3

I'm trying to extract video from an mkv file using mkvextract. Is there a way to extract the audio along with it so that the resulting video file already has audio, or does audio and video have to be extracted separately and recombined later?

1 Answer 1

3

Look at the manual (emphasis mine):

This program extracts specific parts from a Matroska™ file to other useful formats. The first argument, mode, tells mkvextract(1) what to extract. Currently supported is the extraction of tracks, tags, attachments, chapters, CUE sheets and timecodes.

The tool only has a very specific purpose, namely extracting parts from an MKV file. This is easier to implement than recombining audio and video at the same time, which would involve creating another container and synchronizing both streams. I guess this is way beyond the scope of an extractor tool.

If you want to recombine, you need another tool, as suggested by the mkvextract manual:

H.264 / AVC video tracks are written to H.264 elementary streams which can be processed further with e.g. MP4Box™ from the GPAC™ package.

Using ffmpeg would also be an option, of course. If the only thing you want to to is get video and sound out of an MKV file, then you just want to transcode the file into something different. For example, the following command just copies the stream content as is (e.g. h.264 video and AAC audio) and transcodes an MKV into an MP4:

ffmpeg -i infile.mkv -vcodec copy -acodec copy outfile.mp4
2
  • Why is it that when I extract the video file I can't play it?
    – tony_sid
    Jul 28, 2011 at 8:11
  • > "... are written to H.264 elementary streams" -- an elementary stream without a container can not be played by all programs. It contains raw h.264 video data and should actually be wrapped into an .mp4 or a .mkv container again to be played back.
    – slhck
    Jul 28, 2011 at 8:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .