user18565: 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.

user18565: 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

18565: <p>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.</p>
 18565: <p>It can be done with ffmpeg. I ended up using following:</p>

<pre><code>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
</code></pre>

<p>You can print expressions like this, which is useful for testing:</p>

<pre><code>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
</code></pre>

<p>Following documentation may be helpful:</p>

<p><a href="https://ffmpeg.org/ffmpeg-all.html#Expression-Evaluation" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-all.html#Expression-Evaluation</a></p>

<p><a href="https://ffmpeg.org/ffmpeg-all.html#setpts" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-all.html#setpts</a></p>
