FFmepg相关命令的使用
1.分离视频流
ffmpeg -i test.mp4 -vn -acodec copy test-vn.mp4
2.分离音频流
ffmpeg -i test.mp4 -an -vcodec copy test-an.mp4
3.提取TS流
ffmpeg -i test.mp4 -an -vcodec copy -bsf: h264_mp4toannexb -f h264 test.264
注意: -bsf后必须加空格,否则会出错
4.提取TS流封装成MP4格式
ffmpeg -i test.mp4 -an -vcodec copy -bsf: h264_mp4toannexb -f mp4 test264.mp4
5.视频格式转换
MP4转TS:
ffmpeg -i test.mp4 -c copy -f mpegts test.ts
TS转MP4:ffmpeg -i test.ts -c copy -f mp4 test-ts.mp4
264码流转TS流:
ffmpeg -i test.mp4 -an -vcodec copy -bsf: h264_mp4toannexb -f mpegts test1.ts
注意:如果直接用纯264码流转ts流的会出错,因为纯264码流中并没有pts所以无法装成ts流
6.修改视频相关参数
ffmpeg.exe -i 1.1.mp4 -vcodec libx264 -acodec aac -s 176x144 -r 25 -g 100 -b 200K -ac 1 -ar 44100 -f flv 1.1.flv
这里是将原视频的视频编码改为h264,也就是avc,将音频编码改为aac,重新定义视频的宽高为176x144,设置每秒25帧,每4s一个关键帧,码率为200k,声道数为1个,设置采样率为44.1khz,转换为flv格式