How to Loop an Image in FFmpeg

This article explains how to use the -loop option in FFmpeg to convert a single static image into a continuous video loop. You will learn the correct command syntax, how to set a specific duration for the video, and how to apply essential encoding settings to ensure the output plays smoothly across different media players.

To loop an image in FFmpeg, you must place the -loop 1 option before specifying the input image. This tells FFmpeg to read the single image infinitely. Because the loop is infinite, you must also define a stopping point using the duration parameter (-t) or a frame limit.

Basic Command Syntax

Here is the standard command to create a 10-second MP4 video from a single image:

ffmpeg -loop 1 -i input.png -c:v libx264 -t 10 -pix_fmt yuv420p output.mp4

Parameter Breakdown

Adding Audio to the Loop

If you want to loop the image to match the length of an audio track (like an MP3 or WAV file), you can combine the image loop with the -shortest flag:

ffmpeg -loop 1 -i input.png -i audio.mp3 -c:v libx264 -c:a aac -pix_fmt yuv420p -shortest output.mp4

In this command: * -i audio.mp3: Imports your audio file. * -c:a aac: Encodes the audio to AAC format. * -shortest: Tells FFmpeg to stop encoding as soon as the shortest input finishes. Since the image loops infinitely, the video will end exactly when the audio file ends.