I needed to convert several videos in an MKV container to MP4 for better compatibility with my Apple devices so I needed a quick, easy and free way to do so. Here’s the solution I came up with:

brew install ffmpeg
  • With the videos you want to convert in a single folder, run this script from the command line:
#!/usr/bin/env zsh -f
for video in *.mkv
do
ffmpeg -i $video -c:v copy -c:a copy ${video%.mkv}.mp4
done

Voilà! The containers are swapped and no re-encoding is necessary, allowing me to keep the original quality of the video.