0

I'm using ffmpeg to show images for different durations in a video:

(command taken from example on this page)

ffmpeg -f concat -i input.txt -vsync vfr -pix_fmt yuv420p output.mp4

Here what input.txt roughly looks like:

file '/path/to/im1.png'
duration 123
file '/path/to/im2.png'
duration 234
file '/path/to/im3.png'
duration 235
file '/path/to/im4.png'
duration 400
file '/path/to/im4.png'

The resulting file has trouble playing back in mpv, Movies and TV (windows), and VLC. On a hunch, I ran the file through ffmpeg again to see I could 'fix' the output file (command used: ffmpeg -i in.mp4 out.mp4). out.mp4 was much larger than in.mp4 (around an order of magnitude), but played smoothly, showed progress correctly, and was able to seek properly. What could be the reason for this?

1

With the -vsync vfr flag, ffmpeg will insert the images at time 0, 123, 357..etc with no frames in between. A video player normally works with streams where adjacent frames are centiseconds apart, so its buffering/caching system are designed with that expectation. You could get away with the VFR mode if durations were in the single-digit seconds, but not here. I would recommend CFR mode with a low frame rate.

So,

ffmpeg -f concat -i input.txt -vsync cfr -r 2 -pix_fmt yuv420p output.mp4
  • Ahh, so if I'm understanding correctly it's kinda the players faults for not handling this valid, but weird video? – Matt M. Feb 15 at 6:40
  • You could say that, but fault is a harsh term. Any software will be designed for vanilla and common edge cases. – Gyan Feb 15 at 6:44
  • Strangely enough, running my original command and then passing it through ffmpeg again is faster then just using -vsync cfr (around 4x faster) – Matt M. Feb 15 at 6:46
  • Vsync cfr is default for mp4 output. The difference will be due to the framerate. – Gyan Feb 15 at 7:08

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.