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?
Let's say I have:
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?
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:
The text goes beyond the upper limit and continues to scroll upward.
Anyone can now generate it.
(Thanks to FB !)
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.
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