Configure MP4 Major and Compatible Brands in FFmpeg

This article provides a straightforward guide on how to configure the major brand and compatible brands in the MP4 muxer using FFmpeg. You will learn the specific command-line flags required to define these metadata tags, enabling you to customize file compatibility and ensure seamless playback across various devices and media players.

Understanding MP4 Brands

Every MP4 file contains a File Type Box (ftyp) at the beginning of the file. This box identifies the specifications to which the file complies. It consists of: * Major Brand: The primary container specification used to package the file (e.g., isom, mp42, m4v). * Minor Version: The version of the major brand. * Compatible Brands: A list of alternative specifications with which the file is compatible, allowing wider playback support.

By default, FFmpeg automatically assigns these brands based on the codecs and options you select. However, you can manually override them for specialized workflows.

How to Set the Major Brand

To configure the major brand in FFmpeg, use the -brand muxer option followed by the four-character brand identifier.

Here is the basic command template:

ffmpeg -i input.mov -c:v libx264 -c:a aac -brand mp42 output.mp4

In this example, -brand mp42 explicitly forces the major brand of the output MP4 container to be mp42 (MP4 Base Media v2).

How to Set Compatible Brands

To define the list of compatible brands, use the -compatible_brands option. You must pass the brands as a comma-separated list of four-character codes without spaces.

ffmpeg -i input.mov -c:v libx264 -c:a aac -brand mp42 -compatible_brands isom,mp42,avc1 output.mp4

In this command: * -brand mp42 sets the primary container brand. * -compatible_brands isom,mp42,avc1 declares compatibility with the ISO Base Media file format (isom), MP4 Base Media v2 (mp42), and Advanced Video Coding (avc1).

Verifying the Changes

After muxing the file, you can verify that the brands were successfully applied.

Using FFprobe

Run the following command to inspect the format metadata:

ffprobe -v error -show_entries format=format_name,format_long_name -of default=noprint_wrappers=1 input.mp4

Using MediaInfo

For a detailed look at the ftyp box, use the third-party tool MediaInfo:

mediainfo output.mp4 | grep "Codec ID"

This will display the “Codec ID” (which represents the major brand) and the “Compatible codecs” list.