How to Convert .MKV Video to .MP4 Video in Linux[Command Line]

FFmpeg is a video and audio converter that can also grab from a live audio/video source. It can also resize video on the fly without compromising the quality.

FFmpeg is a powerful tool and can be used for various scenarios, if you are curious here is the official documentation. We also have a good collection of ffmpge usage examples.

Make sure to install ffmpeg using your distribution’s package manager:

sudo apt install ffmpeg

Once you have selected the video that you want to convert, open your terminal and change directory where your video is saved. Below is a general principle, where input is the actual name of the video, following by the video format and the name that you want your gif to be.

The output name can be something totally different to the input name, but I tend to use something similar, as it helps to identify it when you have a folder full of files.

ffmpeg -i vid.mkv -map 0 -c copy -c:a aac vid.mp4

Source