用 ffmpeg 把编号图片合成视频
把一串按编号命名的照片合成为 MP4 延时摄影或幻灯片视频。
运行:ffmpeg -framerate 24 -i frame%04d.png -c:v libx264 -pix_fmt yuv420p output.mp4
01命令
命令
$ ffmpeg -framerate 24 -i frame%04d.png -c:v libx264 -pix_fmt yuv420p output.mp402作用说明
先把照片按 frame0001.png、frame0002.png 这样的编号命名,%04d 表示四位数字编号。-framerate 24 表示每秒播放 24 张图——想加快延时效果就调大,想让幻灯片慢一点就调小。-pix_fmt yuv420p 保证生成的 MP4 在大多数播放器和手机上都能正常播放。
03风险
!注意: 编号必须从 0001 开始且不能缺号,否则 ffmpeg 会在第一张缺图处停止。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- FFmpeg Documentation依据: Documents -framerate (input frames per second for the image demuxer), -i with image sequence patterns (frame%04d.png), and libx264 encoding via -c:v.
- FFmpeg Formats Documentation依据: Documents the image2 image file demuxer/muxer used for numbered image sequences, including its framerate option and %d-style filename patterns.
最后验证: 2026-09-19 · 分类: 媒体