ffmpeg scroll text without gap

0

I'm using this command to scroll text on video

"drawbox=y=ih-108:color=blue@0.4:\
width=iw:height=48:t=fill, \
drawtext=textfile=file.txt: \ 
fontfile=OpenSans-Regular.ttf: \
y=h-line_h-65:\
x=w-mod(max(t-1.5\,0)*(w+tw)/18.5\, (w+tw)): \
fontcolor=white:fontsize=36" \

This scroll runs in loop with gap. When all the text is scrolled on video [there's a gap] then it restarts the scroll.

I want scroll to run continuously without any gap like in this video - https://www.youtube.com/watch?v=Z0ZpLAgpghk

Is there any other filter to accomplish this or how do i modify the x= expression to get desired output?

Ramjivan Jangid

Posted 2019-12-23T05:56:09.480

Reputation: 13

Answers

0

You can achieve this by chaining two drawtext filters

"drawbox=y=ih-108:color=blue@0.4:\
width=iw:height=48:t=fill, \
drawtext=textfile=file.txt: \ 
fontfile=OpenSans-Regular.ttf: \
y=h-line_h-65:\
x=w-mod(max(t-START_TIME_OFFSET\,0)*(SPEED)\, 2*(tw+MARGIN)): \
fontcolor=white:fontsize=36, \
drawtext=textfile=file.txt: \ 
fontfile=OpenSans-Regular.ttf: \
y=h-line_h-65:\
x=w-mod(max(t-(tw+MARGIN)/(SPEED)-START_TIME_OFFSET\,0)*(SPEED)\, 2*(tw+MARGIN)): \
fontcolor=white:fontsize=36"

START_TIME_OFFSET is the initial time when the text appears e.g. 1.5 seconds.
SPEED is the scrolling distance for one character per second e.g. 100 pixels or 1/10th the width, w/10.
MARGIN is the distance between the end of one scroll and the start of the next e.g. 100 pixels or proportional distance w/5.

For this method, text has to be equal to or wider than frame width.

Gyan

Posted 2019-12-23T05:56:09.480

Reputation: 21 016

I'm getting error msg - [h264 @ 0x55bd20ad7200] co located POCs unavailable [h264 @ 0x55bd20af8500] co located POCs unavailable [Parsed_drawtext_3 @ 0x55bd20af3480] Failed to configure input pad on Parsed_drawtext_3peed=N/A
Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 [aac @ 0x55bd20a83140] Qavg: 152.432 [aac @ 0x55bd20a83140] 2 frames left in the queue on closing Conversion failed!
– Ramjivan Jangid – 2019-12-23T12:37:29.033

That's an input file decoding error - unrelated to filtering. – Gyan – 2019-12-23T13:09:16.950

input file is ok. It's working with previous command i posted – Ramjivan Jangid – 2019-12-23T14:06:17.343

Add -report and rerun. Share report. – Gyan – 2019-12-23T14:10:51.183

Link to report file - https://drive.google.com/file/d/1PE0YICMiwZYCorYkuD8SyVsQ7BMRHlin/view?usp=sharing

– Ramjivan Jangid – 2019-12-23T14:30:15.617

Added missing 2nd arg in max function in first drawtext – Gyan – 2019-12-23T15:47:11.077

Let us continue this discussion in chat.

– Ramjivan Jangid – 2019-12-23T17:13:55.827