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

得知这条命令还要感谢网友(游戏爱好者  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哈哈~,第一次写文章,啥都别说了,打赏我吧!!! 哈哈

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 最近开始学习Python,于是通过练习题来强化所学基础知识。 有四个数字:1、2、3、4,能组成多少个互不相同且无...
    于阗阅读 470评论 0 0
  • Day69 好可爱,软糯软糯的。(^.^)
    小懒说Yolo阅读 264评论 4 6
  • 有一个穿越时空的印度留学生来到中国,留学一个月后回国了。 他的父亲和儿子见面后,觉得儿子在中国呆的时间太短,有点不...
    紫羽说阅读 342评论 7 11