需要在同一行中依次设置多个drawtext。但无法通过 FFMPEG 命令这样做

Need to set Multiple drawtext in same line one after the other. but unable to do so via FFMPEG command

您好,我正在尝试创建一个 FFMPEG 命令,用于在视频上覆盖部分文本为粗体的文本。我正在使用以下命令。但我无法弄清楚如何传递第一个结尾部分的 x 位置。

ffmpeg -i b.mp4 -vf "drawtext=fontfile=arial.ttf:text='Title of this video is ':fontcolor=blue:fontsize=20,drawtext=fontfile=ariali.ttf:text='How to have a healthy Life':fontcolor=yellow:fontsize=20:x=**<width of 1st text>**" -c:v libx264 -c:a copy -movflags +faststart output.mp4 -y

解决方法是使用 subtitles 过滤器。

ffmpeg -i input.mp4 -filter_complex subtitles=subs.ass -c:a copy output.mp4

示例 ASS 文件:

[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: None

[Aegisub Project Garbage]
Last Style Storage: Default

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,38,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\c&HFFFF00&}Title of this video is {\c&H00FFFF&\b1}How to Have a Healthy Life.{\b0}