ffmpegvstack

How to use ffmpeg vstack to have both audio tracks?


I have simplest ever question, which I can't find an answer here. How to vstack and get sound from both videos?

I use simply:

ffmpeg -i e:\tt140_H.mp4 -i e:\tt140_m.mp4 -vsync 2 -filter_complex vstack e:\tt140+.mp4

but get only first track, not both.

EDIT

When I try

ffmpeg -i e:\tt140_H.mp4 -i e:\tt140_m.mp4 -vsync 2 -filter_complex "[0:v][1:v]vstack,amerge[a]" -c:a aac e:\tt140+.mp4

I get error: Media type mismatch between the 'Parsed_vstack_0' filter output pad 0 (video) and the 'Parsed_amerge_1' filter input pad 0 (audio).


Solution

  • You use amerge or amix depending on your requirements.

    https://ffmpeg.org/ffmpeg-filters.html#toc-amerge-1

    https://ffmpeg.org/ffmpeg-filters.html#toc-amix

    Here's an amix example:

    ffmpeg -i 'Brassic01.mp4' -i 'Brassic03.mp4' -vsync vfr -filter_complex "[0:v][1:v]vstack=2::shortest=0[out0];[0:a][1:a]amix[a]" -map [out0] -map [a] -preset ultrafast out.mp4