ffmpeg 移动文字 drawtext [英] 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 秒钟,
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 秒保持移动.enable 中的 t2
也发生了变化.
Here t2
includes the stay, so movement from 12 to 14 + 1 second hold. The t2
in enable is changed as well.
这篇关于ffmpeg 移动文字 drawtext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!