I'm on MacOSX Lion and would like a method for converting webm to mp4 (or another iTunes compatible format). ffmpeg seems like a possibility but the documentation is a bit obtuse for me; step-by-step directions would be appreciated.
- 2,359
- 4
- 21
- 30
-
1You can also use Handbrake if that's already installed. It's a beautiful, open source GUI around ffmpeg and does the trick very nicely and easily. https://handbrake.fr/ – Joshua Pinter Apr 25 '20 at 16:32
2 Answers
Get FFmpeg
If you want to use ffmpeg, go and either
- download a recent version of it, or
install it through Homebrew with
brew install ffmpeg
If you downloaded it manually (not with Homebrew), I would suggest copying the ffmpeg executable file to your PATH, so that you can use it from the Terminal. Let's say you downloaded it to ~/Downloads/ffmpeg/ffmpeg, then do:
sudo mkdir -p /usr/local/bin
sudo cp ~/Downloads/ffmpeg/ffmpeg /usr/local/bin/
sudo chmod +x !$ /usr/local/bin/ffmpeg
Convert to MP4
Now, by "to MP4", I assume you mean to use H.264 and AAC as video and audio codecs, respectively. For that, the basic command would be:
ffmpeg -i input.webm -c:v libx264 -c:a aac -strict experimental -b:a 192k output.mp4
If you want to control the quality, have a look at the x264 encoding guide. It is set with the -crf option, where the default is 23, and lower means better quality (typical values are from 18 to 28). In the above example it uses the default quality of 23 for video, and 192 kBit/s constant bitrate for audio.
As for audio, the static builds do not support libfdk-aac, but if you have support for it, you should use that instead:
ffmpeg -i input.webm -c:v libx264 -c:a libfdk_aac output.mp4
FDK-AAC gives you better quality than the internal AAC encoder. For controlling audio quality, see the AAC encoding guide.
- 223,558
- 70
- 607
- 592
-
I successfully create MP4 files this way on FreeBSD (from MKV and WEBM), and can play them on FreeBSD with `mplayer`, but Apple refuses to open them... – Mikhail T. Feb 05 '17 at 08:30
-
Who is "Apple" in your case? QuickTime or Preview? Do you get any specific error message? What is the output of `ffmpeg -i
? – slhck Feb 06 '17 at 12:17 -
By "Apple" I meant their file-manager. It would not generate a preview-image from the file. Trying to play the video (by double-clicking) also resulted in an error message. Similarly, iMovie refused to open the file. – Mikhail T. Feb 06 '17 at 20:56
-
There may be something peculiar about your source that makes it fail. Like I said, the command you gave below creates a more or less "legacy" video with bad quality. Let me know what exactly fails and we'll figure it out. – slhck Feb 07 '17 at 08:06
-
Looks like [the FDK-AAC param is now](https://trac.ffmpeg.org/wiki/Encode/AAC) `libfdk_aac` (underscore instead of a dash). – twelve17 Mar 12 '17 at 08:36
-
@twelve17 Thanks. Actually, that was a typo, it's always been with an underscore. – slhck Mar 13 '17 at 09:16
-
-
use VLC instead https://apple.stackexchange.com/questions/230703/how-to-edit-webm-video-files-on-mac – Pavol Travnik May 19 '20 at 18:23
This is, what I just used successfully on FreeBSD to create MP4-files, that MacOS would recognize as such:
ffmpeg -i input_filename -acodec aac -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output_filename.mp4
I started with the command-line using this tutorial, but had change libfaac to aac because the latter was not found...
There must be some special kind of madness affecting programmers in the domain of multimedia codecs, that causes them to subtly change the command-line options from one release to another.
- 53,069
- 19
- 162
- 212
- 634
- 1
- 8
- 27
-
While this creates an MP4 container indeed, your command uses the (old) MPEG-4 Part II codec, which is different from the modern H.264 (see [here](http://stackoverflow.com/questions/10477430/what-is-the-difference-between-h-264-video-and-mpeg-4-video)), which means that your video quality will be lower for any given file size. I would recommend against using this codec. macOS should read H.264 video just fine. You could [ask] a new question, including details on the video you created and your OS, then ping me and I'll have a look why it doesn't work. – slhck Feb 07 '17 at 08:00