VIRTUALS

the virtual labs for the virtuals

0%

玩转ffmpeg

摘要:
FFmpeg的使用技巧。

合并分段视频

方法1:txt文件保存视频文件名

ffmpeg -f concat -safe 0 -i files.txt -c copy "merge.MP4"

其中files.txt中写入分段视频文件名

file name0x0.ts
file name0x1.ts
file name0x2.ts
file name0x3.ts
file name0x4.ts
file name0x5.ts

方法2:直接写入各个视频文件名

ffmpeg -i "concat:name0x0|name0x1|name0x2|name0x3" -c copy "merge.mp4"

视频转换格式

ffmpeg -i "video.ts" -vcodec copy -acodec copy "video.mp4"

截取一段视频

从第12秒截取到294秒:
ffmpeg -i 0x0.mkv -ss 12 -c copy -to 294 0x1.mp4

提取视频中的音频

ffmpeg -i xxx.mp4 -f mp3 -ar 16000 xxx.mp3
其中:
xxx.mp4 视频文件
-f mp3 mp3编码
-ar 16000 音频采样率
xxx.mp3输出的音频文件

未完待续