-i 輸入媒體文件
-r 指定幀率
-re 重復(fù)輸入
-t 指定生成時(shí)長
-filter_complex 濾波器(后面跟各種濾鏡)
-c:v 指定視頻編碼格式
-s 200*300 生成視頻的尺寸
-ss 開始編輯的位置(單位:S)
-y 若文件存在則覆蓋
1、兩個(gè)視頻水平同框
D:\下載\ffmpeg\bin\ffmpeg.exe -re -i D:\下載\video\test.mp4 -re -i D:\下載\video\test1.mp4 -filter_complex "nullsrc=size=540*960[base];[0:v]setpts=PTS-STARTPTS, scale=270*960[left];[1:v]setpts=PTS-STARTPTS, scale=960*960[right];[base][left]overlay=shortest=1[tmp1];[tmp1][right] overlay=shortest=1:x=270:y=0" -c:v libx264 -strict -2 D:\下載\video\output14.mp4 -y
2、單張圖片生成指定時(shí)長視頻
D:\下載\ffmpeg\bin\ffmpeg.exe -r 24 -f image2 -loop 1 -i D:\下載\微信圖片.jpg -s 540*960 -pix_fmt yuvj420p -t 2 -vcodec libx264 D:\下載\video\輸出.mp4
3逛犹、添加指定顏色畫布(無聲音)
D:\下載\ffmpeg\bin\ffmpeg.exe -ss 0 -t 30 -f lavfi -i color=c=0x666666:s=960x960:r=30? -i D:\下載\video\test.mp4 -filter_complex "[1:v]scale=540:960[v1];[0:v][v1]overlay=210:0[outv]" -map [outv] -c:v libx264 D:\下載\video\output15.mp4 -y
4根穷、添加指定顏色畫布(有聲音)
D:\下載\ffmpeg\bin\ffmpeg.exe -ss 0 -t 30 -f lavfi -i color=c=0x666666:s=960x960:r=30? -i D:\下載\video\test.mp4 -filter_complex "[1:v]scale=540:960[v1];[0:v][v1]overlay=210:0" -c:v libx264 D:\下載\video\output15.mp4 -y
5、【九宮格】4個(gè)視頻同框艰管,其他格式可自由組合。
D:\下載\ffmpeg\bin\ffmpeg.exe -re -i D:\下載\video\test4.mp4 -re -i D:\下載\video\test1.mp4 -re -i D:\下載\video\test.mp4 -re -i D:\下載\video\test2.mp4 -filter_complex "[0][2][3]amix=inputs=3:duration=first:dropout_transition=0;nullsrc=size=540*960[base];[0:v]setpts=PTS-STARTPTS,scale=270*480[topleft];[1:v]setpts=PTS-STARTPTS, scale=270*480[topright];[2:v]setpts=PTS-STARTPTS,scale=270*480[downleft];[3:v]setpts=PTS-STARTPTS,scale=270*480[downright];[base][topleft]overlay=shortest=1[tmp1];[tmp1][topright]overlay=shortest=1:x=270:y=0[tmp2];[tmp2][downleft]overlay=shortest=1:x=0:y=480[tmp3];[tmp3][downright]overlay=shortest=1:x=270:y=480" -c:v libx264 D:\下載\video\output16.mp4 -y?
[0][2][3]amix=inputs=3:duration=first:dropout_transition=0;表示把第1個(gè),第3個(gè)娘赴,第4個(gè)視頻的聲音以第一個(gè)(first)為主進(jìn)行混合悲立,nullsrc=size=540*960[base]表示生成一個(gè)540*960的空白背景并起名叫base呜达,[0:v]setpts=PTS-STARTPTS,scale=270*480[topleft];表示將第一個(gè)輸入的視頻的分辨率改為270*480并起名叫topleft,[tmp1[topright]overlay=shortest=1:x=270:y=0[tmp2];表示把topright以tmp1為背景進(jìn)行圖層合并诗舰,x,y表示topright左上角在tmp1上的位置
6隅肥、抽取音頻命令
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\video\test4.mp4 -vn -y -acodec copy D:\下載\video\audio4.aac
7竿奏、提取視頻?
ffmpeg -i Life.of.Pi.has.subtitles.mkv -vcodec copy –an? videoNoAudioSubtitle.mp4
8、音視頻合成命令
ffmpeg -i video2.avi -i audio.mp3 -vcodec copy -acodec copy output.avi
9腥放、查看音視頻文件信息命令
ffmpeg -i 3.mp4
ffmpeg -i 3.aac
ffmpeg -i 3.m4a
10泛啸、把文本畫到視頻上(字幕)
D:\下載\ffmpeg\bin\ffmpeg.exe -hide_banner -i D:\下載\video\test.mp4 -vf drawtext=fontfile=字體文件.ttc:text='helooooooo':x1=100:y1=100:x2=200:y2=200:fontcolor=green:fontsize=50:enable='between(t,2,5):box=1:boxcolor=white' D:\下載\video\output17.mp4 -y
11、把a(bǔ)ss格式的字幕文件硬壓進(jìn)視頻中
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\video\test.mp4 -filter_complex "subtitles='D\:/Program Files (x86)/PopSub/時(shí)間軸(2).ass'" -c:v libx264 -crf 20 -c:a aac -strict experimental -b:a 192k D:\下載\video\output17.mp4 -y
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\video\test.mp4 -vf "subtitles='D\:/Program Files (x86)/PopSub/時(shí)間軸(2).ass'" -c:v libx264 -crf 20 -c:a aac -strict experimental -b:a 192k D:\下載\video\output17.mp4 -y
12秃症、視頻變速 setpts=0.5*PTS控制播放速度候址,標(biāo)準(zhǔn)為1.0吕粹,注意格式為0.0,數(shù)值越小播放越快岗仑,數(shù)值越大播放越慢匹耕,注意改變速度的同時(shí)改變生成視頻的時(shí)長-t,慢速可以不傳-t,快速必須要傳-t
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\video\test.mp4 -filter:v setpts=2*PTS D:\下載\video\output17.mp4 -y
13荠雕、添加水印圖
Documents/ffmpeg/ffmpeg -i Documents/test.mp4 -i Documents/logo.jpg -i Downloads/logo1.jpg -filter_complex "[0:v][1:v]overlay=100:100:transpose=1:enable=between(t\,2\,4)[m1];[m1][2:v]overlay=200:200:enable=between(t\,4\,6)" Documents/output.mp4 -y
14稳其、視頻倒放,無音頻
ffmpeg.exe -i inputfile.mp4 -filter_complex [0:v]reverse[v] -map [v] -preset superfast reversed.mp4
15炸卑、視頻倒放既鞠,音頻不變
ffmpeg.exe -i inputfile.mp4 -vf reverse reversed.mp4
16、音頻倒放盖文,視頻不變
ffmpeg.exe -i inputfile.mp4 -map 0 -c:v copy -af "areverse" reversed_audio.mp4
17嘱蛋、音視頻同時(shí)倒放
ffmpeg.exe -i inputfile.mp4 -vf reverse -af areverse -preset superfast reversed.mp4
18、視頻添加音樂椅寺,保留原聲浑槽,注意指定生成視頻時(shí)長-t
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\Last_Stop.mp3 -i D:\下載\video\test.mp4 -filter_complex [1:a]aloop=-1:size=2e+09:enable='between(t,2,5)'[out];[out][0:a]amix -t 00:00:06 -y D:\下載\video\output17.mp4
添加背景音樂的同時(shí)調(diào)整音量
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\video\test.mp4 -i D:\下載\Last_Stop.mp3 -filter_complex "[0:a]volume=1.0[1],[1:a]volume=0.5[2],[2]adelay=2000|2000[del1],[1][del1]amix" D:\下載\video\output17.mp4
19、調(diào)整音頻音量. 0.1表示調(diào)整為當(dāng)前音量的0.1倍
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\Last_Stop.mp3 -filter:a volume=0.1 D:\下載\Last_Stop1.mp3 -y
20返帕、音視頻裁剪
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\Last_Stop.mp3 -vn -acodec copy -ss 00:00:00 -t 00:00:03 D:\下載\Last_Stop2.mp3 -y
21桐玻、水印旋轉(zhuǎn)(只能旋轉(zhuǎn)90的倍數(shù),由transpose控制)
D:\下載\ffmpeg\bin\ffmpeg.exe -i D:\下載\video\test.mp4 -i D:\下載\logo.jpg -filter_complex "[1]transpose=4[a],[0:v][a]overlay=100:200" D:\下載\video\output17.mp4 -y
22荆萤、單張圖片生成指定時(shí)長的視頻
ffmpeg -r 5 -loop 1 -i input.jpg -t 3 output.mp4