1

Let's say I have:

  • A txt file
  • A 1920x1080 image

I would like to generate a video like this where text is scrolling and audio is a given MP3.

I was digging a bit with ffmpeg but with no success.

Can you help?

2 Answers 2

2

I gave a try to my favorite reading (3 paragraphs, wrapped to 80 characters) :-)

lorem-ipsum-generator -l -p 3 -s 1 | fold -w 80 -s > TEXT

Then generate the video:

ffmpeg -loop 1 \
       -i Blue-Planet-Earth-1920x1080.jpg  
       -vf drawtext="fontsize=20:fontcolor=white:fontfile=FreeSans.ttf:textfile=TEXT:y=h-200*t"  
       -t 8 output.mp4

Explanations:

  • infinite loop as we have only one image (support multiple images in sequence, or piped)
  • the image
  • the drawtext is quite readable, animation done with usage of t
  • "-t 8" for 8 seconds duration (at the end)

The text goes beyond the upper limit and continues to scroll upward.

Anyone can now generate it.

(Thanks to FB !)

2
  • What does FB mean?
    – llogan
    Oct 27, 2016 at 19:03
  • FB is a glimpse to Fabrice (bellard.org)
    – levif
    Oct 27, 2016 at 19:27
1

You can use the subtitles filter with Advanced SubStation Alpha (ASS) subtitles. Using the /move tag will allow you to scroll the subtitles by providing beginning and ending x,y coordinates.

Advantages over the drawtext filter include more formatting options and the ability to automatically wrap the text. Disadvantage is that the x,y coordinates do not appear to be able to reference the text width and height, so you have to manually provide appropriate values in the /move tag.

enter image description here
Screenshot of scrolling subtitles

Example ASS file made with Aegisub:

[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

[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,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,1,5,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\move(190,350,180,-90)}Draw subtitles on top of input video using the libass library.\NTo enable compilation of this filter you need to configure FFmpeg wit{\i1}h --enable-liba{\i0}ss. This filter also requires a build with libavcodec and libavformat to convert the passed subtitles file to ASS (Advanced Substation Alpha) subtitles format.

Example ffmpeg command:

ffmpeg -loop 1 -i image.jpg -i audio.mp3 -filter_complex "subtitles=scroll.ass" -c:a copy -shortest output.mkv

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .