在ffmpeg drawtext过滤器中提供时间段 [英] provide time period in ffmpeg drawtext filter
问题描述
我正在尝试使用ffmpeg向视频中添加文本,并希望在给定的时间内显示文本。我正在尝试使用DrawText过滤器,但不知道如何为该过滤器提供时间段。有人可以帮我吗?
I am trying to add text to video using ffmpeg and wants text to appear for a given period of time. I am trying to use DrawText filter but don't know how to provide time period for this filter. Can Anybody please help me.
谢谢
推荐答案
href = http://ffmpeg.org/ffmpeg-filters.html#drawtext-1> drawtext
视频过滤器具有时间线编辑支持(请参见 ffmpeg -filters
的输出)。这样可以评估表达式,并允许您提供应启用过滤器的时间。 。
The drawtext
video filter has timeline editing support (see the output of ffmpeg -filters
). This can evaluate an expression and allows you to provide the time(s) of when the filter should be enabled.
此示例将使过滤器从12秒变为3分钟:
This example will enable the filter from 12 seconds to 3 minutes:
ffmpeg -i input.mp4 -vf "drawtext=enable='between(t,12,3*60)':fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test Text'" -acodec copy output.mp4
音频为在此示例中复制的流。
如果您没有时间线编辑支持,则需要以获得更新的版本。您可以简单地下载 Linux构建的 ffmpeg
或执行以下步骤-逐步编译 ffmpeg
的指南。
If you do not have timeline editing support then you will need to get a newer version. You can simply download a Linux build of ffmpeg
or follow a step-by-step guide to compile ffmpeg
.
另请参见 FFmpeg和x264编码指南。
这篇关于在ffmpeg drawtext过滤器中提供时间段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!