1

Currently, I am using this to reading a text file and scrolling it to the bottom from right to left:

ffmpeg -i rtmp://127.0.0.1/source/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 128K -s 640x360 -vf "drawtext=enable='gte(t,3)':fontfile=/usr/share/fonts/dejavu/DejaVuSans.ttf:fontsize=40:fontcolor=white:textfile=/opt/stream/sample_text.txt:reload=1:y=h-line_h:x=-50*t" -f flv -c:a aac -ac 1 -strict -2 -b:a 32k rtmp://127.0.0.1/out/$name;

But it only runs once. How can I make it repeat infinitely? The text on the text file will be dynamic, sometimes it will be small and sometimes it will be big. Also, the current command only reads and scroll the first line of the file, is there any way to read and scroll full text file line by line?

  • See superuser.com/a/1026814/114058 for looping. Place all lines on a single line in the file. – Gyan Mar 21 '19 at 15:52
  • Thanks a lot, It works. But when I add more characters (text /word/sentence) to the file, scrolling is speeding up and is not readable. Any way to keep the speed fixed, no matter how long the line is? – Angel Mar 21 '19 at 16:52
1

Use x=w-w/3*mod(t,3*(w+tw)/w) where 3 is the time in seconds for one character to span the width of the video frame.

| improve this answer | |
  • This doesn't work. [h264 @ 0x3153280] co located POCs unavailable [h264 @ 0x3163000] mmco: unref short failure [h264 @ 0x31bcbc0] co located POCs unavailable [AVFilterGraph @ 0x3217400] No such filter: '3*(w+tw)/w)' Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:2 [aac @ 0x3148040] Qavg: 61229.324 [aac @ 0x3148040] 2 frames left in the queue on closing Conversion failed! – Angel Mar 22 '19 at 5:56
  • Probably not a valid method, but somehow, this works. x=w-mod(w*t/10\,1200*(w+tw)/w). 1200/2 = Total characters of the line. So If we add more characters, we will need to calculate and change that value accordingly. – Angel Mar 22 '19 at 6:08
  • Those errors have nothing to do with the filter. Your input has corrupted frames in the video. But there is an error in my expr which I corrected. – Gyan Mar 22 '19 at 6:43
  • Share full command and log. – Gyan Mar 22 '19 at 8:10
  • I understand now. Corrected code is working perfectly. Thanks a lot. – Angel Mar 22 '19 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.