To convert a folder of images into an MP4 video using FFmpeg, follow these steps:
- Make sure all the images are in the same folder.
- Rename the images sequentially if they are not already (e.g.,
img001.jpg, img002.jpg, img003.jpg, etc.).
- Use consistent naming with leading zeros for proper ordering.
Use the following FFmpeg command in your terminal or command prompt:
ffmpeg -framerate 30 -i /path/to/images/img%03d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p output.mp4
-framerate 30: Sets the input frame rate to 30 FPS (adjust as needed).
-i /path/to/images/img%03d.jpg: Specifies the input images with a numeric sequence (e.g., img001.jpg, img002.jpg).
%03d matches filenames with three digits (001, 002, etc.).
-c:v libx264: Sets the video codec to H.264.
-r 30: Sets the output video frame rate to 30 FPS (match it to the input framerate).
-pix_fmt yuv420p: Ensures compatibility with most video players.
output.mp4: The name of the output MP4 file.
- Replace
30 with your desired FPS.
- If your images have a different format (e.g., PNG), replace
.jpg with .png.
- Customize the output filename (
output.mp4) as desired.
After running the command, you’ll have an MP4 video generated from the folder of images.