ffmpeg移动文本绘图 [英] ffmpeg moving text drawtext
问题描述
我正在使用ffmpeg库在特定的时间内在视频上绘制文字,我成功地做了现在我需要将文本从位置移动到另一个位置,我无法做到这一点,任何人都可以建议我要做到这一点
I'm using ffmpeg library to draw text on video in specific time and i'm success to do that Now i need to move the text from position to another and i can't do that so can any one suggest me how to do that
我正在使用此命令将文本从上到下移动,但我无法确定x和Y从x,y移动到具体x,y
i'm using this command to move text from top to down but i can't determine the x and Y to move from the x,y to specific x,y
ffmpeg -i VideoInput.mp4 -vf "drawtext=enable='between(t,12,14)':fontfile=myfont.otf:text='Test test':x=(w-text_w)/2:y=w/50\*mod(t\,2):fontsize=65" -acodec copy outputVideo.mp4
推荐答案
使用
ffmpeg -i VideoInput.mp4 \
-vf "drawtext=enable='between(t,12,14)':fontfile=myfont.otf:text='Test test': \
x='x1+(x2-x1)*(t-t1)/(t2-t1)':y='y1+(y2-y1)*(t-t1)/(t2-t1)':fontsize=65" \
-acodec copy outputVideo.mp4
其中
x1
和 y1
坐标;
x2
和 y2
是最终坐标;
t1
和 t2
是开始和结束时间;在您给定的命令中, 12
和 14
。
x1
and y1
are initial co-ordinates;
x2
and y2
are final co-ordinates;
t1
and t2
are start and end times; in your given command, 12
and 14
.
这些以上需要用命令中的值替换。
These above need to be replaced with their values in the command.
最后留下1秒钟, / p>
To give a 1 second stay at the end,
ffmpeg -i VideoInput.mp4 \
-vf "drawtext=enable='between(t,12,15)':fontfile=myfont.otf:text='Test test': \
x='if(lt(t-t2+1\,0)\,x1+(x2-x1)*(t-t1)/(t2-t1-1)\,x)': \
y='if(lt(t-t2+1\,0)\,y1+(y2-y1)*(t-t1)/(t2-t1-1)\,y)':fontsize=65" \
-acodec copy outputVideo.mp4
这里 t2
包括停留,所以从12移动到14 + 1秒。启用中的 t2
也会更改。
Here t2
includes the stay, so movement from 12 to 14 + 1 second hold. The t2
in enable is changed as well.
这篇关于ffmpeg移动文本绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!