得知這條命令還要感謝網(wǎng)友(游戲愛好者? 70000020)的提供,在此整理一下使用方法(有很多重復(fù)性的命令可以幫助大家理解命令的作用)。
O(∩_∩)O哈哈~,在此用一個好聽的歌曲(新娘不是我-小蝦米)給大家作為demo。
素材地址:鏈接:http://pan.baidu.com/s/1bFauYE 密碼:834v
1、給視頻添加圖片字幕
ffmpeg -ss 00:00:00 -t 00:00:22 -i xiami_xinniangbushiwo.mp4 -i subtitle_1.png -i subtitle_2.png -filter_complex " [0:v][1:v]overlay=x=50:y=300:enable='between(t,0,5.420000)'[out_1];[out_1][2:v]overlay=x=50:y=300:enable='between(t,6.022000,10.852000)'[out_2];[out_2][1:v]overlay=x=50:y=300:enable='between(t,11.022000,15.852000)'[out_3];[out_3][2:v]overlay=x=50:y=300:enable='between(t,16.022000,20.852000)' " -acodec copy -vcodec libx264 -b:v 500k -threads 4 -thread_type frame -preset faster -tune zerolatency -y test.mp4
黑體部分為主要功能命令,命令中(-i xiami_xinniangbushiwo.mp4)可以用(-f concat -i filelist.txt)替換,后者用于批處理多個視頻文件
?附帶一些命令的解釋,第一次寫簡書,所有啰嗦一下:
-ss 截圖視頻的起始位置(hh:mm:ss); -t 截圖視頻的長度(hh:mm:ss);-acodec copy 音頻沒有重編碼,直接copy原始aac音頻流;-vcodec libx264 因為是overlay,所以視頻不能copy(這也是好多朋友不明白原理想要去copy和overlay一起用),這里用的libx264;-b:v 500k 設(shè)置視頻編碼碼率為500kbps;-threads 4 (Number of encoding threads);-thread_type frame (Set multithreading technique. Possible values: ‘slice’ Slice-based multithreading. It generates the same effect asx264’s--sliced-threadsoption. ‘frame’ Frame-based multithreading);-preset faster -tune zerolatency 編碼預(yù)設(shè)?
2、給視頻添加圖片字幕,并添加微信二維碼片尾
ffmpeg -ss 00:00:00 -t 00:00:22 -i xiami_xinniangbushiwo.mp4 -i subtitle_1.png -i subtitle_2.png -loop 1 -t 4.5 -i tail-leader.jpg -filter_complex " [0:v][1:v]overlay=x=50:y=300:enable='between(t,0,5.420000)'[out_1];[out_1][2:v]overlay=x=50:y=300:enable='between(t,6.022000,10.852000)'[out_2];[out_2][1:v]overlay=x=50:y=300:enable='between(t,11.022000,15.852000)'[out_3];[out_3][2:v]overlay=x=50:y=300:enable='between(t,16.022000,20.852000)'[out_4];[3:v]scale=w=480:h=360[out_5];[out_4][out_5]concat " -acodec copy -vcodec libx264 -b:v 500k -threads 4 -thread_type frame -preset faster -tune zerolatency -y test.mp4
黑體部分為主要功能命令,命令中(-i xiami_xinniangbushiwo.mp4)可以用(-f concat -i filelist.txt)替換,后者用于批處理多個視頻文件
[3:v]scale=w=480:h=360[out_5] 此處對于微信二維碼圖片進行了一次scale,因為原始視頻尺寸為480x360,而圖片為480x480,如果圖片尺寸和原始視頻尺寸一樣的話,可以省略這一步,直接用?[out_4][3:v]concat 即可;
-loop 1 -t 4.5 -i tail-leader.jpg 代表微信二維碼圖片持續(xù)4.5s
O(∩_∩)O哈哈~,第一次寫文章,啥都別說了,打賞我吧?。?! 哈哈