Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add top and bottom frame to a video using ffmpeg and imagemagick

I'm trying to add a top and bottom section to a video like we do for image memes. I'm using ffmpeg and imagemagick but there is no inbuilt option to do this task. Let's say i have a video and I need to add the caption like this to the whole video. How can i achieve this?

enter image description here

like image 693
user1159517 Avatar asked Dec 25 '22 13:12

user1159517


1 Answers

From what I can tell something like this is what you're looking for:

enter image description here

Using pad and drawtext. In this example pad adds 50 pixels to the top and 50 pixels to the bottom, then two drawtext instances place each line.

ffmpeg -i input -filter_complex \
"[0:v]pad=iw:ih+100:0:(oh-ih)/2:color=white, \
 drawtext=text='ONE DOES NOT SIMPLY':fontfile=/path/to/impact.ttf:fontsize=24:x=(w-tw)/2:y=(50-th)/2, \
 drawtext=text='STOP ME FROM FILTERING':fontfile=/path/to/impact.ttf:fontsize=24:x=(w-tw)/2:y=h-25-(th/2)" \
output
like image 76
llogan Avatar answered Dec 28 '22 08:12

llogan