Question

The quicktime documentation recommends the following approach to finding a keyframe:

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:

  1. Examines the time-to-sample atom to determine the sample number that contains the data for the specified time.
  2. Scans the sync sample atom to find the key frame that precedes the sample number chosen in step 1.
  3. Scans the sample-to-chunk atom to discover which chunk contains the key frame.
  4. Extracts the offset to the chunk from the chunk offset atom.
  5. Finds the offset within the chunk and the sample’s size by using the sample size atom.

source: https://developer.apple.com/library/mac/documentation/QuickTime/qtff/QTFFChap2/qtff2.html

This is quite confusing, since multiple tracks ("trak" atom) will yield different offsets. For example, the keyframe-sample-chunk-offset value for the video trak will be one value, and the audio will be another.

How does one translate the instructions above into a location in the file (or mdat atom)?

No correct solution

OTHER TIPS

That's not restricted to key frames. You can't in general guarantee that samples for different tracks are close to each other in the file. You hope that audio and video will be interleaved so you can play back a movie without excessive seeking but that's up to the software that created the file. Each track has its own sample table and chunk atoms that tell you where the samples are in the file and they could be anywhere. (They could even be in a different file, though reference movies are deprecated nowadays so you can probably ignore them.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top