Remux to MKV, but add all streams using FFmpeg

I am trying to automate FFmpeg to convert all video files to a given directory in MKV. I am currently using

ffmpeg -i $INPUT -c copy $OUTPUT.mkv 

However, some streams are skipped this way - for example, if there are 2 audio streams, only 1 goes to the output file.

How to indicate that all streams from input should be copied to output?

Since I'm trying to automate FFmpeg, it would be better if the command did not change for each file, that is, manually specifying all streams with -map would require me to parse each file first. I would do it if necessary, but if there is a better solution, I would prefer it.

+6
source share
1 answer

How to indicate that all streams from input should be copied to output?

The -map option can do this with the -map 0 shortcut.

For instance:

 ffmpeg -i input.mkv -c copy -map 0:0 -map 0:2 output.mkv 

to copy the stream 0: 0 and 0: 2 to output.mkv.

 ffmpeg -i input.mkv -c copy -map 0 output.mkv 

to copy all input streams from input 0 ( input.mkv ) to output (even if there are several streams of video, audio or subtitles).

The value -map corresponds to the input number ( 0 is the first input, 1 is the second input, etc.): if you add an additional input (-> input 1), and also want to copy the entire contents, then you will need to add -map 1 .

You can use ffprobe to analyze files and see which stream is displayed where. Try -fflags +genpts if you get an unknown timestamp error. For a detailed guide, see the WFFFppeg page in the -map option .

+15
source

All Articles