-
Input:
-f lavfi -i color=c=black:s=1280x720:d=%duration%
: Generates a video of a black color with a resolution of 1280x720 and a duration specified by theduration
variable (140 seconds in this case).
-
Video Filter (
-vf
):"drawtext=fontfile=C\\:/path/to/font.ttf:
: Specifies the font file to be used for the text.textfile=C\\:/path/to/input.txt:
: Specifies the file containing the text to be overlaid on the video.fontcolor=white:
: Sets the font color to white.fontsize=%fontsize%:
: Sets the font size using thefontsize
variable (38 in this case).x=(w-text_w)/2+%xoffset%:
: Sets the horizontal position of the text. It centers the text horizontally by calculating(w-text_w)/2
and adjusts it with thexoffset
variable. Ifxoffset
is 0, the text will be exactly centered.y=h*0.8-(t/%duration%)*(h*0.6+text_h):
: Sets the vertical position of the text. Initially, the text is positioned at 80% of the frame height. Over time, it moves upwards.t
is the current time, andduration
is the total duration, so(t/%duration%)
is the fraction of the time elapsed. The text moves upwards by(t/%duration%)*(h*0.6+text_h)
over the duration of the video.box=1:
: Enables a box around the text.[email protected]:
: Sets the box color to black with 50% opacity.boxborderw=5
: Sets the width of the box border to 5.
-
Output:
-codec:a copy output.mp4
: Specifies that the output file should beoutput.mp4
and the audio codec should be copied from the input (although in this case, there is no audio input, so this part is redundant).
This script is useful for creating a video with text that moves vertically over time, starting at a centered horizontal position, with customizable duration, font size, and horizontal offset.