分享

ffmpeg 图片转视频命令

 昵称597197 2016-01-18
ffmpeg -f image2 -r 1/5 -i logo.png -vcodec libx264 out.mp4


For very recent versions of ffmpeg (roughly from the end of year 2013)

The following will create a video slideshow (using video codec libx264 or webm) from all the png images in the current directory. The command accepts image names numbered and ordered in series (img001.jpgimg002.jpgimg003.jpgas well as random bunch of images.

(each image will have a duration of 5 seconds)

ffmpeg -r 1/5 -pattern_type glob -i '*.png' -c:v libx264 out.mp4   # x264 video
ffmpeg -r 1/5 -pattern_type glob -i '*.png'              out.webm  # WebM video

For older versions of ffmpeg

This will create a video slideshow (using video codec libx264 or webm) from series of png images, named img001.pngimg002.pngimg003.png, …

(each image will have a duration of 5 seconds)

ffmpeg -f image2 -r 1/5 -i img%03d.png -vcodec libx264 out.mp4     # x264 video
ffmpeg -f image2 -r 1/5 -i img%03d.png                 out.webm    # WebM video

You may have to slightly modify the following commands if you have a very recent version of ffmpeg

This will create a slideshow in which each image has a duration of 15 seconds:

ffmpeg -f image2 -r 1/15 -i img%03d.png out.webm

If you want to create a video out of just one image, this will do (output video duration is set to 30 seconds):

ffmpeg -loop 1 -f image2 -i img.png -t 30 out.webm

If you don't have images numbered and ordered in series (img001.jpgimg002.jpgimg003.jpg) but rather random bunch of images, you might try this:

cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - out.webm

or for png images:

cat *.png | ffmpeg -f image2pipe -r 1 -vcodec png -i - out.webm

That will read all the jpg/png images in the current directory and write them, one by one, using the pipe, to the ffmpeg's input, which will produce the video out of it.

Important: All images in a series need to be of the same size (x and y dimensions) and format.

Explanation: By telling FFmpeg to set the input file's FPS option (frames per second) to some very low value, we made FFmpeg duplicate frames at the output and thus we achieved to display each image for some time on screen. You have seen, that you can set any fraction as framerate. 140 beats per minute would be -r 140/60.

Source: The FFmpeg wiki


For creating images from a video use

ffmpeg -i video.mp4 img%03d.png

This will create images named img001.pngimg002.pngimg003.png, …

shareimprove this answer
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多