![Ffmpeg の改行を右揃えにする](https://rvso.com/image/1598543/Ffmpeg%20%E3%81%AE%E6%94%B9%E8%A1%8C%E3%82%92%E5%8F%B3%E6%8F%83%E3%81%88%E3%81%AB%E3%81%99%E3%82%8B.png)
私はこの ffmpeg コマンドを使用して画像からビデオをレンダリングします - 問題は、carriage /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テキストを1つのフィルターに入れています
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'
2 行を 2 つの drawtext フィルターに分割し、2 つの文字列を右側に「揃えます」。
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'
2 行目のテキストでは、y オフセットの値を変更しました。「-line_h」という用語を追加したので、2 行目は 1 行目より下になります。