FFmpeg drawtext多行 [英] FFmpeg drawtext over multiple lines
问题描述
我有代码:
import subprocess , os
ffmpeg = "C:\\ffmpeg_10_6_11.exe"
inVid = "C:\\test_in.avi"
outVid = "C:\\test_out.avi"
if os.path.exists( outVid ):
os.remove( outVid )
proc = subprocess.Popen(ffmpeg + " -i " + inVid + ''' -vf drawtext=fontfile=/Windows/Fonts/arial.ttf:text="onLine1 onLine2 onLine3":fontcolor=white:fontsize=20 -y ''' + outVid , shell=True, stderr=subprocess.PIPE)
proc.wait()
print proc.stderr.read()
os.startfile( outVid )
将文本写入视频文件.但是我要写出多行文本,而不是只将所有内容都写在一行上.
to write text to a video file. But I want to write out many lines of text instead of just having it all on the one line.
请帮助.谢谢
推荐答案
这个答案对您来说可能有点晚了,但是您可以使用[in]标签在一个文件中指定多个绘图文本,并使用逗号列出每个绘图文本.如果通过其各自的定位方法来定向每个绘画文字,则可以使用多行.在您的示例中,命令行看起来像这样(将第一行放在屏幕中间,然后将每行都放下25像素):
This answer is probably a bit late for you, but you can specify multiple drawtexts on one file by using the [in] tag and listing each drawtext using commas. This allows you to use multiple lines if you orient each drawtext through their respective positioning methods. In your example, the command line would look something like this (puts the first line in the middle of the screen, and puts each subsequent line 25 pixels down):
ffmpeg -i test_in.avi -vf "[in]drawtext=fontsize=20:fontcolor=White:fontfile='/Windows/Fonts/arial.ttf':text='onLine1':x=(w)/2:y=(h)/2, drawtext=fontsize=20:fontcolor=White:fontfile='/Windows/Fonts/arial.ttf':text='onLine2':x=(w)/2:y=((h)/2)+25, drawtext=fontsize=20:fontcolor=White:fontfile='/Windows/Fonts/arial.ttf':text='onLine3':x=(w)/2:y=((h)/2)+50[out]" -y test_out.avi
这篇关于FFmpeg drawtext多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!