# User:Mjb/MP4Box

## Contents

This is the GPAC installer. When running the installer, untick every box except the one for MP4Box. On Windows, it will put mp4box.exe and supporting files in your `"%ProgramFiles(x86)%\GPAC"` folder.

## Command-line examples

### Rewrite the PAR (pixel aspect ratio)

My input video was a YouTube rip at 1920×1080, and was 4:3 NTSC TV content that was playing back horizontally stretched. FFmpeg reports it has SAR 1:1 DAR 16:9, i.e. 1920×1080 stored image size @ 1:1 SAR = 1920×1080 displayed image size = 16:9 DAR (display aspect ratio). So I ran it through MP4Box like this:

• `mp4box -add "input.mp4" -par 1=3:4 -new "output.mp4"`

FFmpeg reports output.mp4 has SAR 3:4 DAR 4:3, and indeed it plays back correctly as 4:3. Hooray!

FFmpeg numbers its streams starting with 0, but MP4Box starts at 1, hence the "1=" to say that the new PAR applies to stream 1 of the input.

### PAR calculation

The "3:4" in the example above is calculated thusly:

Given the DAR of 16:9, we need to solve for x and y (the PAR) in this equation:

• ( 16 ⁄ 9 ) × ( xy ) = 4:3

So divide both sides by 16:9:

• ( xy ) = ( 4 ⁄ 3 ) ÷ ( 16 ⁄ 9 )

Division by a fraction is the same thing as multiplication by the inverse of that fraction:

• ( xy ) = ( 4 ⁄ 3 ) × ( 9 ⁄ 16 )

Multiplication of two fractions is a new fraction where the top is the product of the tops, and the bottom is the product of the bottoms:

• ( xy ) = ( 4 × 9 ) ⁄ ( 3 × 16 )
• ( xy ) = 36 ⁄ 48