MP4(3)

NAME

MP4Optimize - Optimize the layout of an mp4 file

SYNTAX

#include <mp4.h>

bool MP4Optimize(
    const char* existingfileName,
    const char* newfileName = NULL,
    u_int32_t verbosity = 0
);

ARGUMENTS

existingFileName
    Specifies the path name of the existing file to be optimized.

newFileName
    Specifies the path name of the new, optimized file. If NULL, then a temporary file is used, and the existing file is overwritten upon successful completion.

verbosity
    Specifies a bitmask of diagnostic details the library should print to stdout during its functioning. See MP4SetVerbosity() for values.

RETURN VALUES

Upon success, true (1). Upon an error, false (0).

DESCRIPTION

MP4Optimize reads an existing mp4 file and writes a new version of the file with the two important changes:

First, the mp4 control information is moved to the beginning of the file. (Frequenty it is at the end of the file due to it being constantly modified as track samples are added to an mp4 file.) This optimization is useful in that in allows the mp4 file to be HTTP streamed.

Second, the track samples are interleaved so that the samples for a particular instant in time are colocated within the file. This eliminates disk seeks during playback of the file which results in better performance.

There are also two important side effects of MP4Optimize():

First, any free blocks within the mp4 file are eliminated.

Second, as a side effect of the sample interleaving process any media data chunks that are not actually referenced by the mp4 control structures are deleted. This is useful if you have called MP4DeleteTrack() which only deletes the control information for a track, and not the actual media data.

SEE ALSO

MP4(3)