Convert mkv to mp4 with ffmpeg

Solution 1:

As I've already written here, I suggest you change a few details in your command line:

  • If you're using an Ubuntu release older than 15.04, replace ffmpeg for avconv, as it was the fork used by Ubuntu for a few years (see the comments)
  • Do you really need -absf aac_adtstoasc? It had some issues that may not have been corrected in current Ubuntu's ffmpeg. I suggest you to try without it first.
  • -vcodec copy -acodec copy can be simplified to -codec copy or -c copy. It would also prevent tampering other streams besides video and audio, like subtitles.

So the winner is...

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

If that does not work, please post all terminal output.

Solution 2:

To automatically convert all files in a folder from MKV to MP4 you can create an alias:

alias mkv2mp4="for f in ./**/*.mkv; do ffmpeg -n -i \"\$f\" -c copy \"\${f%.mkv}.mp4\" && rm \"\$f\"; done"

This command performs the following steps:

  • Recursively loops through the current directory looking for .mkv files
  • Converts each file & all its sources to .mp4, not overwriting (-n) existing files
  • Removes the source file when the conversion was successful