I am trying to write text on a video in such a way that the text "writes itself" - letter by letter.
To do this I was able to do something like this:
-vf "[in]drawtext=text='a':fontfile='/Windows/Fonts/arial.ttf'\
:enable='between(t\,1\,1.5)':x=300:y=(h)-100-th, \
drawtext=text='ab':fontfile='/Windows/Fonts/arial.ttf':enable='between(t\,1.5\,2)':\
x=300:y=(h)-100-th"
This replaces the text on screen with a new one every half a second adding a new character. ( a
changes to ab
). Obviously if the texts are long than this line would be really long.
I was able to do something similar and shorter with :
-vf "[in]drawtext=fontsize=80:shadowcolor=Black:shadowx=2:shadowy=2:fontcolor=White:\
fontfile='/Windows/Fonts/arial.ttf':text='%{expr\:if(gt(t\,1.5)\,12\,1)}':\
x=300:y=(h)-100-th"
Where the text itself is an expression dependent on time. However this only works for numbers: 1
changes to 12
(ignoring the numbers after the decimal point for now).
Now the issue is that if I try to do the same expression for texts (a->ab
) this fails. and I get:
Expression 'if(gt(t,1.5),ab,a)' for the expr text expansion function is not valid.
The question is: Is it possible to have the expression return the actual text after expansion and not just numbers?.
Thanks in advance for anyone helping!
'if(gt(t,1.5),'ab','a')'
[email protected]:WxH