The fastest way to convert MKV to MP4 on Linux
The quickest method uses FFmpeg, a command-line tool installed on most Linux systems. Open a terminal, navigate to the folder holding your MKV file, and run this single command:
ffmpeg -i inputfile.mkv -codec copy outputfile.mp4
Replace inputfile.mkv with your actual filename and outputfile.mp4 with what you want to call the result. The -codec copy flag tells FFmpeg to copy the video and audio streams without re-encoding, which means the conversion finishes in minutes rather than hours. The file size stays nearly identical because you are only changing the container format, not the video quality itself.
If that command fails with a "file not found" error, FFmpeg is not installed. On Ubuntu or Debian, run sudo apt install ffmpeg. On Fedora, run sudo dnf install ffmpeg. On Arch, run sudo pacman -S ffmpeg. After installation completes, run the conversion command again.
Key Takeaways
- FFmpeg with the -codec copy flag converts MKV to MP4 in minutes without losing quality, because it only changes the container format.
- If your MKV contains audio or subtitle tracks that MP4 does not support, FFmpeg will drop them — check the output to confirm what made it through.
- Handbrake offers a graphical interface instead of command-line typing, and lets you re-encode the video if you need to shrink the file size.
- VLC can convert files through its menu, though it is slower than FFmpeg and designed primarily for playback rather than batch conversion.
When to re-encode instead of just copying
The -codec copy method works when your MKV and MP4 contain compatible video codecs — usually H.264 or H.265. But if your MKV uses an older or uncommon codec, or if you want to shrink the file size, you need to re-encode. This takes much longer (often hours for a two-hour video) but gives you control over quality and file size.
To re-encode, use this command instead:
ffmpeg -i inputfile.mkv -c:v libx264 -preset medium -crf 23 -c:a aac outputfile.mp4
This tells FFmpeg to encode the video with H.264 at quality level 23 (lower numbers mean better quality but larger files; 23 is a reasonable middle ground), and convert the audio to AAC format, which MP4 supports reliably. The -preset medium flag balances speed and compression — use fast if you are in a hurry, or slow if file size matters more than time.
Using Handbrake for a graphical interface
If you prefer clicking buttons instead of typing commands, Handbrake is a graphical tool that handles MKV to MP4 conversion. Install it with sudo apt install handbrake on Ubuntu or Debian, or download it from the Handbrake website for other distributions.
Open Handbrake, click the folder icon to select your MKV file, then choose "MP4" from the container dropdown near the bottom of the window. Click "Start" and Handbrake will re-encode the video using its default settings, which produce good quality at reasonable file sizes. The process takes longer than FFmpeg's copy method but requires no command-line knowledge.
Handbrake also lets you adjust quality, file size, and audio settings before conversion starts. If you have many files to convert, you can add multiple MKV files and queue them — Handbrake will process them one after another without your help.
Converting with VLC media player
VLC is primarily a video player, but it includes conversion tools. Most Linux distributions include VLC by default; if yours does not, install it with sudo apt install vlc.
Open VLC, click the Media menu, and select "Convert / Save". Click "Add" to choose your MKV file, then click "Convert / Save" at the bottom. In the dialog that appears, select "Video - MP4" from the profile dropdown, then click "Browse" to choose where to save the output file. Click "Start" to begin conversion.
VLC works reliably but converts more slowly than FFmpeg because it re-encodes by default. Use it when you already have VLC open or when you prefer a familiar interface, but for batch conversions or speed-critical work, FFmpeg or Handbrake are better choices.
Handling audio and subtitle tracks
MKV files often contain multiple audio tracks or subtitle streams. When you convert to MP4, some of these may not transfer. FFmpeg's copy method preserves whatever tracks the MP4 container supports, but it drops incompatible ones silently.
To see what your MKV contains before converting, run:
ffmpeg -i inputfile.mkv
FFmpeg will list every stream in the file — look for lines starting with "Stream #0". If you see audio tracks labeled as FLAC or DTS, or subtitles labeled as ASS or SSA, those will not survive the copy-only conversion. To keep them, either re-encode the audio to AAC (which MP4 supports), or extract the subtitles as separate files and add them back after conversion.
Batch converting multiple files
If you have dozens of MKV files to convert, typing the command once for each file wastes time. Create a simple script to do it automatically. Open a text editor, paste this code, and save it as convert.sh in the folder containing your MKV files:
#!/bin/bash for file in *.mkv; do ffmpeg -i "$file" -codec copy "${file%.mkv}.mp4" done
Then run chmod +x convert.sh followed by ./convert.sh. The script will convert every MKV file in that folder to MP4, naming each output file to match the input (so movie.mkv becomes movie.mp4). This runs overnight if needed, and you can check progress by opening the folder in a file manager.
Troubleshooting common problems
If FFmpeg reports "Unknown encoder" or "Encoder not found", your FFmpeg installation is missing optional codecs. Reinstall it with sudo apt install ffmpeg --reinstall, or on some systems, install the ffmpeg-full package instead of the basic ffmpeg package.
If the output MP4 plays audio but no video, the video codec in your MKV is not MP4-compatible. Use the re-encoding command with libx264 instead of -codec copy. If the output file is much larger than the original, you re-encoded when you only needed to copy — check that you used -codec copy in your command.
If conversion stops partway through with an error about a missing library or codec, search the error message along with your Linux distribution name — the solution usually involves installing a specific package through your package manager.
Frequently Asked Questions
Does converting MKV to MP4 reduce video quality?
Not if you use the -codec copy method. The video data stays identical — you are only changing the container format. Quality loss only happens if you re-encode, and even then you control how much quality you trade for file size using the -crf setting.
Why is my converted MP4 file so much larger than the original MKV?
You likely re-encoded when you only needed to copy. Check your command — if it does not include -codec copy, FFmpeg is re-encoding the video, which can produce a larger file if the original was already compressed. Use -codec copy to keep the file size nearly identical.
Can I convert MKV to MP4 on a Raspberry Pi or low-power computer?
Yes, but re-encoding takes much longer — sometimes days for a two-hour video on older hardware. Use the -codec copy method instead, which works on any Linux system regardless of processor speed. If you must re-encode, use -preset ultrafast to prioritize speed over compression.
What if my MKV file has multiple audio tracks and I only want one in the MP4?
Add -map 0:v -map 0:a:0 to your FFmpeg command. This tells FFmpeg to include all video streams and only the first audio track. Change the 0 at the end to 1, 2, etc. to select a different audio track instead.
Is it safe to delete the original MKV after conversion?
Only after you verify the MP4 plays correctly in your media player and contains the audio and video you expected. Keep the MKV for at least a few days in case the conversion failed silently or dropped important tracks. Once you confirm the MP4 is complete, you can safely delete the original.