lpms icon indicating copy to clipboard operation
lpms copied to clipboard

Abort transcoding if output duration or frame count grows out of bounds

Open stronk-dev opened this issue 2 months ago • 0 comments

This PR:

  • Tracks first seen PTS, accumulated duration and last seen PTS for the decode & encode
  • Tracks accumulated duration for the decode & encode
  • Aborts if we run out of 'frame budget' (if we have a known constant framerate) as well as if the output duration grows too far compared to the input duration.
  • Instead of doing a avfilter_graph_create_filter (which is incompatible with FFMPEG 8), use the more universal avfilter_graph_alloc_filter + avfilter_init_str

Note that:

  • We probably don't need to track both start/end timestamp AND the accumulated duration. Since we already fallback on LibAV's best_effort_timestamp (or the frame duration if even that is null). I've left both in for now and just take the biggest one for the guard.
  • Slack for frame count or duration is fairly arbitrary at the moment.
  • We should take extra care for inputs that have timestamps gaps in them... We don't want to trigger the guards for any segment that IE has a 100ms jump.

This PR definitely needs more testing and code review, but is put up here for brave guinea pigs in advance.

stronk-dev avatar Oct 15 '25 14:10 stronk-dev