ffmpeg视频合并、添加背景音乐命令整理

1、视频合并
第一步将mp4文件转成ts
ffmpeg -i /storage/emulated/0/Movies/output1.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb /storage/emulated/0/Movies/output1.ts
第二步合并
ffmpeg -y -f concat -safe 0 -i /storage/emulated/0/Movies/list.txt -c copy /storage/emulated/0/Movies/Cam01.mp4
list.text内容如下:
file '/storage/emulated/0/Movies/output1.mp4'
file '/storage/emulated/0/Movies/output2.mp4'

2、视频编辑 比如从第5秒的地方开始,往后截取10秒钟
ffmpeg -ss 5 -t 10 -i /storage/emulated/0/Movies/output1.mp4 /storage/emulated/0/Movies/output2.mp4

3、视频加背景音乐
ffmpeg -y -i /storage/emulated/0/Movies/Cam01.mp4 -i /storage/emulated/0/Movies/jj01.mp3 -filter_complex [0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.5[a0];[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.5[a1];[a0][a1]amix=inputs=2:duration=first[aout] -map [aout] -ac 2 -c:v copy -map 0:v:0 -preset superfast /storage/emulated/0/Movies/result.mp4

4、视频加速
ffmpeg -i /storage/emulated/0/Movies/result.mp4 -vf setpts=PTS/2 -af atempo=2 /storage/emulated/0/Movies/result01.mp4

5、音频剪辑
ffmpeg -y -i 124.mp3 -vn -acodec copy -ss 00:00:00 -t 00:01:32 output.mp3

我的gradle依赖包:

implementation 'com.github.microshow:RxFFmpeg:2.2.0'
发布了5 篇原创文章 · 获赞 0 · 访问量 652

猜你喜欢

转载自blog.csdn.net/yeZhuShanCun/article/details/104020484