Cap rendered frames to prevent ffmpeg over-read#1933
Conversation
BigRoy
left a comment
There was a problem hiding this comment.
Makes sense - I'm no ffmpeg export so no idea if -frames:v has side effects. E.g. what if it's a video that has a variable frame rate? Does that work?
| frame_start = otio_range.start_time.value | ||
| input_fps = otio_range.start_time.rate | ||
| frame_duration = otio_range.duration.value | ||
| frames_to_render = int(round(frame_duration)) |
There was a problem hiding this comment.
Should this variable be named frames_num or frames_count. Is frames_to_render too ambiguous?
| # the intended range, e.g. the image2 demuxer has no "end frame" | ||
| # option and will keep consuming consecutive numbered files on | ||
| # disk beyond what this segment actually needs. | ||
| frames_to_render = None |
There was a problem hiding this comment.
Can we make this less ambiguous by enforcing it to be int, like have the default be 0?
Just so we can do:
frames_num: int = 0
To enforce it's always integer, etc.
There was a problem hiding this comment.
Pull request overview
This PR prevents FFmpeg from reading past the intended end of an image sequence or OTIO-defined segment by computing an explicit frame count (frames_to_render) and passing it to FFmpeg via -frames:v, ensuring the produced review render contains the expected number of frames.
Changes:
- Compute
frames_to_renderfor image-sequence inputs from the sequence collection indexes. - Compute
frames_to_renderfor OTIO/video inputs from the OTIO range duration. - Add
-frames:v <n>to the FFmpeg command for video/sequence renders to cap output frames.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| frame_duration = otio_range.duration.value | ||
| frames_to_render = int(round(frame_duration)) | ||
| sec_start = frames_to_seconds(frame_start, input_fps) | ||
| sec_duration = frames_to_seconds( | ||
| frame_duration, input_fps |
Changelog Description
Cap output frames when rendering image sequences and OTIO segments by computing an explicit
frames_to_renderand passing-frames:vto ffmpeg. This prevents the ffmpeg image2 demuxer from reading files past the intended range and ensures rendered outputs contain the correct number of frames. Affects the publish reviewer/renderer.Additional info
frames_to_renderfrom sequence collection indexes or OTIO range duration and add-frames:v <n>to the ffmpeg command.client/ayon_core/plugins/publish/extract_otio_review.py.Testing notes:
Dependency
Close #1932
YN-0890