Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Media Atoms

Media atoms describe and define a track’s media type and sample data. The media atom contains information that specifies the media type, such as sound or video, the media handler component used to interpret the sample data, the media timescale and track duration, and media-and-track-specific information such as sound volume or graphics mode. It also contains the media data references, which typically specify the file where the sample data is stored, and the sample table atoms, which specify the sample description, duration, and byte offset from the data reference for each media sample.

The media atom has an atom type of 'mdia'. It must contain a media header atom ('mdhd'), and it can contain a handler reference ('hdlr') atom, media information ('minf') atom, and user data ('udta') atom.

Note: Do not confuse the media atom ('mdia') with the media data atom ('mdat'). The media atom contains only references to media data; the media data atom contains the actual media samples.

Figure 2-15 shows the layout of a media atom.


Figure 2-15  The layout of a media atom

The layout of a media atom

Media atoms contain the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this media atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'mdia'.

Media header atom

This atom contains the standard media information. See “Media Header Atoms.”

Handler reference atom

This atom identifies the media handler component that is to be used to interpret the media data. See “Handler Reference Atoms” for more information.

Note that the handler reference atom tells you the kind of media this media atom contains—for example, video or sound. The layout of the media information atom is specific to the media handler that is to interpret the media. “Media Information Atoms” discusses how data may be stored in a media, using the video media format defined by Apple as an example.

Media information atom

This atom contains data specific to the media type for use by the media handler component. See “Media Information Atoms.”

User data atom

See “User Data Atoms.”

Media Header Atoms

The media header atom specifies the characteristics of a media, including time scale and duration. The media header atom has an atom type of 'mdhd'.

Figure 2-16 shows the layout of the media header atom.


Figure 2-16  The layout of a media header atom

The layout of a media header atom

Media header atoms contain the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this media header atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'mdhd'.

Version

One byte that specifies the version of this header atom.

Flags

Three bytes of space for media header flags. Set this field to 0.

Creation time

A 32-bit integer that specifies (in seconds since midnight, January 1, 1904) when the media atom was created. It is strongly recommended that this value should be specified using coordinated universal time (UTC).

Modification time

A 32-bit integer that specifies (in seconds since midnight, January 1, 1904) when the media atom was changed. It is strongly recommended that this value should be specified using coordinated universal time (UTC).

Time scale

A time value that indicates the time scale for this media—that is, the number of time units that pass per second in its time coordinate system.

Duration

The duration of this media in units of its time scale.

Language

A 16-bit integer that specifies the language code for this media. See “Language Code Values” for valid language codes.

Quality

A 16-bit integer that specifies the media’s playback quality—that is, its suitability for playback in a given environment.

Handler Reference Atoms

The handler reference atom specifies the media handler component that is to be used to interpret the media’s data. The handler reference atom has an atom type value of 'hdlr'.

Historically, the handler reference atom was also used for data references. However, this use may now be ignored.

The handler atom within a media atom declares the process by which the media data in the stream may be presented, and thus, the nature of the media in a stream. For example, a video handler would handle a video track.

Figure 2-17 shows the layout of a handler reference atom.


Figure 2-17  The layout of a handler reference atom

The layout of a handler reference atom

Handler reference atoms contain the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this handler reference atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'hdlr'.

Version

A 1-byte specification of the version of this handler information.

Flags

A 3-byte space for handler information flags. Set this field to 0.

Component type

A four-character code that identifies the type of the handler. Only two values are valid for this field: 'mhlr' for media handlers and 'dhlr' for data handlers.

Component subtype

A four-character code that identifies the type of the media handler or data handler. For media handlers, this field defines the type of data—for example, 'vide' for video data or 'soun' for sound data.

For data handlers, this field defines the data reference type—for example, a component subtype value of 'alis' identifies a file alias.

Component manufacturer

Reserved. Set to 0.

Component flags

Reserved. Set to 0.

Component flags mask

Reserved. Set to 0.

Component name

A (counted) string that specifies the name of the component—that is, the media handler used when this media was created. This field may contain a zero-length (empty) string.

Media Information Atoms

Media information atoms (defined by the 'minf' atom type) store handler-specific information for a track’s media data. The media handler uses this information to map from media time to media data and to process the media data.

These atoms contain information that is specific to the type of data defined by the media. Further, the format and content of media information atoms are dictated by the media handler that is responsible for interpreting the media data stream. Another media handler would not know how to interpret this information.

This section describes the atoms that store media information for the video ('vmhd'), sound ('smhd'), and base ('gmhd') portions of QuickTime movies.

Note: “Using Sample Atoms” discusses how the video media handler locates samples in a video media.

Video Media Information Atoms

Video media information atoms are the highest-level atoms in video media. These atoms contain a number of other atoms that define specific characteristics of the video media data. Figure 2-18 shows the layout of a video media information atom.


Figure 2-18  The layout of a media information atom for video

The layout of a media information atom for video

The video media information atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this video media information atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'minf'.

Video media information atom

See “Video Media Information Header Atoms.”

Handler reference atom

See “Handler Reference Atoms.”

Data information atom

See “Data Information Atoms.”

Sample table atom

See “Sample Table Atoms.”

Video Media Information Header Atoms

Video media information header atoms define specific color and graphics mode information.

Figure 2-19 shows the structure of a video media information header atom.


Figure 2-19  The layout of a media information header atom for video

The layout of a media information header atom for video

The video media information header atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this video media information header atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'vmhd'.

Version

A 1-byte specification of the version of this video media information header atom.

Flags

A 3-byte space for video media information flags. There is one defined flag.

No lean ahead

This is a compatibility flag that allows QuickTime to distinguish between movies created with QuickTime 1.0 and newer movies. You should always set this flag to 1, unless you are creating a movie intended for playback using version 1.0 of QuickTime. This flag’s value is 0x0001.

Graphics mode

A 16-bit integer that specifies the transfer mode. The transfer mode specifies which Boolean operation QuickDraw should perform when drawing or transferring an image from one location to another. See “Graphics Modes” for a list of graphics modes supported by QuickTime.

Opcolor

Three 16-bit values that specify the red, green, and blue colors for the transfer mode operation indicated in the graphics mode field.

Sound Media Information Atoms

Sound media information atoms are the highest-level atoms in sound media. These atoms contain a number of other atoms that define specific characteristics of the sound media data. Figure 2-20 shows the layout of a sound media information atom.


Figure 2-20  The layout of a media information atom for sound

The layout of a media information atom for sound

The sound media information atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this sound media information atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'minf'.

Sound media information header atom

See “Sound Media Information Header Atoms.”

Handler reference atom

See “Handler Reference Atoms.”

Data information atom

See “Data Information Atoms.”

Sample table atom

See “Sample Table Atoms.”

Sound Media Information Header Atoms

The sound media information header atom (shown in Figure 2-21) stores the sound media’s control information, such as balance.


Figure 2-21  The layout of a sound media information header atom

The layout of a sound media information header atom

The sound media information header atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this sound media information header atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'smhd'.

Version

A 1-byte specification of the version of this sound media information header atom.

Flags

A 3-byte space for sound media information flags. Set this field to 0.

Balance

A 16-bit integer that specifies the sound balance of this sound media. Sound balance is the setting that controls the mix of sound between the two speakers of a computer. This field is normally set to 0. See “Balance” for more information about balance values.

Reserved

Reserved for use by Apple. Set this field to 0.

Base Media Information Atoms

The base media information atom (shown in Figure 2-22) stores the media information for media types such as text, MPEG, time code, and music.

Media types that are derived from the base media handler may add other atoms within the base media information atom, as appropriate. At present, the only media type that defines any additional atoms is the timecode media. See “Timecode Media Information Atom” for more information about timecode media.


Figure 2-22  The layout of a base media information atom

The layout of a base media information atom

The base media information atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this base media information atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'minf'.

Base media information header atom

See “Base Media Information Header Atoms.”

Base media info atom

See “Base Media Info Atoms.”

Base Media Information Header Atoms

The base media information header atom indicates that this media information atom pertains to a base media.

The base media information header atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this base media information header atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'gmhd'.

Base Media Info Atoms

The base media info atom, contained in the base media information atom, defines the media’s control information, including graphics mode and balance information.

Figure 2-23 shows the layout of the base media info atom.


Figure 2-23  The layout of a base media info atom

The layout of a base media info atom

The base media info atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this base media info atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'gmin'.

Version

A 1-byte specification of the version of this base media information header atom.

Flags

A 3-byte space for base media information flags. Set this field to 0.

Graphics mode

A 16-bit integer that specifies the transfer mode. The transfer mode specifies which Boolean operation QuickDraw should perform when drawing or transferring an image from one location to another. See “Graphics Modes” for more information about graphics modes supported by QuickTime.

Opcolor

Three 16-bit values that specify the red, green, and blue colors for the transfer mode operation indicated in the graphics mode field.

Balance

A 16-bit integer that specifies the sound balance of this media. Sound balance is the setting that controls the mix of sound between the two speakers of a computer. This field is normally set to 0. See “Balance” for more information about balance values.

Reserved

Reserved for use by Apple. Set this field to 0.

Data Information Atoms

The handler reference atom (described in “Handler Reference Atoms”) contains information specifying the data handler component that provides access to the media data. The data handler component uses the data information atom to interpret the media’s data. Data information atoms have an atom type value of 'dinf'.

Figure 2-24 shows the layout of the data information atom.


Figure 2-24  The layout of a data information atom

The layout of a data information atom

The data information atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this data information atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'dinf'.

Data reference atom

See “Data Reference Atoms.”

Data Reference Atoms

Data reference atoms contain tabular data that instructs the data handler component how to access the media’s data. Figure 2-24 shows the data reference atom.

The data reference atom contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in this data reference atom.

Type

A 32-bit integer that identifies the atom type; this field must be set to 'dref'.

Version

A 1-byte specification of the version of this data reference atom.

Flags

A 3-byte space for data reference flags. Set this field to 0.

Number of entries

A 32-bit integer containing the count of data references that follow.

Data references

An array of data references.

Each data reference is formatted like an atom and contains the following data elements.

Size

A 32-bit integer that specifies the number of bytes in the data reference.

Type

A 32-bit integer that specifies the type of the data in the data reference. Table 2-4 lists valid type values.

Version

A 1-byte specification of the version of the data reference.

Flags

A 3-byte space for data reference flags. There is one defined flag.

Self reference

This flag indicates that the media’s data is in the same file as the movie atom. On the Macintosh, and other file systems with multifork files, set this flag to 1 even if the data resides in a different fork from the movie atom. This flag’s value is 0x0001.

Data

The data reference information.

Table 2-4 shows the currently defined data reference types that may be stored in a header atom.

Table 2-4  Data reference types

Data reference type

Description

'alis'

Data reference is a Macintosh alias. An alias contains information about the file, including its full path name.

'rsrc'

Data reference is a Macintosh alias. Appended to the end of the alias is the resource type (stored as a 32-bit integer) and ID (stored as a 16-bit signed integer) to use within the specified file.

'url '

A C string that specifies a URL. There may be additional data after the C string.



< Previous PageNext Page > Hide TOC


Last updated: 2007-09-04




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice