在 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.
谢谢
推荐答案
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
在此示例中,音频是流复制.
如果您没有时间线编辑支持,那么您将需要获得更新的版本.您可以简单地下载 ffmpeg
的 Linux 版本或按照分步 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屋!