如何使用ffmpeg和imagemagick为视频添加顶部和底部框架 [英] How to add top and bottom frame to a video using ffmpeg and imagemagick

查看:194
本文介绍了如何使用ffmpeg和imagemagick为视频添加顶部和底部框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为视频添加顶部和底部部分,就像我们为图像模因一样。我正在使用ffmpeg和imagemagick,但没有内置选项来执行此任务。假设我有一个视频,我需要将这样的标题添加到整个视频中。我怎样才能实现这一目标?



drawtext 。在此示例中, pad 向顶部添加50个像素,向底部添加50个像素,然后每行添加两个 drawtext 实例。

  ffmpeg -i input -filter_complex \ 
[0:v] pad = iw:ih + 100:0 :( oh-ih)/ 2:颜色= white,\
drawtext = text ='ONE DOES NOT SIMPLY':fontfile = / path / to / impact.ttf:fontsize = 24:x =(w-tw)/ 2:y =(50- th)/ 2,\
drawtext = text ='STOP ME FROM FILTERING':fontfile = / path / to / impact.ttf:fontsize = 24:x =(w-tw)/ 2:y = h -25-(th / 2)\
输出


I'm trying to add a top and bottom section to a video like we do for image memes. I'm using ffmpeg and imagemagick but there is no inbuilt option to do this task. Let's say i have a video and I need to add the caption like this to the whole video. How can i achieve this?

解决方案

From what I can tell something like this is what you're looking for:

Using pad and drawtext. In this example pad adds 50 pixels to the top and 50 pixels to the bottom, then two drawtext instances place each line.

ffmpeg -i input -filter_complex \
"[0:v]pad=iw:ih+100:0:(oh-ih)/2:color=white, \
 drawtext=text='ONE DOES NOT SIMPLY':fontfile=/path/to/impact.ttf:fontsize=24:x=(w-tw)/2:y=(50-th)/2, \
 drawtext=text='STOP ME FROM FILTERING':fontfile=/path/to/impact.ttf:fontsize=24:x=(w-tw)/2:y=h-25-(th/2)" \
output

这篇关于如何使用ffmpeg和imagemagick为视频添加顶部和底部框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆