Skip to content

ffmpeg多媒体框架

L edited this page May 10, 2021 · 5 revisions

FFmpeg是领先的多媒体框架,能够解码,编码,转码,mux,demux,流,过滤和播放人类和机器创建的几乎所有内容。
官网下载各平台的执行文件(比如windows上就是exe文件),通过命令行操作
参考:merge two mp4 video as single video using ffmpeg in C# is not working
合并视频指令:(官方资料)

ffmpeg -f concat -i merge.txt -c copy output.mp4

merge.txt如下:

file 20210423_195727.mp4
file 20210423_195743.mp4

以上文件在当前命令行目录下,如果不在当前目录下,需要写相对路径,比如

file /mnt/share/file-1.wav

封装的C#库:FFmpeg.AutoGen

Unsafe file name

添加-safe 0 参数

视频文件和ffmpeg.exe不在同一目录下

使用绝对路径,加单引号

file 'D:\Document\FilesTest\20210423\20210423_095727.mp4'
file 'D:\Document\FilesTest\20210423\20210423_095743.mp4'

命令

ffmpeg -f concat -safe 0 -i merge.txt -c copy output.mp4

参考资料

报错

Could not find tag for codec pcm_alaw in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --

命令-c:a aac

ffmpeg -f concat -safe 0 -i xxx.txt -c:a aac xxx.mp4
Clone this wiki locally