WebM is just a subset of Matroska (.mkv), so just use HandBrake to create a MKV file (choose MKV container, not MP4). IMHO is HandBrake the best tool for creating MP4 and MKV files on Mac (also exists for Windows and Linux, but I never used it there). With two pass encoding you can get optimal quality for the available storage space and/or bandwidth, and while being very powerful (you can configure so many settings), HandBrake is still a very easy tool (you don't need to configure most of the settings, already the defaults will give you very good results).
Just keep in mind that WebM is a MKV subset, so as a video codec use either VP8 or VP9 and as an audio codec use either Vorbis or Opus. Up to 2013 there was only VP8 and Vorbis for WebM, so this is the most compatible combination that is going to play on most devices, browsers and players. In 2013 the newer VP9 and Opus were added and now any combination of these is legit.
Once you got your MKV, convert it to WebM using ffmpeg
. You can download ffmpg pre-built for MacOS X as a stand-alone binary (works with 10.9 or newer). All you need to do is running that command in Terminal:
./ffmpeg -i INPUTIFLE.mkv -c copy OUTPUTFILE.webm
and that's it. This will be very fast because -c copy
means that ffmpeg is not converting anything here (the video is not transcoded again!), it is copying all audio and video data just as it is, only the container is rewritten, removing the MKV parts that are not supported in WebM (e.g. chapters are not supported). Just copying also means that this conversion has zero influence on quality as nothing is recompressed.
Using ffmpeg
to convert between containers w/o recompression also works with many other formats. E.g. if you have a MKV that is in fact MPEG4 or H.264, you can convert that to a MP4 file the same way, no re-enconding. You can even extract just the audio layer of a video to plain audio file without losing any quality (e.g. extracting MP3 or AAC audio to an MP3 or MPA file). If the chosen destination container cannot hold the data of the source file (e.g. you cannot copy AAC audio into a MP3 file or VP9 video into a MP4 file, that just won't work), ffmpeg
will let you know.