Best Guide to Convert MKV to MP4 Using FFmpeg

mkv to mp4 using ffmpeg

There often arise a need to convert the format of the video to another. There are many formats out there, but the most used are MKV and MP4, so to convert Mkv to mp4 using FFMpeg, there are several services and platforms out there. One such program is FFMpeg. FFmpeg is a valuable program for fast changing the format or quality of an AV file, extracting audio, making GIFs, and much more.

On the other hand, FFmpeg can be difficult to use for beginners. Knowing the entire command lines can be beneficial. The primary command line to convert MKV to MP4 is:

 ffmpeg -i input.mkv output.mp4

FFmpeg is a command-line-based free and open-source software project. It provides a comprehensive, cross-platform solution for recording, converting, and streaming audio and video, effective conversion of MKV to MP4 using FFmpeg. This command line’s complete explanation is as follows:

  1. FFmpeg: a required component for informing the operating system using the command line.
  2. I: The abbreviation input indicates that the following file is the source file to be converted.
  3. File to be converted.mp4: the file to be converted. FFmpeg I input1.mp4 I input2.mp4 I input3.mp4 I input4.mp4 I input5.mp4 I input6.mp4 I input7.mp4 I input8.mp4 I input.
  4. Output.Mkv: the MKV container’s output file. You can change the format to suit your needs. You don’t need to worry about the audio and video encoder because of the power processing capability. FFmpeg will select the most appropriate ones.


Basic conversion of mkv to mp4 using FFmpeg

Before going in after the hardcore details, let us take a moment and help the novices out there who might have different approaches to doing this but are committed to learning how to convert Mkv to mp4 using FFmpeg. The foremost step in doing so is, downloading the program you will use; hence let us start with downloading FFMpeg.

Downloading FFmpeg from the official website

Downloading FFmpeg from the official website is the official download site for FFmpeg for Windows, Linux, and Mac.

In the present article, we will take the example by downloading the Windows version and walk you through the configuration steps based on it.

Configure FFmpeg

Locate the FFmpeg binary file folder at the location. Select and copy the address in the address bar. Configuring FFMpeg is the foremost step to successfully converting Mkv to mp4 using FFMpeg.

Enter “system” into the search bar by pressing the Win key on your computer. The Control Panel tab has a system button. Locate and click Advanced system settings on the left-hand side of the new pop-up window. Then, in the System variables table, look for Path by clicking > Environment variables… The path can be edited by double-clicking it.

To put the location address of FFmpeg’s binary file folder at the end of the original value bar, use Ctrl + V. Please ensure that the original finishes with “;” If it isn’t already there, include it.

Now that you are done configuring the program let’s get right to the chase and know how to convert Mkv to mp4 using FFMpeg.

Change Character:

This operation requires the same command like the one shown at the beginning of the article, namely FFmpeg I input. Mkv output.mp4. Let’s skip ahead to the portion where the matching parameters are introduced. There is no need to require any transcoding while converting MKV to MP4 using FFmpeg.

MKV to MP4 using FFmpeg Conversions in Bulk

MKV to MP4 using FFmpeg Conversions in Bulk

Suppose you want to convert a large number of MKV files to MP4 simultaneously. You can also use FFmpeg for help. To do so, open a DOS window and go to the location.mkv files are stored. If you want to convert Mkv to mp4 using FFmpeg, you should follow the procedures below.

  1. Press Win + R and type cmd to open the DOS window. Typed: to access the D disc.  
  2. At the command prompt, type cd mkvFolder. I’m currently in the MKV folder.
  3. Use the following command to start.
FFmpeg: IN (*.mkv) /R % f ffmpeg -i "% f" –c copy " % nf.mp4

Defining the Parameters of the above-used command :

The looping section —

for /R %f IN (*.mkv) Do 

– as well as the FFmpeg command

 ffmpeg –i "%f" –c copy "%~nf.mp4" 

These can be divided into two categories:

  • The first portion checks to see if there are any more.mkv files; if there are some more left, the mkv to mp4 using FFMpeg will start and stop until there are none left to convert.
  • The second part, i.e., the FFmpeg command, follows the same pattern as the first. The only difference is the input and output file names and the –c copy option. The file name is the input name and is the same, while the command %nf defines that the output names should be the same as the original ones.

Finally, the -c copy option ensures that the original stream codec and the video and audio streams are preserved. To put it another way, there will be no transcoding when converting Mkv to mp4 using FFMpeg.

Change Codecs for videos and audio streams :

Using the methods listed above, the output file will be encoded using the original codecs, which may or may not be the ones you want. FFmpeg also allows you to change the codecs to a specific one. For instance, if you’re going to convert FFmpeg to MP4 with the H264 codec. You can type this command :

ffmpeg –i input.mkv –c:v h264 output.mp4

-c:v denotes that the following character is used to specify the video codec. You can also use –c: a to specify an audio codec, such as FFmpeg I input. mkv. –c: an output.mp4 aac If you’re not sure which codecs your FFmpeg supports, type FFmpeg –codecs in a DOS window to get a list of supported codecs. This shall complete the steps for converting Mkv to mp4 using FFmpeg.

Hence, following the above chain of command, one can easily convert Mkv to mp4 using FFmpeg no matter how novice one might be.

Convert mp4 to mkv using FFmpeg without re-encoding

Convert mp4 to mkv using FFmpeg without re-encoding

Just use the following command to solve the problem.

ffmpeg -i filename.mkv -vcodec copy 1.mp4

Mkv to mp4 using FFMpeg losslessly

the most accessible tool for that is ffmpeg, or avconv from the libav-tools package. Libav is a fork of FFmpeg, which Ubuntu switched to for a few years until Ubuntu 15.04. Following is the command to do so

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

Mkv to Mp4 without losing subtitles?

MP4 does not support SRT. You can either use softsubs or hard subs.

Softsubs are the subtitles that consist of a separate stream in the file. They can be toggled on/off by the player and do not require the video stream to be re-encoded.

ffmpeg -i input.mkv -c copy -c:s mov_text output.mp4

Hard subs are “burned” into the video, so the video must be re-encoded.

ffmpeg -i input.mkv -vf subtitles=input.mkv output.mp4

Convert MKV to MP4 using FFmpeg on iPhone/iPad?

Convert video file format with FFmpeg for iPod/iPhone/iPad in one command

For our convenience, we can form this command to a script

ffmpeg -i $1 -s 480x320 -b 1000k -strict -2 /tmp/$1.mp4

Each time to convert a video file video.wmv, we can run:

$ video.wmv

and the converted file is /tmp/video.wmv.mp4 after the script finishes

FAQs on Convert MKV to MP4 Using FFmpeg

What is FFmpeg?

FFMpeg stands for Fast Forward Moving Pictures Expert Group.FFmpeg is a free and open-source software project that includes a collection of libraries and tools for working with video, audio, and other multimedia files and streams. The command-line FFmpeg utility, designed to process video and audio data, lies at its heart.

How to install FFmpeg?

Go to the official website of FFmpeg to download it for Windows, Linux, and Mac. Click here to redirect yourself to the FFmpeg site.

Does FFmpeg conversion reduce the quality?

No, it does not affect the quality provided the suitable formats and codecs have been chosen, and its default function ensures no loss of quality while converting Mkv to mp4 using FFmpeg. However, you can use the FFmpeg command line to change the quality of any audio or video manually.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top