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
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
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 (
-scodec for audio and subtitles, respectively)
-c copy Short for
-c:v copy Short for
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.
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 \
- 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