視頻音頻合并
視頻音頻合并,以視頻時間為主,音頻短了循環(huán)
方法1:混音,視頻權(quán)重0,volume調(diào)節(jié)音量,aloop無限循環(huán),duration:first為第一個素材的長度
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[1:a]volume=0.5[a1];[a1]aloop=loop=-1:size=2e+09[a2];[0:a][a2]amix=inputs=2:duration=first:weights='0 1'[a]" -map 0:v -map "[a]" out.mp4
有的音頻:first不起作用,需要-t截止時間
方法2:替換音頻
ffmpeg -an -i video.mp4 -stream_loop -1 -i audio.mp3 -af volume=0.5 -shortest -fflags +shortest -y out.mp4
有的音頻shortest不管用,需要-t截止時間
合并視頻的時候加字幕
ffmpeg -i /video/0.ts -i /video/4.ts -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[v][outa];[outv]drawtext=text='字幕Text':fontcolor=#ffffff:fontsize=192:fontfile=/conf/msyhbd.ttc:x=(w-text_w)/2:y=(h-text_h)/1.5:enable='between(t\,0\,1)'[dv]" -map [dv] -map [outa] -vsync 2 -y out.mp4
視頻合并,有的視頻沒有音頻,找到?jīng)]有音頻的視頻,用虛擬音頻,concat=n=的數(shù)量不包括虛擬音頻
./ffmpeg -i /video/0.mp4 -i /video/1.mp4 -i /video/無音頻視頻.mp4 -f lavfi -t 0.1 -i anullsrc -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][3:a]concat=n=3:v=1:a=1[outv][outa]" -map [outv] -map [outa] -vsync 2 -y out.mp4
切割視頻
按關(guān)鍵幀切割視頻
ffmpeg.exe -i video.m4v -c copy -f segment -reset_timestamps 1 video\output-%d.mp4
ffmpeg -i video.m4v -an -vf select='eq(pict_type\,I)' -vsync 2 ?-f image2 video\img-%d.jpg
按幀切割視頻
./ffmpeg -i ./video/video.m4v -vf "select=between(n\,0\,52),setpts=N/FRAME_RATE/TB" -af "aselect='between(n\,0\,52)',asetpts=N/SR/TB" -y ./video/output.mp4
./ffmpeg -i ./video/video.m4v -vf "trim=start_frame=0:end_frame=52+1,setpts=PTS-STARTPTS" -an -y ./video/output1.mp4
ffmpeg -i video.m4v -an -vf "select=eq(n\,26)" -vframes 1 -f image2 -y video\image.jpg
音頻漸入漸出
音頻音量+漸入漸出,st起始時間,d持續(xù)時間
ffmpeg -an -i video.m4v -stream_loop -1 -i 3m.mp3 -filter_complex [1:a]volume=0.5[a1];[a1]afade=t=in:st=0:d=3,afade=t=out:st=29:d=3 -t 32 -vcodec copy -y out.mp4文章來源:http://www.zghlxwxcb.cn/news/detail-635631.html
詳細(xì)講解ffmpeg命令的使用(視頻合并&avi轉(zhuǎn)MP4&補(bǔ)空白音頻文章來源地址http://www.zghlxwxcb.cn/news/detail-635631.html
到了這里,關(guān)于ffmpeg視頻音頻命令的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!