'How can I loop one frame with ffmpeg? All the other frames should point to the first with no changes, maybe like a recusion

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


Solution 1:[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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gyan
Solution 2 Ran Bo