fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.64k stars 874 forks source link

How center the input video inside the output video? #1154

Open jonathanidealump opened 2 years ago

jonathanidealump commented 2 years ago

Hello,

Thank you for your work.

I would like to get this result:

My cool Image

But I cannot found enough documentation about the complexFilter parameters. Add a "background image" is optional, What want to do as a priority is to be able to center a video or add padding or margin or border (I also want to keep the sound).

Can you help me.

Regards

laggingreflex commented 2 years ago

First I'd figure out a way to do this in ffmpeg.

Then translate it to fluent:

.complexFilter([
 ... 
 // overlay=(W-w)/2:(H-h)/2:shortest=1
 { filter: 'overlay', options: { x: '(W-w)/2', y: '(H-h)/2', shortest: 1 } inputs: ['base', 'vid'] }
 ...
])

For some filters (like overlay in this case) you might also need to check the ffmpeg docs for what names the named options translate to (x, y in this case): https://ffmpeg.org/ffmpeg-filters.html#overlay-1