[FFmpeg-user] How to create "Input #1", "Input #2" etc. in addition to "Input #0"?

Moritz Barsnick barsnick at gmx.net
Mon Sep 28 16:14:16 EEST 2020


On Mon, Sep 28, 2020 at 12:31:49 +0000, Stub via ffmpeg-user wrote:
> Let me give a much simplified example of what I hoped to achieve. I have two movie files that each contain a video stream and an audio stream: movie1.mp4 and movie2.mp4. I merge both into a single MKV container with ffmpeg:
>
> ffmpeg -i movie1.mp4 -i movie2.mp4 -map 0:v -map 0:a -map 1:v -map 1:a -c copy combined.mkv
>
> At the end of the ffmpeg monitor output I get the following about the contents of the "combined.mkv":
>
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
>   Stream #0:1 -> #0:1 (copy)
>   Stream #1:0 -> #0:2 (copy)
>   Stream #1:1 -> #0:3 (copy)

In ffmpeg's stream mapping notation, the digits before the colon count
the separate inputs (files or URIs) and outputs.

> Now, my question is how to achieve the following mapping:
>
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
>   Stream #0:1 -> #0:1 (copy)
>   Stream #1:0 -> #1:0 (copy)
>   Stream #1:1 -> #1:1 (copy)

You can only achieve this by creating two output files, not a combined
file.

$ ffmpeg -i movie1.mp4 -i movie2.mp4 -map 0:v -map 0:a -c copy output1.mkv -map 1:v -map 1:a -c copy output2.mkv

> It seems that the "-map" flag always adds a stream as a "#0:n". I
> would like to have "#1:0" and "#1:1" in the "combined.mkv" container.
> Is that possible?

No. And to reiterate others' questions: What for? A single input file
will always present itself to ffmpeg as "Input #0". If you want an
additional "Input #1", give ffmpeg a second input file/URI.

Again: If you map to a *combined* file, all output streams of the
conversion process *need* to be "#0:N".

Cheers,
Moritz


More information about the ffmpeg-user mailing list