带有右侧对齐的 Ffmpeg 换行符

带有右侧对齐的 Ffmpeg 换行符

我使用这个 ffmpeg 命令从图像渲染视频 - 问题是当我使用回车/ni 时无法对阿拉伯文本进行右侧对齐,我无法为此使用多个 drawtext 因为文本来自数据库。

ffmpeg -r:v 1/5 -f concat -safe 0 -i /system/gobro.txt -i "/system/chill.mp3" -vf "scale=iw*min(1280/iw\,800/ih):ih*min(1280/iw\,800/ih), pad=1280:800:(1280-iw*min(1280/iw\,800/ih))/2:(800-ih*min(1280/iw\,800/ih))/2,
drawbox=enable='between(t,5,39.9)':y=(ih-110):[email protected]:width=iw:height=110:t=filldrawtext=enable='between(t,10,14.9)':fontfile=/ttf/changa-medium.ttf:fontsize=30:fontcolor=white:x=(w-text_w-20):y=(h-text_h-60):text='غير كانت الخطّة ', 
drawtext=enable='between(t,10,14.9)':fontfile=/TTF/Changa-Medium.ttf:fontsize=20:fontcolor=white:x=(w-text_w-20):y=(h-text_h-15):text='gfuishg isfdhgi usfdhgi sfdg /n hello this is new line'" 
-c:a aac -shortest -y -pix_fmt yuv420p /public/video.mp4 2> /system/out.txt

屏幕截图解释该问题

谢谢

答案1

我认为你的文本是从右到左书写还是从左到右书写并不重要。我认为你唯一需要解决的问题是结盟或者理由文本。在您的示例照片中,似乎您希望所有文本都右对齐,无论它是用 RTL 还是 LTR 脚本编写的。如果我是对的,那么类似于以下内容的内容应该可以满足您的要求。

在示例代码中,您将 LTR 文本放入一个过滤器中

drawtext=enable='between(t,10,14.9)':fontfile=/TTF/Changa-Medium.ttf:fontsize=20:fontcolor=white:x=(w-text_w-20):y=(h-text_h-15):text='gfuishg isfdhgi usfdhgi sfdg /n hello this is new line'

将两行分成两个 drawtext 过滤器,并将两个字符串在右侧“对齐”。

drawtext=enable='between(t,10,14.9)':fontfile=/TTF/Changa-Medium.ttf:fontsize=20:fontcolor=white:x=(w-text_w-20):y=(h-text_h-15):text='gfuishg isfdhgi usfdhgi sfdg',
drawtext=enable='between(t,10,14.9)':fontfile=/TTF/Changa-Medium.ttf:fontsize=20:fontcolor=white:x=(w-text_w-20):y=(h-text_h-line_h-15):text='hello this is new line'

对于第二行文本,我更改了 y 偏移的值。我添加了术语“-line_h”,因此第二行应该位于第一行下方。

相关内容