Chris MacPherson

Extract audio or video from MKV files with mkvtoolnix

April 19, 2020 -
2 minute read

I streamed a few DJ sets over the last few weeks with a bunch of friends as part of ‘covidcore’, an online get-together while we’re all in isolation. It’s been a while since I’ve played any DJ sets but it was great fun and thankfully I didn’t make too many mistakes.

Anyway, It was my first streaming experience and I found it a breeze to set up thanks to Twitch and OBS. When reviewing my recordings I noticed that my microphone level was pretty low so I decided to bust out the audio track from the video and raise it. Also when uploading my video to Youtube I also got a copyright notice about one the clips in my video which was subsequently being blocked, so I decided to edit that out too.

Here is how you can do it.

Note: I’m on a mac so all of the instructions are for that, but apart from installation the rest should be platform agnostic.

Optionally convert audio track if editing needed

My audio editor couldn’t open the aac file I created so I converted it to FLAC format using ffmpeg, another command line program that is insanely useful for converting audio formats (amongst other things).

So to convert I ran

ffmpeg -i audio.aac -c:a flac audio.flac

Now I can open my flac file and edit the parts I want, like amplifying my microphone in the recording.

Merge audio and video tracks back in to mkv file

Right, now you have completed your editing we can stitch them back together again using the mkvmerge command

mkvmerge -o name-of-your-output-file.mkv video.h264 audio.flac

You can see I just merged the flac formatted audio back in. I just tried it and it worked. I need to read up a bit more on file formats to be honest so if you need more info check the docs.