用 ffmpeg 把图片序列合成视频
把编号 PNG/JPG 帧合成流畅的 MP4——延时摄影、动画帧、扫描图都适用。
运行 `ffmpeg -framerate 24 -i img%04d.png -c:v libx264 -pix_fmt yuv420p slideshow.mp4`,其中 img%04d 对应 img0001.png、img0002.png。
01命令
命令
$ ffmpeg -framerate 24 -i img%04d.png -c:v libx264 -pix_fmt yuv420p slideshow.mp402作用说明
-framerate 决定每秒播放多少张图(这里是 24 张;做幻灯片可用 1/5 表示每 5 秒一张)。%04d 是数字编号模式——四位、不足补零——ffmpeg 的 image2 解复用器会按这个模式读取文件。加上 yuv420p 像素格式可以保证视频在手机、浏览器和社交平台都能正常播放。
03风险
!注意: 文件名必须连续编号,模式对不上时请先批量重命名。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- FFmpeg Documentation依据: Main ffmpeg documentation includes the -framerate input option and stream specifier syntax used in the conversion command.
- FFmpeg Formats Documentation (image2 demuxer)依据: Documents the image2 demuxer options -framerate and pattern_type used to read numbered image sequences.
最后验证: 2026-09-19 · 分类: 媒体