2

I have a variable frame rate video file. There is a delay of over 30 seconds between some frames. Can I transcode the video and reduce all delays between frames over a certain value, say 1 second, to that value? This would mean the maximum gap or delay between any 2 consecutive frames would be 1 second.

4

It can be done with ffmpeg. I ended up using following:

ffmpeg -i input-file -vf "setpts=ifnot(isnan(PREV_OUTPTS)\,PREV_OUTPTS) + min(1000\,PTS - PREV_INPTS)" -c:v libx264 -preset ultrafast -crf 0 output.mkv

You can print expressions like this, which is useful for testing:

ffmpeg -i input-file -vf "setpts=print(PREV_INPTS)\;print(PTS - PREV_INPTS)\;print(ifnot(isnan(PREV_OUTPTS)\,PREV_OUTPTS) + min(1000\,PTS - PREV_INPTS))" -c:v libx264 -preset ultrafast -crf 0 output.mkv

Following documentation may be helpful:

https://ffmpeg.org/ffmpeg-all.html#Expression-Evaluation

https://ffmpeg.org/ffmpeg-all.html#setpts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.