[FFmpeg-user] Stack + resize + use audio from first video?

Moritz Barsnick barsnick at gmx.net
Tue Feb 9 11:38:22 EET 2021


On Mon, Feb 08, 2021 at 13:00:15 -0600, Gilles wrote:
> In one command, I'd like to stack two videos, resize them to the same
> width+height, and use audio from the first video.

Which of the below works for you? The first two, right?

> #Stack
> ffmpeg -i input0 -i input1 -filter_complex vstack=inputs=2 output
>
> #Using audio from one particular input. This example will use the audio from
> input1:
> ffmpeg -i input0 -i input1 -filter_complex "[0:v][1:v]vstack=inputs=2[v]"
> -map "[v]" -map 1:a output
>
> #Resize/scale an input
> ffmpeg -i input0 -i input2 -filter_complex
> "[0:v]scale=640:-1[v0];[v0][1:v]vstack=inputs=2" output

You could just merge your work from the second and the third example.
Did you try this?:

$ ffmpeg -i input0 -i input1 -filter_complex "[0:v]scale=640:-1[v0];[v0][1:v]vstack=inputs=2[v]" -map "[v]" -map 1:a output
(Untested by myself.)

There's also a very handy filter called "scale2ref". It will scale one
input based on the other's size:

https://ffmpeg.org/ffmpeg-filters.html#scale2ref

Cheers,
Moritz


More information about the ffmpeg-user mailing list