2

I am using the current ffmpeg command to convert multiple videos and create a watermark that is a scrolling text that goes from right to left to right every 120 seconds of play time.

find /home/video/ -type f -execdir ffmpeg -i '{}' -filter:v "drawtext=fontfile=/root/FreeSans.ttf:text='QWERTY':fontcolor=white@1.0:fontsize=26:y=h-line_h-30:x=w/20*mod(t\,120),scale=854:480" -pix_fmt yuv420p -c:v libx264 -preset slow -b:v 1000k -minrate 500k -maxrate 2000k -bufsize 2000k -c:a aac -ar 44100 -b:a 128k -movflags +faststart '/home/video/new/{}.mp4' \;

I would like to modify the watermark so it looks something like this

enter image description here

I would like the text shown above to fade in every 120 seconds and last for 15 seconds. Be bold format and the same colour (black).

"qwerty qwerty qwerty qwerty" new line
"qwerty qwerty qwerty qwerty"

Another issue I currently have with the current command I am using is with different video frames. For example if the video is only 800x600 the text will be very large. If the video is 1920x1080 the text will be extremely small. I would like the text size to be adjusted depending on the frame rate. It should look like above in terms of screen size.

  • So you no longer want the scrolling, but to fade in/out instead? – llogan Apr 15 at 18:42
  • Yep and it should look like the screenshot above. Fade in every 120 seconds and last 15 seconds. – Toodarday Apr 15 at 23:12
  • How can I do this without taking video resolution into account? I can work off that maybe. – Toodarday Apr 18 at 12:05
2
+100

One method is to use ASS subtitles with the subtitles filter:

 ffmpeg -i input -filter_complex "subtitles=fade.ass" -c:a copy output

Advantages:

  • Fading and timing is controlled by the ASS file.
  • The text will be automatically resized to fit the video size.
  • Subtitles are more customizable than drawtext.
  • Text can auto wrap if needed unlike drawtext.
  • ffmpeg command is simple.

Disadvantage:

  • Each instance is a separate line in the ASS file. Not a big deal for short videos. There might be a way to address this with an ASS or karaoke feature, but I don't know off-hand.

Sample ASS file (created in Aegisub 3.2.2):

[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: None

[Aegisub Project Garbage]
Last Style Storage: Default
Video Position: 749

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,20,&H00000000,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,0,2,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:15.00,Default,,0,0,0,,{\fad(500,500)}qwerty qwerty qwerty qwerty\Nqwerty qwerty qwerty qwerty
Dialogue: 0,0:02:00.00,0:02:15.00,Default,,0,0,0,,{\fad(500,500)}qwerty qwerty qwerty qwerty\Nqwerty qwerty qwerty qwerty
Dialogue: 0,0:04:00.00,0:04:15.00,Default,,0,0,0,,{\fad(500,500)}qwerty qwerty qwerty qwerty\Nqwerty qwerty qwerty qwerty
Dialogue: 0,0:06:00.00,0:06:15.00,Default,,0,0,0,,{\fad(500,500)}qwerty qwerty qwerty qwerty\Nqwerty qwerty qwerty qwerty
  • @Toodarday If you want a drawtext solution then see fontcolor_expr (see example) or alpha options and apply an appropriate expression. I may add another answer doing that some other time. – llogan Apr 18 at 18:42

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.