Reputation: 61
I have MKV file which contains:
Stream #0:0(eng): Video: h264 (High)
Stream #0:1(pol): Audio: ac3
Stream #0:2(eng): Audio: dts (DTS)
Stream #0:3(pol): Subtitle: subrip
Stream #0:4(eng): Subtitle: hdmv_pgs_subtitle
I would like to omit subtitles (-sn
option), copy video and encode audio streams to AAC.
I tried few various command and output file is always the same (2 audio streams but in both sound from first audio stream).
Here are my commands:
ffmpeg -i input.mkv -sn -map 0:a? -map 0:v -c:v copy -c:a? aac output.mp4
ffmpeg -i input.mkv -sn -map 0 -c:v copy -c:a aac output.mp4
ffmpeg -i input.mkv -sn -map 0:? -c:v copy -c:a aac output.mp4
Everything almost work but in output file I have 2 audio streams with name (pol) and (eng) but in both is sound from (pol) stream0:1.
What command should I use to convert audio streams in order to achieve two a audio streams where will be pol and eng sound (not pol in both of them). Sometimes input file has only 1 audio stream so to command line should be universal, I guess ffmpeg map with ?
character.
Upvotes: 5
Views: 13212
Reputation: 133743
You can remux with stream copy mode (-c copy
). This avoids re-encoding.
ffmpeg -i input.mkv -map 0 -c copy output.mp4
-map 0
selects all streams from input #0 which is input.mkv
(note that ffmpeg
starts counting from 0). Otherwise the default stream selection behavior is used which will only select one stream per stream type.
ffmpeg
will tell you if a stream is not compatible with the output container format with an error message: codec not currently supported in container
.
Currently the most typical compatible formats are: H.264 video, H.265/HEVC video, and AAC audio.
You can use negative mapping. Example to include everything except subtitles:
ffmpeg -i input.mkv -map 0 -map -0:s -c copy output.mp4
See the -map
option documentation for more info.
This example stream copies everything except for audio which is converted to AAC:
ffmpeg -i input.mkv -map 0 -c copy -c:a aac output.mp4
Upvotes: 10