ffmpeg

How to split a .mkv file into sound and video files?


I have a mkv file which contains 3 streams. I use ffprobe to get the info of my mkv file.

ffprobe ./demo/test2.mkv 

I got this output

Input #0, matroska,webm, from './demo/test2.mkv':
Metadata:
encoder         : libebml v0.7.7 + libmatroska v0.8.1
creation_time   : 2011-02-16T16:06:17.000000Z
Duration: 00:03:41.08, start: 0.000000, bitrate: 1363 kb/s
Stream #0:0: Video: rv40, yuv420p, 720x480, SAR 1:1 DAR 3:2, 29.97 tbr, 1k tbn, 1k tbc (default)
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp

The audio streams should be vocal and background music. I would like to extract them from the video.

I have tried to do so with this command

ffmpeg -i ./demo/test2.mkv -map_channel 0.1.0 -y ch0.wav -map_channel 0.2.0 -y ch1.wav

However, it outputs the same audio file. Is there any mistake I have made? Thanks a lot.


Solution

  • Assuming the vocal and BG parts are separate tracks, use

    ffmpeg -i ./demo/test2.mkv -map 0:a:0 track1.wav -map 0:a:1 track2.wav