The simplest way to convert MKV to MP4 on Linux

The fastest conversion on Linux uses FFmpeg, a command-line tool that handles video format changes in minutes. You run one line of code, and FFmpeg re-packages your video from MKV (Matroska) into MP4 without re-encoding — meaning it keeps the same video and audio quality while just changing the container format. This takes seconds to minutes depending on file size.

If you prefer a graphical interface instead of typing commands, HandBrake offers a window-based converter that does the same job. Both tools are free and available in your Linux distribution's package manager. The choice between them comes down to whether you want speed (FFmpeg) or a visual interface (HandBrake).

Key Takeaways

  • FFmpeg converts MKV to MP4 in one command line and keeps the original video quality by skipping re-encoding.
  • HandBrake provides the same conversion through a graphical window if you prefer not to use the terminal.
  • Copy mode (FFmpeg's -c copy flag) completes conversion in seconds; re-encoding takes hours but allows quality adjustments.
  • MP4 files play on more devices and platforms than MKV, making conversion useful for phones, tablets, and older media players.
  • Both tools are free, open-source, and available through your distribution's package manager without installation fees.

Installing FFmpeg on your Linux system

FFmpeg comes pre-installed on many Linux distributions, but if you need it, installation takes one command. On Ubuntu or Debian-based systems, open a terminal and type: sudo apt install ffmpeg. On Fedora or Red Hat systems, use: sudo dnf install ffmpeg. On Arch Linux, use: sudo pacman -S ffmpeg. After installation completes, verify it worked by typing ffmpeg -version — you should see version information.

If you use a different distribution, search your package manager for "ffmpeg" and install from there. The tool is widely available and maintained, so you will find it in any major repository. Once installed, you can convert files when ready without restarting.

Converting MKV to MP4 without re-encoding

The fastest conversion keeps your video and audio exactly as they are — it only changes the file wrapper. Open a terminal in the folder containing your MKV file, or navigate there using cd /path/to/folder. Then type this command, replacing input.mkv and output.mp4 with your actual filenames:

ffmpeg -i input.mkv -c copy output.mp4

The -c copy flag tells FFmpeg to copy the video and audio streams without touching them. Conversion finishes in seconds or minutes depending on file size. The output MP4 will be nearly identical in size to the original MKV because no re-encoding happened. This method works when your MKV contains video and audio codecs that MP4 supports — which is true for most MKV files you encounter.

If the command fails with an error about unsupported codecs, your MKV contains audio or video that MP4 cannot hold. In that case, move to the re-encoding section below.

Re-encoding when copy mode does not work

Some MKV files contain audio codecs like FLAC or video codecs like VP9 that MP4 containers do not support. When copy mode fails, you must re-encode — convert the streams to formats MP4 accepts. This takes much longer (often hours for a two-hour video) but produces an MP4 that plays anywhere.

Use this command to re-encode to H.264 video and AAC audio, the most compatible formats:

ffmpeg -i input.mkv -c:v libx264 -crf 23 -c:a aac -b:a 128k output.mp4

The -crf 23 setting controls quality: lower numbers (like 18) mean better quality but larger files; higher numbers (like 28) mean smaller files but visible quality loss. The default 23 balances quality and file size for most uses. The -b:a 128k sets audio bitrate to 128 kilobits per second, which sounds good for most content. Conversion will take significant time — check back in an hour or more depending on your video length and computer speed.

Using HandBrake for a graphical interface

If you want to avoid the terminal, HandBrake provides a window-based converter that does the same work. Install it with sudo apt install handbrake on Ubuntu or Debian, or search your package manager for "handbrake" on other distributions. Launch the process and click "Open Source" to select your MKV file.

HandBrake defaults to re-encoding with reasonable settings, so your conversion will take time but produce a widely compatible MP4. If you want faster conversion without re-encoding, HandBrake does not offer a copy mode — it always re-encodes. For that reason, FFmpeg is faster if your MKV already contains compatible codecs. Use HandBrake when you want a visual interface and do not mind waiting for re-encoding.

Checking your converted file before deleting the original

After conversion finishes, play the MP4 file in your media player to confirm it looks and sounds correct. Check that video plays smoothly, audio syncs with video, and subtitles (if present) appear. If something looks wrong, keep the original MKV — do not delete it yet.

Common issues include audio out of sync (usually from re-encoding with mismatched settings) or missing subtitles (because MP4 handles subtitle formats differently than MKV). If subtitles disappeared, you can extract them from the MKV and add them back, but that requires additional steps. For most conversions, the MP4 plays correctly and you can safely delete the MKV to free disk space.

Batch converting multiple MKV files

If you have many MKV files to convert, you can automate the process with a shell script instead of running the command for each file. Create a new text file called convert.sh in your folder of MKV files, then paste this code:

#!/bin/bashfor file in *.mkv; do ffmpeg -i "$file" -c copy "${file%.mkv}.mp4"done

Save the file, then open a terminal in that folder and type: chmod +x convert.sh followed by ./convert.sh. The script will convert every MKV file in the folder to MP4, naming each output file to match the input. This runs in the background, so you can close the terminal and come back later. For re-encoding instead of copy mode, replace -c copy with your re-encoding command from the earlier section.

Frequently Asked Questions

Why is my MKV file larger than the MP4 after conversion?

MKV containers are less efficient at storing video than MP4, so the same video takes more space in MKV form. When you convert with copy mode (no re-encoding), the MP4 will be slightly smaller because the container itself is more compact. If the MP4 is much larger, you probably re-encoded with higher quality settings than the original MKV used.

Can I convert MP4 back to MKV using the same method?

Yes, the command works in reverse: ffmpeg -i input.mp4 -c copy output.mkv. MKV supports more audio and subtitle formats than MP4, so converting back is useful if you want to add multiple audio tracks or subtitle streams. Copy mode works the same way — fast and lossless.

What if FFmpeg says the file is corrupted?

A corrupted MKV file may not convert properly. Try playing it in a media player first to confirm it works. If it plays but FFmpeg fails, the file may have minor corruption that playback tolerates but conversion does not. Try re-encoding with -err_detect ignore_err added to your command, though this may produce incomplete output.

Does conversion reduce video quality?

Copy mode preserves quality completely — you are only changing the container, not the video itself. Re-encoding can reduce quality if you use high compression settings, but the default settings in the re-encoding command above maintain good quality for most uses. If quality matters, use copy mode whenever possible.

How long does conversion typically take?

Copy mode takes seconds to a few minutes depending on file size. Re-encoding takes much longer — typically 30 minutes to several hours for a two-hour video, depending on your computer's processor speed and the quality settings you choose. Faster processors complete re-encoding sooner, but even on older hardware, re-encoding runs in the background without blocking other work.