Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

video

ffmpeg

People also ask

How do I set video duration in FFmpeg?

Use the -t option to specify a time limit: `-t duration' Restrict the transcoded/captured video sequence to the duration specified in seconds. hh:mm:ss[.


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/


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