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