Converting mkv to h264 FFmpeg

I suggest you first check whether your .mkv file already has H.264/AAC streams in the first place. Because if it does, all you have to do is copy the streams and change the container:

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

If it doesn't, you probably got rejected because your formats are not compatible with .mp4. Try the following to output H.264/AAC:

ffmpeg -i input.mkv -c:v libx264 -c:a aac output.mp4

But again, if your .mkv already contains H.264/AAC, USE THE FIRST SOLUTION. It'll be faster and will have a better quality.


As an alternative to ffmpeg you can use HandBrakeCLI, e.g.:

HandBrakeCLI --encoder "x264" --quality 25.0 --aencoder "copy:aac" --audio-fallback "av_aac" --all-audio --all-subtitles -i "input.mkv" -o "output.mkv"

HandBrakeCLI is part of the package handbrake-cli.

For parameter explanation, see HandBrakeCLI --help or https://handbrake.fr/docs/en/latest/cli/command-line-reference.html