x=if(eq(t\,0)\,w\,if(lt(x\,(0-tw))\,w\,x-4))
It's all about setting the value of x. I like the answer of Mulvya which is good if you want the text to scroll across the video frame in a fixed number of seconds. I however wanted a constant speed regardless of the width of the video.
I started with if(lt(x,(0-tw)),w,x-1)
The idea was to start at the video width w and go on decreasing the value of x till it becomes less than 0-text_w. At this point the text disappears.
But it did not work. Default value for x is 0, I needed it to set it to w at the start. So I came up with this -
if(eq(t,0),w,if(lt(x,(0-tw)),w,x-1))
x-1 was too slow for my taste for I changed it to x-4.
Escape the , before using it in your command x=if(eq(t\,0)\,w\,if(lt(x\,(0-tw))\,w\,x-4))
The opposite of that, starting from LEFT and going to RIGHT would be
if(eq(t,0),(0-tw),if(gt(x,(w+tw)),(0-tw),x+4))
Thanks @Mulvya , but unfortunately it does not work on my ffmpeg. Currently, this is what I use as a parameter:
text='Test Text':y=h-line_h-10:x=(mod(5*n,w+tw)-tw)
This works fine, but in the wrong direction (left to right). I would need it right to left. – Ron Van Herk – 2016-01-15T17:31:08.427
What command did you use with my answer? – Gyan – 2016-01-15T17:44:37.557
I use it to give as parameter to ffmpeg, but ffmpeg is called from inside a streaming platform. Here is the full parameter:
-vf "scale=640x360, setsar=1:1, setdar=16:9, drawtext='fontsize=100:fontcolor=white:fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:text='Test Text':y=h-line_h-10:x=w-(t-4.5)*w/5.5’ " -vcodec libx264 -preset superfast -vprofile baseline -level 30 -x264opts keyint=90 -b:v 800K -r 25 -acodec libvo_aacenc -ab 64K -ar 44100 -ac 2 – Ron Van Herk – 2016-01-15T22:05:42.287
Actually, the code that works - but from left to right, is: -vf "scale=640x360, setsar=1:1, setdar=16:9, drawtext='fontsize=100:fontcolor=white:fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:text='Test Text':y=h-line_h-10:x=(mod(5*n,w+tw)-tw)' " -vcodec libx264 -preset superfast -vprofile baseline -level 30 -x264opts keyint=90 -b:v 800K -r 25 -acodec libvo_aacenc -ab 64K -ar 44100 -ac 2 – Ron Van Herk – 2016-01-15T22:07:49.400
Try
-vf "scale=640x360,setsar=1,drawtext="fontsize=100:fontcolor=white:fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:text='Test Text':y=h-line_h-10:x=(w-(t-4.5)*w/5.5)"
– Gyan – 2016-01-16T06:15:22.240Ok, this scrolls the right way, but only once and I would need it to repeat. The code that goes from left to right does repeat perfectly... – Ron Van Herk – 2016-01-16T08:56:35.360
You didn't mention the loop part. I'll update in some time. – Gyan – 2016-01-16T09:04:01.167
Updated with loop – Gyan – 2016-01-16T10:05:42.123