Repository navigation
feat(encoder): EncoderOptions::segment_frames so a bitrate cap can hold across segments - #276
SwapShaOnline wants to merge 1 commit into
Conversation
…gth so a bitrate cap can hold Segments are at most a second long, and each is a fresh encoder, so an x264 maxrate/bufsize cap starts over every second (dmtrKovalenko#275). segment_frames: None keeps today's behaviour; the video's length in frames encodes it in one run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes #275.
Segments are at most a second long (
min_segment_framesismin(gop_size, fps)), and each one is a fresh encoder run, so an x264maxrate/bufsizecap starts over with a full buffer every second. This adds an opt-inEncoderOptions::segment_frames: Option<usize>that sets the minimum segment length:None(the default) keeps today's behaviour, so nothing changes for existing renders.The doc comment on the field explains when to use it. A scheduler test checks that a minimum equal to the length gives one segment.
Results on the repro in #275 (1080×1920, 60 fps, 20 s,
crf 22,maxrate 4.5M,bufsize 9M, Apple M2, Skia on Metal):main(1 s segments)segment_frames: Some(1200)segment_frames: Some(1200)+("threads", "0")One segment alone is slow because segments default to one codec thread each, so it is worth pairing with
("threads", "0"). The field's doc doesn't say so yet; I can add that, or make one segment imply automatic threads, if you prefer.The other design I considered was switching to one segment automatically when
codec_paramshasmaxrate. I kept it opt-in because that is your call; happy to change it.Checked:
cargo test -p fframes(99 passed, 1 ignored),cargo clippy -p fframes -- -D warnings(no errors; the existing unused-dependency warnings only) andcargo fmt -p fframes --check, on macOS 27.2 with rustc 1.100.0. The rendering results above use the Skia Metal pipeline. The CPU renderer reads the samemin_segment_frames(cpu.rs#L195), but I didn't render with it, and the e2e snapshots were not run.🤖 Generated with Claude Code
Summary by CodeRabbit