Programster's Blog

Tutorials focusing on Linux, programming, and open-source

FFMPEG - Losslessly convert mp4 to mkv

The formats mp4 and mkv are just the "containers" for video files that you have, which "contain" the video, audio, and metadata, such as chapter information and subtitles, for the content. The video and audio streams are encoded using codecs such as libx264 and vorbis etc. Since mkv and mp4 can both hold the same codecs (as far as I'm aware) you can losslessly convert an mp4 file into an mkv file in order to take advantage of the additional functionality mkv can provide, such as better support for subtitles etc.

This tutorial assumes you are using a Linux computer.

To convert an mp4 video to mkv, simply install ffmpeg and run the command below:

ffmpeg \
-i input.mp4 \
-vcodec copy \
-acodec copy \
output.mkv
Last updated: 28th February 2021
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch