Loop Static Image with Multiple Audio Tracks in FFmpeg
Combining a static image with several audio tracks is a popular method for creating YouTube videos, podcasts, and album playlists. This guide explains how to use FFmpeg to merge multiple audio files into a seamless stream, loop a single image for the entire duration of the audio, and export a fully compatible video file with optimal compression settings.
Method 1: Using a Single Command for a Few Audio Files
If you only have two or three audio files, you can load them directly
as inputs and use FFmpeg's filter_complex to join them into
one continuous track while looping the image.
Run the following command:
ffmpeg -loop 1 -framerate 2 -i image.png -i track1.mp3 -i track2.mp3 -filter_complex "[1:a][2:a]concat=n=2:v=0:a=1[outa]" -map 0:v -map "[outa]" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest output.mp4Method 2: Using a Text List for Many Audio Tracks
When dealing with a large playlist or an entire album, listing every file via the command line becomes unwieldy. The most efficient approach is using FFmpeg's concat demuxer.
Step 1: Create an Audio List
Create a plain text file named audio_list.txt in the
same directory as your files. Add each audio file using the following
format:
file 'track1.mp3'
file 'track2.mp3'
file 'track3.mp3'
Step 2: Run the FFmpeg Command
Execute this command to read the text list and loop the image over the combined tracks:
ffmpeg -loop 1 -framerate 2 -i image.png -f concat -safe 0 -i audio_list.txt -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest output.mp4Explanation of Parameters
-loop 1: Instructs FFmpeg to repeat the single input image indefinitely.-framerate 2: Sets the video frame rate to 2 frames per second. Since the image does not move, a low frame rate drastically speeds up encoding and reduces file size.-tune stillimage: Configures thelibx264encoder to optimize compression specifically for non-moving pictures.-pix_fmt yuv420p: Converts the pixel format to YUV 4:2:0 planar, ensuring the output MP4 plays reliably on all browsers, mobile devices, and media players.-shortest: Automatically stops encoding as soon as the audio ends, preventing the looped image from generating an infinite video.