0

I want to make a long video from a single image in ffmpeg.

I need it to be fastly encodeable and at the end the video should have a small file size.

Is it possible to fill the video with frames that point to the preivous(or the first) frame with no changes?

I tried with this code, but it was slow and made a big file:

ffmpeg -loop 1 -i image.jpg -c:v libx264 -tune stillimage -shortest -preset ultrafast -t 3600 output.mp4
zodrob
  • 1
  • 4
  • How are you going to use the output? Where? – Gyan Jun 14 '20 at 05:40
  • I just need a very long video. I know there are different better solutions, like looping a little segment, but I need a very long one. – zodrob Jun 14 '20 at 09:28
  • But it would already help if I can fix the encoding fps at a stable value. Now it is dropping 1-2 encoding fps / every second.(and getting slower) – zodrob Jun 14 '20 at 09:30
  • It's possible to encode this quickly. But it won't be a small file. – Gyan Jun 14 '20 at 10:48
  • And how would you do this quickly? (if big file is ok) – zodrob Jun 14 '20 at 14:55

2 Answers2

1

You can do this in two steps:

1) Encode a short loop, say, 30 seconds.

ffmpeg -loop 1 -framerate 5 -i image.jpg -pix_fmt yuv420p -c:v libx264 -t 30 looped.mp4

2) Loop the encode for desired duration.

ffmpeg -stream_loop -1 -i looped.mp4 -c copy -t 3600 output.mp4
Gyan
  • 85,394
  • 9
  • 169
  • 201
1

Maybe this will help - enter it all on a single line and it will stream a single image (called test.jpg) repeatedly. See: https://stackoverflow.com/a/71885708/18795194 for my post and an explanation of the parameters.

ffmpeg 
-loop 1 
-fflags +genpts 
-framerate 1/30 
-i test.jpg 
-c:v libx264 
-vf fps=25 
-pix_fmt yuvj420p 
-crf 30 
-f fifo -attempt_recovery 1 -recovery_wait_time 1 
-f flv rtmp://localhost:5555/video/test
Ran Bo
  • 33
  • 8