Skip to content
DeveloperMemos

Converting a MOV File to MP4 with FFmpeg

FFmpeg, Video Conversion, MOV, MP42 min read

Whether you're editing videos or preparing them for online streaming, converting video files from one format to another is a common task. In this article, we'll explore the process of converting MOV files to the more widely supported MP4 format using FFmpeg. By following these steps, you'll be able to leverage FFmpeg's capabilities for efficient and high-quality video conversion.

What is FFmpeg?

FFmpeg is a versatile and cross-platform command-line tool used for handling multimedia data. It supports various audio and video formats, codecs, and filters, making it a popular choice for media professionals and enthusiasts alike. One of its strengths is its ability to perform complex video manipulation tasks, including file conversion, compression, resizing, and more.

Installing FFmpeg

Before we dive into converting MOV files to MP4, let's ensure that FFmpeg is installed on your system. The installation process varies depending on your operating system, so make sure to follow the instructions appropriate for your platform. FFmpeg can be installed on Windows, macOS, and Linux distributions. You can find official installation guides and pre-built binaries on the FFmpeg website.

Converting MOV to MP4

Once you have FFmpeg installed, open a terminal or command prompt to begin the conversion process. Use the following command to convert a MOV file to MP4:

1ffmpeg -i input.mov -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output.mp4

Let's break down the options used in the command:

  • -i input.mov: Specifies the input file (replace input.mov with the actual path to your MOV file).
  • -c:v libx264: Sets the video codec to H.264, which provides good quality compression.
  • -preset slow: Adjusts the encoding speed and quality trade-off. Using slow produces better quality output but takes more time. You can experiment with other presets like medium, fast, or veryfast based on your requirements.
  • -crf 22: Controls the video quality. Lower values result in higher quality but larger file sizes. The range typically used is 18-28, with 23 being a reasonable default.
  • -c:a aac -b:a 128k: Specifies the audio codec as AAC with a bitrate of 128 kbps.
  • output.mp4: Defines the output file name and format. Replace output.mp4 with the desired name for your MP4 file.

Once you've entered the command with the appropriate file paths and settings, press Enter to initiate the conversion process. FFmpeg will display progress information, including the input file's duration, bitrates, and output file details.

Additional Options

FFmpeg offers a wide range of additional options and filters to further customize your video conversion. Here are a few examples:

Changing Video Resolution

To resize the video while converting, use the -vf option followed by the desired width and height. For example, to resize the video to a resolution of 1280x720 pixels:

1ffmpeg -i input.mov -c:v libx264 -preset slow -crf 22 -vf "scale=1280:720" -c:a aac -b:a 128k output.mp4

Trimming Video Duration

To trim the video and extract a specific portion, use the -ss option to specify the start time and -t to define the duration in seconds. The following example trims the first 10 seconds of the video:

1ffmpeg -i input.mov -ss 00:00:00 -t 10 -c:v libx264 -preset slow -crf 22 -c:a aac -b:a 128k output.mp4