Here are two simple ways to convert a batch of MP3 files into MP4 files with ffmpeg. The first method uses a static image as the video track. The second method creates a plain color video track automatically.
Table of Contents
Solution 1: Use a Static Image
Put an image named image.png in the same directory as the MP3 files, then run:
for mp3File in *.mp3; do
outputFile="${mp3File%.mp3}"
ffmpeg -loop 1 -i image.png -i "$mp3File" \
-c:v libx264 -c:a copy -shortest \
"$outputFile.mp4"
done
This creates one MP4 file for each MP3 file. The audio is copied without re-encoding, and image.png is used as a still video frame for the whole duration.
If your files may use .MP3 or mixed-case extensions, adjust the glob pattern or normalize the filenames first.
Solution 2: Generate a Plain Color Video
If you do not need a cover image, ffmpeg can generate a simple video stream:
mkdir -p out
for f in *.mp3; do
ffmpeg -f lavfi -i color=s=160x120:r=2 -i "$f" \
-c:v libx264 -preset ultrafast -c:a copy -shortest \
"out/${f%.mp3}.mp4"
done
This writes the converted files into the out/ directory. The generated video is a 160×120 color frame at 2 frames per second, which is enough when the video track is only needed to wrap the audio in an MP4 container.
Check the Result
To confirm the output file contains both audio and video streams, run:
ffprobe "output.mp4"
Replace output.mp4 with one of the generated files. You should see an audio stream from the original MP3 and a video stream created by one of the commands above.
