Creating a video from a single image for a specific duration in ffmpeg

VideoFfmpeg

Video Problem Overview


How do I generate a movie using ffmpeg using a single image (image1.png) for a duration of 15 seconds with a specific resolution so when I play the video, the image will appear on screen for 15 seconds.

Video Solutions


Solution 1 - Video

ffmpeg -loop 1 -i image.png -c:v libx264 -t 15 -pix_fmt yuv420p -vf scale=320:240 out.mp4
  • The -t 15 makes it 15 seconds long.
  • The -vf scale=320:240 sets the width/height.

Make sure to use the latest ffmpeg version e.g. http://johnvansickle.com/ffmpeg/

Solution 2 - Video

Found this to be faster:

ffmpeg -framerate 1/10 -i DJI_0024.JPG -c:v libx264 -t 10 -pix_fmt yuv420p -vf scale=320:240 out.mp4

-t 10 making the video 10 seconds long, and setting -framerate 1/10. Divisor of framerate should be same number as the argument to -t. This made a jpeg with large resolution to be converted to a video in less then a second for me, while the other answer took about 40 sec. Also resulting filesize became slightly smaller. from 3.38MB to 3.17MB

Solution 3 - Video

use ffmpeg with the Parameter -r 0.01 for almost no frame rate. This makes the file about 65% smaller But you maybe also need to cut the length with this Paramter -ss 00:00:00 -t 00:00:27

heres my code:

ffmpeg -r 0.01 -loop 1 -i image.jpg -i audio.mp3 -c:v libx264 -tune stillimage -preset  ultrafast -ss 00:00:00 -t 00:00:27   -c:a aac  -b:a 96k -pix_fmt yuv420p  -shortest out.mp4 -y

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDharmeshView Question on Stackoverflow
Solution 1 - VideoEquanoxView Answer on Stackoverflow
Solution 2 - VideobratView Answer on Stackoverflow
Solution 3 - VideodazzafactView Answer on Stackoverflow