<p>There are multiple questions; I'll try to answer them separately for simplicity.</p>
<p>First of all, converting from mkv to mp4:
The easiest way would be something like this <code>ffmpeg -i input.mkv output.mp4</code>
This will cause ffmpeg to infer the format based on the filename and isn't always possible.</p>
<p>If you need to specify the type explicitly, you can add the parameter <code>-f &lt;format&gt;</code>.
In your case, something like this:
<code>ffmpeg -f matroska -i input.mkv -f mp4 output.mp4</code></p>
<p>Note: The format before the input (<code>-i</code>) corresponds to the input format, while the format after the input corresponds to the output format.</p>
<p>Next, let's look at the codec:</p>
<p>FFmpeg uses a predefined codec by default; you can disable this by specifying the <code>copy</code> codec using <code>-codec copy</code>.</p>
<p>There are multiple options to specify a codec, depending on the scenario:</p>
<ul>
<li><code>-codec copy</code> Use the original codec for all mapped streams</li>
<li><code>-codec libx264</code> Convert all video streams to h264 (type of stream is deduced by the codec)</li>
<li><code>-vcodec libx264</code> Convert video streams to h264 (<code>-acodec</code> and <code>-scodec</code> for audio and subtitles, respectively)</li>
<li><code>-c copy</code> Short for <code>-codec copy</code></li>
<li><code>-c:v copy</code> Short for <code>-vcodec copy</code></li>
</ul>
<p>In your case, something like <code>ffmpeg -i input.mkv -c libx264 output.mp4</code> should produce the desired result.</p>
<p>Next, audio channels:</p>
<p>FFmpeg already integrates a downmixer; therefore, the standard solution is to use <code>-ac 2</code> (Set the number of audio channels to 2).
As Dolby digital is probably not supported within mp4, you should change the audio codec as well:
<code>ffmpeg -i input.mkv -c aac -ac 2 output.mp4</code></p>
<p>A much more detailed answer is provided <a href="https://superuser.com/a/1410620/1130613">here</a>.</p>
<p>Next, chapters:
Removing chapters is relatively easy; adding the following option <code>-map_chapters -1</code> will remove the Chapter-TOC from the output.</p>
<p>Last but not least, stream selection:</p>
<p>The simplest way of selecting a stream is by number, but there are multiple other options:</p>
<ul>
<li><code>-map 0:0</code> use the first stream from the first input file</li>
<li><code>-map 0:v:0</code> select the first video stream from the first input file</li>
<li><code>-map -0:s</code> everything except subtitles from the first input file</li>
<li><code>-map 0:m:language:eng</code> select by language</li>
<li><code>-map 0:v:0?</code> use the first video stream of the first input if exists</li>
</ul>
<p>To conclude this answer, your final command should look something like this:</p>
<pre class="lang-bash prettyprint-override"><code>ffmpeg -i input.mkv \
  -map 0:v:0 \
  -map 0:m:language:eng? \
  -c:v libx264 \
  -c:a aac \
  -map_chapters -1 \
  -ac 2 \
  output.mp4
</code></pre>
<p>Output contains:</p>
<ul>
<li>First video stream</li>
<li>English audio (if exists)</li>
<li>No chapters</li>
<li>Only two audio channels</li>
<li>video codec: h264</li>
<li>Audio codec: aac</li>
<li>Output format: mp4</li>
</ul>
<p>Hope this helps, and I didn't miss any requirements</p>

CC BY-SA 4.0
2022-09-09T16:17:05.680Z
Thank you for your very detailed response. The solution was actually quite simple, just `ffmpeg -i "C:\video.mkv" -c:v libx264 -c:a libfdk_aac -c:a copy "C:\video.mp4"`, but I've saved your reply for future use.
Adam
CC BY-SA 4.0
2022-08-29T11:31:51.370Z
2022-08-29T11:31:51.370Z
Euklios
<p>I have MKV files which contain multiple subtitle options, multiple audio options, and multiple chapters.</p>
<p>I'm wanting to convert to MP4. The MKV's are x265 with DD 5.1. I just want x264 MP4's with plain stereo, no subs and the default audio.</p>
<p>All I can find is solutions for converting with hardcoded subs or specific audio tracks. I need all of that stripped away, and more importantly, x265 to x264.</p>

<ffmpeg><mp4><conversion><mkv><x264>
Using FFMPEG to convert an MKV with multiple subtitles, audio tracks and chapters to a plain mp4
Adam
# Using FFMPEG to convert an MKV with multiple subtitles, audio tracks and chapters to a plain mp4

(Asked by: username_0 on 2022-08-18)

I have MKV files which contain multiple subtitle options, multiple audio options, and multiple chapters.

I'm wanting to convert to MP4. The MKV's are x265 with DD 5.1. I just want x264 MP4's with plain stereo, no subs and the default audio.

All I can find is solutions for converting with hardcoded subs or specific audio tracks. I need all of that stripped away, and more importantly, x265 to x264.

**Tags:** ffmpeg, mp4, conversion, mkv, x264


---

## 1 answers

### Answer by username_1 on 2022-08-29. Score: 3 | Accepted answer

There are multiple questions; I'll try to answer them separately for simplicity.
First of all, converting from mkv to mp4:
The easiest way would be something like this ffmpeg -i input.mkv output.mp4
This will cause ffmpeg to infer the format based on the filename and isn't always possible.
If you need to specify the type explicitly, you can add the parameter -f .
In your case, something like this:
ffmpeg -f matroska -i input.mkv -f mp4 output.mp4
Note: The format before the input (-i) corresponds to the input format, while the format after the input corresponds to the output format.
Next, let's look at the codec:
FFmpeg uses a predefined codec by default; you can disable this by specifying the copy codec using -codec copy.
There are multiple options to specify a codec, depending on the scenario:

-codec copy Use the original codec for all mapped streams
-codec libx264 Convert all video streams to h264 (type of stream is deduced by the codec)
-vcodec libx264 Convert video streams to h264 (-acodec and -scodec for audio and subtitles, respectively)
-c copy Short for -codec copy
-c:v copy Short for -vcodec copy

In your case, something like ffmpeg -i input.mkv -c libx264 output.mp4 should produce the desired result.
Next, audio channels:
FFmpeg already integrates a downmixer; therefore, the standard solution is to use -ac 2 (Set the number of audio channels to 2).
As Dolby digital is probably not supported within mp4, you should change the audio codec as well:
ffmpeg -i input.mkv -c aac -ac 2 output.mp4
A much more detailed answer is provided here.
Next, chapters:
Removing chapters is relatively easy; adding the following option -map_chapters -1 will remove the Chapter-TOC from the output.
Last but not least, stream selection:
The simplest way of selecting a stream is by number, but there are multiple other options:

-map 0:0 use the first stream from the first input file
-map 0:v:0 select the first video stream from the first input file
-map -0:s everything except subtitles from the first input file
-map 0:m:language:eng select by language
-map 0:v:0? use the first video stream of the first input if exists

To conclude this answer, your final command should look something like this:
ffmpeg -i input.mkv \
  -map 0:v:0 \
  -map 0:m:language:eng? \
  -c:v libx264 \
  -c:a aac \
  -map_chapters -1 \
  -ac 2 \
  output.mp4

Output contains:

First video stream
English audio (if exists)
No chapters
Only two audio channels
video codec: h264
Audio codec: aac
Output format: mp4

Hope this helps, and I didn't miss any requirements

> **Comments:**
> **username_0**: Thank you for your very detailed response. The solution was actually quite simple, just `ffmpeg -i "C:\video.mkv" -c:v libx264 -c:a libfdk_aac -c:a copy "C:\video.mp4"`, but I've saved your reply for future use.  

---

