This tutorial teaches converting MOV to MP4 using FFmpeg – complete with commandlines, examples, and sample outputs.
People who use Macbooks and Quicktime for video creation often run into the need to convert MOV files to MP4 files. You can buy software for this or use a single line of FFmpeg to quickly convert MOV files to MP4.
In this tutorial, I will show you two simple techniques for converting MOV to MP4 files using FFmpeg
- without re-encoding (copy)
- with re-encoding (lossless, high quality)
Note: You need a MOV file for this tutorial. In case you don’t have a MOV file, you can download a sample from here: https://file-examples.com/index.php/sample-video-files/sample-mov-files-download/
Table of Contents
First, check your audio format Before Converting.
There are a couple of ways to convert a MOV file to MP4 using FFmpeg, but first, you need to inspect your file’s audio format and check if the audio container used by MOV is compatible with MP4 files.
Using ffprobe, type the following at the command line and inspect the output.
./ffprobe -i inputvideo.MOV
If the output contains audio in (HE)-AAC, MPEG-1 Audio Layer 1-2-3, CELP, TwinVQ, Vorbis or Apple Lossless formats, then you are good and can transmux your file to MP4, and they will play back just fine on most machines (Windows, Mac, etc.). To learn more about audio formats, go here.
If the video has an audio format not compatible with MP4, then you may have to re-encode it.
I’ll show you both techniques in this article – no worries 🙂
Convert MOV to MP4 using FFmpeg Without Re-encoding (Transmux)
You can use this technique when your audio and video codecs are compatible with MP4 containers.
Transmux means to convert a file from one container format to another without re-encoding the audio or the video. You copy over the A/V content into a new container.
Video containers – often called formats or wrappers – encapsulate multiple data types into a single file. A video container can hold various data types like compressed video and audio streams, subtitles, metadata, and even codec information. Go to this tutorial to learn more about containers and video codecs.
Converting MOV to MP4 without re-encoding in FFmpeg can be done as follows –
ffmpeg -i file_example_MOV_480_700kB.mov -c copy -movflags +faststart output-mp4.mp4
Here is an explanation of the parameters:-
-i file_example_MOV_480_700kB.mov: The
-iparameter is used to specify the input file.
-c copy: The
-cparameter is shorthand for
copyinstructs FFmpeg to directly copy the existing audio and video streams from the input file to the output file. This is used to avoid quality loss due to encoding or decoding.
-movflags +faststart: The
-movflagsparameter is used to set specific flags for FFmpeg. The
+faststartflag rearranges the metadata of the MP4 file so that it can start playing before it’s fully downloaded when streamed online.
output-mp4.mp4: This is the name of your output file.
Convert MOV to MP4 using FFmpeg with re-encoding.
Use the following command to convert a MOV file to an MP4 file with re-encoding using FFmpeg. This must be done when the audio or video formats are incompatible with the MP4 container format or if you want to change the video or audio quality.
ffmpeg -i input.mov -c:v libx264 -b:v 2M -c:a aac -b:a 128K -movflags +faststart output.mp4
I won’t repeat most of the parameters as we covered them in the previous section. What we are doing here is
- setting the video codec to libx264 for H.264/AVC codec.
-c:a aacto set the audio encoder to AAC
-b:aspecify the video and audio bitrates to 2M and 128k, respectively.
This will re-encode the video with the specified parameters and place it inside an MP4 container.
Convert MOV to MP4 using FFmpeg – High Quality or Lossless
Another option to convert MOV to MP4 with very high quality is to use the CRF parameter during re-encoding. All you need to do is to run this command –
ffmpeg -i input.mov -c:v libx264 -crf 18 -c:a aac -b:a 128K movflags +faststart output.mp4
This sets the CRF value to 18 (What is CRF?) and instructs FFmpeg to produce a video of high quality while using as many bits as possible. If you want to cap the number of bits used (or bitrate), you can use the Capped CRF version of this command by specifying a ceiling for the bitrate along with the desired CRF value.
Go to this post to learn more about CRF, CBR, and capped VBR encoding methods available in FFmpeg.
You now know multiple ways of converting a MOV file to an MP4 file using FFmpeg. But before we end this tutorial, let’s visit the container formats and learn more about them!
What is the MOV container Format?
MOV (QuickTime Movie) is a multimedia container format developed by Apple Inc. It is commonly used for storing video, audio, and text tracks, making it a versatile format for media content. MOV files are widely associated with Apple’s QuickTime software and are known for their high-quality playback and support for various codecs. While MOV files are popular within the Apple ecosystem, they may encounter compatibility issues with specific devices and platforms outside of it.
What is the MP4 container Format?
MP4 (MPEG-4 Part 14) is a widespread multimedia container format that supports video and audio streams. MP4 files are known for their efficient compression and excellent quality, making them ideal for streaming, sharing, and storing media content. In another blog post, we’ll go deep into the structure and format of the MP4 container.
Converting MOV to MP4 using FFmpeg is very easy! You can achieve high-quality results by leveraging the above command line parameters while maintaining compatibility across various devices and platforms.
Until next time, happy streaming, and check out the rest of our FFmpeg tutorials.
Krishna Rao Vijayanagar
Krishna Rao Vijayanagar, Ph.D., is the Editor-in-Chief of OTTVerse, a news portal covering tech and business news in the OTT industry.
With extensive experience in video encoding, streaming, analytics, monetization, end-to-end streaming, and more, Krishna has held multiple leadership roles in R&D, Engineering, and Product at companies such as Harmonic Inc., MediaMelon, and Airtel Digital. Krishna has published numerous articles and research papers and speaks at industry events to share his insights and perspectives on the fundamentals and the future of OTT streaming.