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.
Asked
Active
Viewed 8.9k times
3 Answers
175
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/
-
1`Unable to find a suitable output format for 'scale=1280:1024' scale=1280:1024: Invalid argument` Any idea why? – Agey Jun 23 '15 at 12:45
-
1@Equanox I've had the same issue, but it was caused by the "\" sign when copying and pasting. Removing it solves the issue. – user1319182 Jun 19 '16 at 08:39
-
When I try to run this, I get an error: Option loop not found - I'm using ffmpeg version 2.8.4 on windows – Igor Dvorkin Dec 23 '16 at 05:01
-
1It works when I removed `-c:v libx264` -- it complains not finding the library. – Yan King Yin Jan 21 '17 at 14:15
-
1while using jpeg image it takes a lot of time to execute in android. how can i solve this? – Arpan Dixit Mar 02 '17 at 06:32
-
2@YanKingYin the libx264 is a non GPL library, which might be missing. If you want to install it, you can do so (on mac using mac ports) by: 'port install ffmpeg +nonfree' – andreas Oct 29 '17 at 12:04
-
4It answers the question, but I don't like the use of all those redundant additions in the command. – joey Jun 04 '18 at 21:39
-
26@joey Me neither, especially because OP did not ask for anything specific. You want to make a video from a single pic and don't care about any details at all? `ffmpeg -loop 1 -i image.png -t 5 out.mp4` – Doe Johnson Nov 28 '18 at 05:52
-
-
9This is great, but...it takes forever and melts my CPU to generate a 40 minute video based on a single 720p PNG image. Is there a way to speed it up? Compression doesn't matter as long as it stays under a couple GB. – HunterZ May 10 '20 at 00:35
-
2Note that if you need to specify the framerate (e.g. you want to concat this with existing video and need them to match) you can add e.g. `-r 30` before output to specify 30 FPS – tobek Nov 04 '20 at 22:52
-
@DoeJohnson YEAH, much simpler command. I think FFmpeg is smart enough to figure out the basics – RealZombs Mar 04 '21 at 11:47
-
10
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
brat
- 475
- 5
- 13
0
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
dazzafact
- 2,094
- 3
- 25
- 36