mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-09 03:16:38 +00:00
feat(distributed): add optional cfr flag for exact constant frame rate
Distributed-render output today uses -c:v copy through concat → mux → faststart, which means PTS timestamps from each chunk pass through unchanged. Container r_frame_rate is exact (#1040 + this PR's parent), but stream-level avg_frame_rate stays PTS-derived and can land on fractional rationals like 27648000/921677 over a 60s render. Same for sub-ms duration drift. This is the achievable bar within -c copy stream-copy concat. For most consumers (browser playback, YouTube, etc.) the difference is invisible. For downstream tools that strict-check avg_frame_rate or ms-precision duration (broadcast workflows, frame-accurate compositors, some third-party transcoders), it matters. Adds an opt-in cfr config flag (default false). When true, the assemble step's final pass re-encodes with -fps_mode cfr -r <fps> instead of -c copy, producing exact CFR output. Trade-off: ~2-5x the stitch time for a 60s 1080p clip; second-generation H.264 quality loss is negligible at -crf 18 but is non-zero.
This commit is contained in:
@@ -81,6 +81,16 @@ export interface AssembleEvent {
|
||||
OutputS3Uri: string;
|
||||
/** Output container format; drives file vs frame-dir handling. */
|
||||
Format: DistributedFormat;
|
||||
/**
|
||||
* Optional exact-CFR re-encode at assemble time. When `true`, the final
|
||||
* assembled video is re-encoded with `-fps_mode cfr -r <fps>` so the
|
||||
* stream's `avg_frame_rate` matches the container's `r_frame_rate`
|
||||
* exactly (and the file's duration is exact, not PTS-derived). Trade-off
|
||||
* is ~2-5x the assemble wall-clock. mp4 only — webm / mov stream-copy
|
||||
* paths already produce exact avg_frame_rate. Default `false` /
|
||||
* unset preserves current `-c copy` behavior.
|
||||
*/
|
||||
Cfr?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user