How can I insert the text for the 1st 30 seconds inside a filter_complex expression for each video in FFmpeg?

I am creating a video grid using the filter_complex command in FFmpeg and now wish to, write a text to this video grid that will appear with a fade-in at 10 seconds, stay for 30 seconds and then fade out.

1 Like

Did you try drawtext filter? Actually, I am also facing the same problem.

No, I haven’t tried it yet.

Hey!  
FFmpeg provides the drawtext filter to do this task and you both can use it to add a text overlay to the beginning of each video in a filter complex expression. The drawtext filter allows you to specify the text to be displayed, the font, size, and color of the text, and the position on the video where the text should be displayed.

Here’s an example of how you can use the drawtext filter to add a text overlay to the beginning of each video in a filter complex expression:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v]drawtext=text='Text for video 1':fontsize=24:fontcolor=white:x=10:y=10:enable='between(t,0,30)'[v1]; [1:v]drawtext=text='Text for video 2':fontsize=24:fontcolor=white:x=10:y=10:enable='between(t,0,30)'[v2]; [v1][0:a][v2][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4

In this example, the drawtext filter is applied to the video streams of both input1.mp4 and input2.mp4, with the enable option set to between(t,0,30) to only display the text for the first 30 seconds of each video.

The fontsize, fontcolor, x, and y options are used to specify the appearance of the text. The concat filter is then used to merge the video and audio streams of the two input files into a single output file.

I hope this helps! Let me know if you have any questions.