In Ffmpeg you can create moving text:
ffmpeg -y -t 10 -s qcif -f rawvideo -pix_fmt rgb24 -s 1280x720 -i /dev/zero -g 1 -r 24 -vf drawtext="fontfile=~/fonts/Trebuchet_MS.ttf:text='thing crawls':fontsize=155:fontcolor=red:y=h-20*t" wow.mpg
So this will give me a black frame with “thing crawls” slowly going from bottom up..
If I know the length of the video (20 seconds) and want to, for example create “thing falls” that starts at the top of the screen at time 0 and goes to the bottom of the screen until 00:00:20, how do I do that?
Also can I create the situation where the text will start going from top to bottom, but stop at the middle of the screen?
The FFmpeg docs give a full listing of the variables that you have to work with when using the drawtext filter, but for mobile text there are a few of particular interest:
With these, you can set the text position in relation to how many frames have already been seen. That’s what the
y=h-20*texpression in your example is doing. Astincreases, the text moves closer to the top of the video ash-20*tdecreases.To make your example “thing falls”, you’d want a term like
20*tinstead. Because theyposition starts from 0 at the top of the video, astincreases, it will move down the screen.For text that stops in the middle of the screen, you could probably do some fancy math, or just use FFmpeg’s rich set of logical functions. Something like
y=t*20*lte(t*20,h/2) + h/2*gt(t*20,h/2)which moves the text whilet*20is less than half the height, then keeps theyposition ath/2oncet*20is greater than half the height.