---
title: Using sample atoms
framework: quicktime-file-format
role: article
role_heading: Article
path: quicktime-file-format/using_sample_atoms
---

# Using sample atoms

Find samples or key frames in sample atoms.

## Overview

Overview This section presents examples using the atoms just described. These examples are intended to help you understand the relationships between these atoms. The first section, Finding a sample, describes the steps that the video media handler uses to find the sample that contains the media data for a particular time in a media. The second section, Finding a key frame, describes the steps that the video media handler uses to find an appropriate key frame for a specific time in a movie. Finding a sample When QuickTime displays a movie or track, it directs the appropriate media handler to access the media data for a particular time. The media handler must correctly interpret the data stream to retrieve the requested data. In the case of video media, the media handler traverses several atoms to find the location and size of a sample for a given media time. The media handler performs the following steps: Determines the time in the media time coordinate system. Examines the time-to-sample atom to determine the sample number that contains the data for the specified time. Scans the sample-to-chunk atom to discover which chunk contains the sample in question. Extracts the offset to the chunk from the chunk offset atom. Finds the offset within the chunk and the sample’s size by using the sample size atom. Finding a key frame Finding a key frame for a specified time in a movie is slightly more complicated than finding a sample for a specified time. The media handler must use the sync sample atom and the time-to-sample atom together in order to find a key frame. The media handler performs the following steps: Examines the time-to-sample atom to determine the sample number that contains the data for the specified time. Scans the sync sample atom to find the key frame that precedes the sample number chosen in step 1. Scans the sample-to-chunk atom to discover which chunk contains the key frame. Extracts the offset to the chunk from the chunk offset atom. Finds the offset within the chunk and the sample’s size by using the sample size atom.

## See Also

### Describing samples

- [Sample table atom ('stbl')](quicktime-file-format/sample_table_atom.md)
- [Seeking with a QuickTime file](quicktime-file-format/seeking_with_a_quicktime_file.md)
- [Sample description atom ('stsd')](quicktime-file-format/sample_description_atom.md)
- [Time-to-sample atom ('stts')](quicktime-file-format/time-to-sample_atom.md)
- [Creating video tracks at 30 frames per second](quicktime-file-format/creating_video_tracks_at_30_frames_per_second.md)
- [Creating video tracks at 29.97 frames per second](quicktime-file-format/creating_video_tracks_at_2997_frames_per_second.md)
- [Creating sound tracks at 44.1 kHz](quicktime-file-format/creating_sound_tracks_at_441_khz.md)
- [Composition offset atom ('ctts')](quicktime-file-format/composition_offset_atom.md)
- [Composition shift least greatest atom ('cslg')](quicktime-file-format/composition_shift_least_greatest_atom.md)
- [Using composition offset and composition shift least greatest atoms](quicktime-file-format/using_composition_offset_and_composition_shift_least_greatest_atoms.md)
- [Sync sample atom ('stss')](quicktime-file-format/sync_sample_atom.md)
- [Partial sync sample atom ('stps')](quicktime-file-format/partial_sync_sample_atom.md)
- [Sample-to-chunk atom ('stsc')](quicktime-file-format/sample-to-chunk_atom.md)
- [Referencing two data files with a single track](quicktime-file-format/referencing_two_data_files_with_a_single_track.md)
- [Sample size atom ('stsz')](quicktime-file-format/sample_size_atom.md)
