美文网首页
添加图片字幕和片尾(overlay and concat )

添加图片字幕和片尾(overlay and concat )

作者: Bepartofyou | 来源:发表于2016-08-23 19:48 被阅读0次

得知这条命令还要感谢网友(游戏爱好者  70000020)的提供,在此整理一下使用方法(有很多重复性的命令可以帮助大家理解命令的作用)。

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 设置视频编码码率为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 编码预设 


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 代表微信二维码图片持续4.5s

O(∩_∩)O哈哈~,第一次写文章,啥都别说了,打赏我吧!!! 哈哈

相关文章

网友评论

      本文标题:添加图片字幕和片尾(overlay and concat )

      本文链接:https://www.haomeiwen.com/subject/wmdnsttx.html