Skip to content

Cap rendered frames to prevent ffmpeg over-read#1933

Open
jakubjezek001 wants to merge 1 commit into
developfrom
bugfix/YN-0890-hiero-publish---running-out-of-disk-space-for-tmp-files
Open

Cap rendered frames to prevent ffmpeg over-read#1933
jakubjezek001 wants to merge 1 commit into
developfrom
bugfix/YN-0890-hiero-publish---running-out-of-disk-space-for-tmp-files

Conversation

@jakubjezek001

@jakubjezek001 jakubjezek001 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Changelog Description

Cap output frames when rendering image sequences and OTIO segments by computing an explicit frames_to_render and passing -frames:v to 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

  • Implementation: compute frames_to_render from sequence collection indexes or OTIO range duration and add -frames:v <n> to the ffmpeg command.
  • Files: client/ayon_core/plugins/publish/extract_otio_review.py.

Testing notes:

  1. Render a review segment from an image sequence that has extra numbered files beyond the intended range.
  2. Confirm ffmpeg stops at the intended frame and output duration matches the OTIO segment.
  3. Compare outputs with/without this change to observe that over-read is prevented.

Dependency

Close #1932
YN-0890

@ynbot ynbot added type: bug Something isn't working size/XS labels Jul 8, 2026
@jakubjezek001 jakubjezek001 changed the title Limit frames in ffmpeg output for OTIO review Cap rendered frames to prevent ffmpeg over-read Jul 8, 2026
@jakubjezek001 jakubjezek001 removed size/XS type: bug Something isn't working labels Jul 8, 2026
@jakubjezek001 jakubjezek001 marked this pull request as ready for review July 8, 2026 12:22
@jakubjezek001 jakubjezek001 reopened this Jul 8, 2026
@jakubjezek001 jakubjezek001 added the type: bug Something isn't working label Jul 8, 2026
@jakubjezek001 jakubjezek001 self-assigned this Jul 8, 2026

@BigRoy BigRoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@ynbot ynbot moved this to Review In Progress in PR reviewing Jul 8, 2026
@BigRoy BigRoy requested a review from Copilot July 8, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_render for image-sequence inputs from the sequence collection indexes.
  • Compute frames_to_render for 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.

Comment on lines 514 to 518
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

YN-0890: Hiero publish - running out of disk space for tmp files

4 participants