feat: add --fps option to render.py (default 24)#27
Open
redsung-team wants to merge 1 commit intobrowser-use:mainfrom
Open
feat: add --fps option to render.py (default 24)#27redsung-team wants to merge 1 commit intobrowser-use:mainfrom
redsung-team wants to merge 1 commit intobrowser-use:mainfrom
Conversation
The output frame rate was hardcoded to 24fps (cinematic) inside `extract_segment`'s ffmpeg call. This is a great default for talking-head or interview footage but loses motion fidelity when the source is 60fps screen-capture or 30fps tutorial material. This patch threads an `fps` parameter through `extract_segment` → `extract_all_segments` → `main`, exposed via a new `--fps` CLI flag. The default stays at 24, so existing behavior is unchanged. Users who need 30 or 60 can now pass `--fps 60` instead of patching the source. Tested with a 60fps screen-capture source; the rendered output now preserves the original frame rate while keeping all other ladder behavior (preset/CRF/scale by mode) intact.
There was a problem hiding this comment.
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:594">
P2: `--fps` accepts non-positive integers and passes them straight to ffmpeg, so a bad CLI value can abort rendering.</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.
| ) | ||
| ap.add_argument( | ||
| "--fps", | ||
| type=int, |
There was a problem hiding this comment.
P2: --fps accepts non-positive integers and passes them straight to ffmpeg, so a bad CLI value can abort rendering.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At helpers/render.py, line 594:
<comment>`--fps` accepts non-positive integers and passes them straight to ffmpeg, so a bad CLI value can abort rendering.</comment>
<file context>
@@ -584,6 +589,12 @@ def main() -> None:
)
+ ap.add_argument(
+ "--fps",
+ type=int,
+ default=24,
+ help="Output frame rate (e.g., 24, 30, 60). Default: 24 (cinematic). Use 60 to preserve screen-capture or 60fps source motion.",
</file context>
Suggested change
| type=int, | |
| type=lambda v: int(v) if int(v) > 0 else (_ for _ in ()).throw(argparse.ArgumentTypeError("--fps must be a positive integer")), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The output frame rate is hardcoded to 24fps inside
extract_segment's ffmpeg call. This is a great default for cinematic talking-head footage but drops motion fidelity for 60fps screen-capture or 30fps tutorial sources. This PR adds a--fpsCLI option (default 24) so users can match the source rate without patching the file.extract_segment(..., fps: int = 24)— new keyword arg, threaded through to-r.extract_all_segments(..., fps: int = 24)— passes through.main()— exposes--fpsargparse flag, default 24.Default stays at 24, so existing behavior is unchanged.
Motivation
Real-world case: a 60fps screen-capture of a financial simulator with voice-over. With the hardcoded 24fps, mouse cursor / chart animation looked stuttery in the cut.
--fps 60preserves the original feel;--fps 30is a sensible middle ground for tutorial content.Test plan
python helpers/render.py --helpshows the new--fps FPSoptionffprober_frame_rate=24/1--fps 60produces 60fps output — verified withffprober_frame_rate=60/1ast.parse)Future direction (not in this PR)
A natural follow-up would be
--fps sourceto auto-match the first source clip's frame rate viaffprobe. Kept out of this PR to keep the change focused — happy to add in a follow-up if maintainers want it.Summary by cubic
Adds a
--fpsoption tohelpers/render.pyto set the output frame rate (default 24). This lets you match 30/60fps sources to preserve motion without changing code.extract_segment(..., fps=24)andextract_all_segments(..., fps=24)passfpsto ffmpeg via-r.main()exposes a--fpsCLI flag; default stays 24.Written for commit 78f7a48. Summary will update on new commits.