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:
- 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.
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)?