用 FFmpeg 把多个视频合并成一个

使用 FFmpeg 的 concat 功能把多段视频首尾拼接为单个文件。格式一致时直接复制流,合并速度快且无损画质。

Linux视频合并命令行FFmpeg低风险
把视频路径逐行写入 list.txt,然后执行 ffmpeg -f concat -safe 0 -i list.txt -c copy merged.mp4 即可合并。

01命令

命令
$ printf "file '%s'\n" clip1.mp4 clip2.mp4 clip3.mp4 > list.txt && ffmpeg -f concat -safe 0 -i list.txt -c copy merged.mp4

02作用说明

concat demuxer 会按文本文件中列出的顺序依次读取并拼接各段视频。-c copy 表示直接复制音视频数据,不做重新编码,因此速度极快且不损失画质,但要求所有片段的编码格式、分辨率和音频参数一致。如果片段规格不同,请去掉 -c copy 改为重新编码(例如加上 -c:v libx264 -crf 23),让 FFmpeg 统一转码后再合并。

03风险

风险低风险
使用条件ffmpeg (sudo apt install ffmpeg / sudo dnf install ffmpeg)
!注意: 片段编码或分辨率不一致时使用 -c copy 合并,生成的文件很可能无法正常播放;此时应改用重新编码方式。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • FFmpeg Formats Documentation (concat demuxer)
    FFmpeg · vendor-doc · 2026-09-17
    依据: Documents the concat demuxer: it reads a list of files and concatenates them sequentially, with -safe 0 required for absolute paths.
  • ffmpeg(1) — Linux manual page
    Arch Linux · community · 2026-09-17
    依据: Official ffmpeg manual describing -f concat, -i input list handling, and -c copy for stream copying without re-encoding.

最后验证: 2026-09-18 · 分类: 媒体