slow ffmpeg's images per second when creating

2019-04-28 03:47发布

问题:

I have a series of screenshots from a demo that I want to put in a video. I am using ffmpeg for this purpose. The command is ffmpeg -f image2 -i screenshot_%5d.png -vcodec mpeg4 demo.avi. However, the video length is shorter than what I want, and it moves very fast. How do I specify how many images per second I want? I tried the -r argument but that did not work.

回答1:

You can change video speed by adjusting the “presentation time stamp” (PTS). In your case:

ffmpeg -f image2 -i screenshot_%5d.png -vcodec mpeg4  -vf "setpts=5*PTS" demo.avi

You'll get video, which plays 5 times slower, than normal video.

If you want to make it 5 times faster:

ffmpeg -f image2 -i screenshot_%5d.png -vcodec mpeg4  -vf "setpts=(1/5)*PTS" demo.avi


回答2:

You need to specify the capture rate

 # Note: The frame rate (-r) can be an integer or a float 

 ffmpeg  -r 23.976 \
         -f image2 \
         -i test-%06d.png \
         -vcodec mpeg4 \
         test.avi