FFmpeg 換行並右側對齊

FFmpeg 換行並右側對齊

我使用這個 ffmpeg 命令從圖像渲染視頻 - 問題是當我使用carriage /ni 時無法對阿拉伯文本進行右側對齊,我無法為此使用多個繪製文本,因為文本來自數據庫。

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=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”,因此第二行應該位於第一行下方。

相關內容