Skip to content

fix(render): preserve orientation for portrait video sources - #29

Merged
gregpr07 merged 1 commit into
browser-use:mainfrom
alexandrepirescontato1-bipe:fix/portrait-video-scaling
May 10, 2026
Merged

gregpr07 merged 1 commit into
browser-use:mainfrom
alexandrepirescontato1-bipe:fix/portrait-video-scaling

Conversation

@alexandrepirescontato1-bipe

@alexandrepirescontato1-bipe alexandrepirescontato1-bipe commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Portrait videos (height > width) were being scaled by width, squishing vertical footage. Added is_portrait_source() to detect orientation and switch to scale=-2:H for portrait clips.


Summary by cubic

Fixes squished portrait videos. We now detect orientation and scale portrait sources by height to keep vertical footage correct in draft and final renders.

  • Bug Fixes
    • Added is_portrait_source() using ffprobe to check width and height.
    • For portrait: draft uses scale=-2:1280, final uses scale=-2:1920; landscape behavior unchanged.

Written for commit 3ac4e7b. Summary will update on new commits.

Landscape videos were scaled by width (scale=W:-2), which works for
horizontal footage but squishes portrait/vertical clips (height > width)
because the height becomes the constrained dimension.

Added is_portrait_source() which uses ffprobe to detect when h > w, then
switches the scale filter to scale=-2:H so portrait sources are scaled by
height instead, keeping the correct 9:16 orientation throughout the pipeline.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="helpers/render.py">

<violation number="1" location="helpers/render.py:144">
P2: Portrait detection ignores rotation metadata, so metadata-rotated portrait videos can be misclassified as landscape and scaled incorrectly.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread helpers/render.py
capture_output=True, text=True, check=True,
)
w, h = map(int, out.stdout.strip().split(","))
return h > w

@cubic-dev-ai cubic-dev-ai Bot May 9, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Portrait detection ignores rotation metadata, so metadata-rotated portrait videos can be misclassified 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 144:

<comment>Portrait detection ignores rotation metadata, so metadata-rotated portrait videos can be misclassified as landscape and scaled incorrectly.</comment>

<file context>
@@ -131,6 +131,21 @@ def is_hdr_source(video: Path) -> bool:
+            capture_output=True, text=True, check=True,
+        )
+        w, h = map(int, out.stdout.strip().split(","))
+        return h > w
+    except Exception:
+        return False
</file context>
Fix with Cubic

@gregpr07
gregpr07 merged commit 1200463 into browser-use:main May 10, 2026
2 checks passed
dannywsh pushed a commit to dannywsh/video-use-ad that referenced this pull request Sep 5, 2026
…-use#29)

Landscape videos were scaled by width (scale=W:-2), which works for
horizontal footage but squishes portrait/vertical clips (height > width)
because the height becomes the constrained dimension.

Added is_portrait_source() which uses ffprobe to detect when h > w, then
switches the scale filter to scale=-2:H so portrait sources are scaled by
height instead, keeping the correct 9:16 orientation throughout the pipeline.

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
zeekay pushed a commit to Dream-AI-4444/video-use that referenced this pull request Sep 9, 2026
…-use#29)

Landscape videos were scaled by width (scale=W:-2), which works for
horizontal footage but squishes portrait/vertical clips (height > width)
because the height becomes the constrained dimension.

Added is_portrait_source() which uses ffprobe to detect when h > w, then
switches the scale filter to scale=-2:H so portrait sources are scaled by
height instead, keeping the correct 9:16 orientation throughout the pipeline.

Co-authored-by: Hanzo Dev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants