Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions helpers/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,21 @@ def extract_segment(
"""
out_path.parent.mkdir(parents=True, exist_ok=True)

probe = subprocess.run(
["ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=width,height",
"-of", "csv=p=0:s=x", str(source)],
capture_output=True, text=True,
)
try:
sw, sh = (int(x) for x in probe.stdout.strip().split("x")[:2])
is_vertical = sh > sw
except Exception:
is_vertical = False
Comment on lines +157 to +167
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Portrait detection ignores rotation metadata, so rotated portrait phone clips can still be treated as landscape and scaled incorrectly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At helpers/render.py, line 157:

<comment>Portrait detection ignores rotation metadata, so rotated portrait phone clips can still be treated as landscape and scaled incorrectly.</comment>

<file context>
@@ -154,10 +154,21 @@ def extract_segment(
     """
     out_path.parent.mkdir(parents=True, exist_ok=True)
 
+    probe = subprocess.run(
+        ["ffprobe", "-v", "error", "-select_streams", "v:0",
+         "-show_entries", "stream=width,height",
</file context>
Suggested change
probe = subprocess.run(
["ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=width,height",
"-of", "csv=p=0:s=x", str(source)],
capture_output=True, text=True,
)
try:
sw, sh = (int(x) for x in probe.stdout.strip().split("x")[:2])
is_vertical = sh > sw
except Exception:
is_vertical = False
try:
probe = subprocess.run(
["ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_streams", "-of", "json", str(source)],
capture_output=True, text=True, check=True,
)
stream = json.loads(probe.stdout)["streams"][0]
sw = int(stream["width"])
sh = int(stream["height"])
rotation = int(stream.get("tags", {}).get("rotate", 0) or 0)
for sd in stream.get("side_data_list", []):
rotation = int(sd.get("rotation", rotation) or rotation)
is_vertical = (rotation % 180 != 0) or (sh > sw)
except Exception:
print("warning: could not detect source orientation; defaulting to landscape", file=sys.stderr)
is_vertical = False
Fix with Cubic

if draft:
scale = "scale=1280:-2"
scale = "scale=-2:1280" if is_vertical else "scale=1280:-2"
else:
scale = "scale=1920:-2"
scale = "scale=-2:1920" if is_vertical else "scale=1920:-2"

vf_parts: list[str] = []
if is_hdr_source(source):
Expand Down