An audit of 45 real user clips pulled from R2 on 25-jul-2026 found 86% below 1080 wide, 80% of them exactly 406x720 — well under what TikTok, Reels and Shorts expect, so the platforms re-encode an already soft image. Two causes, one on top of the other: - The download capped format selection at 720p whenever PROXY_URL was set. The cap exists to control paid-proxy bandwidth, but it was decided once from `_proxy` rather than per attempt, so it also capped the DIRECT attempt — the one that costs nothing and, with DIRECT_FIRST=1, serves most downloads. It is now chosen per attempt: direct pulls up to 1080p, proxied stays at 720p. - The reframe set out_h = orig_h, so a 720p source could only ever produce a 406x720 crop. `delivery_size()` now upscales to a 1080-wide floor and leaves anything already above it untouched — a 4K source still delivers 1216x2160, so no one loses resolution they supplied. Applied to the v1 fallback too: an emergency render is still the clip the user posts. Its frame loop already resizes to the target dims, so only the target changed. Crop geometry is unaffected — SmoothedCameraman derives the crop from the source dimensions and never reads the output pair, which the call site now documents. Verified end to end: a 1280x720 source that previously rendered 406x720 now renders 1080x1920, correct aspect, no distortion.
89 lines
3.1 KiB
Python
89 lines
3.1 KiB
Python
from reframe_v2 import (
|
|
DELIVERY_MIN_WIDTH,
|
|
concat_list_content,
|
|
dedupe_sendcmd_lines,
|
|
delivery_size,
|
|
general_filtergraph,
|
|
scene_frame_ranges,
|
|
)
|
|
|
|
VERTICAL = 9 / 16
|
|
|
|
|
|
def test_sendcmd_lines_dedupe_to_change_points():
|
|
xs = [100, 100, 100, 104, 104, 110]
|
|
lines = dedupe_sendcmd_lines(xs, fps=30.0)
|
|
assert lines == [
|
|
"0.0000 crop@c x 100;",
|
|
"0.1000 crop@c x 104;",
|
|
"0.1667 crop@c x 110;",
|
|
]
|
|
|
|
|
|
def test_sendcmd_static_camera_is_single_command():
|
|
assert len(dedupe_sendcmd_lines([250] * 300, fps=30.0)) == 1
|
|
|
|
|
|
def test_scene_ranges_clamped_and_keep_strategy():
|
|
ranges = scene_frame_ranges(
|
|
[(0, 100), (100, 250), (250, 400)],
|
|
['TRACK', 'GENERAL', 'TRACK'],
|
|
total_frames=200,
|
|
)
|
|
# Third scene starts past the decoded frame count -> dropped, and the
|
|
# GENERAL strategy stays attached to its own range.
|
|
assert ranges == [(0, 100, 'TRACK'), (100, 200, 'GENERAL')]
|
|
|
|
|
|
def test_scene_ranges_missing_strategy_defaults_to_track():
|
|
assert scene_frame_ranges([(0, 10)], [], 10) == [(0, 10, 'TRACK')]
|
|
|
|
|
|
def test_concat_list_format():
|
|
content = concat_list_content(["/tmp/a/seg_000.mp4", "/tmp/a/seg_001.mp4"])
|
|
assert content == "file '/tmp/a/seg_000.mp4'\nfile '/tmp/a/seg_001.mp4'\n"
|
|
|
|
|
|
class TestDeliverySize:
|
|
"""A 720p source must not produce a 406x720 clip (prod audit, 25-jul-2026)."""
|
|
|
|
def test_720p_source_is_upscaled_to_the_delivery_floor(self):
|
|
assert delivery_size(1280, 720, VERTICAL) == (1080, 1920)
|
|
|
|
def test_1080p_source_lands_on_the_floor_exactly(self):
|
|
assert delivery_size(1920, 1080, VERTICAL) == (1080, 1920)
|
|
|
|
def test_tiny_source_still_reaches_the_floor(self):
|
|
# 360x640 sources were shipping as-is; platforms treat that as junk.
|
|
assert delivery_size(640, 360, VERTICAL) == (1080, 1920)
|
|
|
|
def test_high_res_source_is_never_downscaled(self):
|
|
# 4K source: the native crop is already well past the floor, so keep it.
|
|
assert delivery_size(3840, 2160, VERTICAL) == (1216, 2160)
|
|
|
|
def test_already_vertical_source_keeps_its_full_height(self):
|
|
assert delivery_size(1080, 1920, VERTICAL) == (1080, 1920)
|
|
|
|
def test_square_output_uses_the_same_floor(self):
|
|
assert delivery_size(1280, 720, 1.0) == (1080, 1080)
|
|
|
|
def test_dimensions_are_always_even(self):
|
|
for w, h in [(1280, 720), (1920, 1080), (854, 480), (3840, 2160), (641, 361)]:
|
|
out_w, out_h = delivery_size(w, h, VERTICAL)
|
|
assert out_w % 2 == 0 and out_h % 2 == 0, (w, h)
|
|
|
|
def test_never_returns_below_the_floor(self):
|
|
for w, h in [(320, 180), (640, 360), (1280, 720), (1920, 1080)]:
|
|
assert delivery_size(w, h, VERTICAL)[0] >= DELIVERY_MIN_WIDTH
|
|
|
|
def test_aspect_ratio_is_preserved(self):
|
|
for w, h in [(1280, 720), (640, 360), (3840, 2160)]:
|
|
out_w, out_h = delivery_size(w, h, VERTICAL)
|
|
assert abs(out_w / out_h - VERTICAL) < 0.01, (w, h)
|
|
|
|
|
|
def test_general_filtergraph_targets_output_geometry():
|
|
graph = general_filtergraph(608, 1080)
|
|
assert "gblur" in graph
|
|
assert "scale=608:-2" in graph
|
|
assert "overlay=x=(W-w)/2:y=(H-h)/2" in graph
|