[Libav-user] Help in understanding seeking behaviour of FFmpeg API on MP4 video with hint tracks
harrison.declan at gmail.com
Sun Apr 19 11:55:36 CEST 2015
I need help understanding the internals of FFmpeg API seek call with
Im using the ffmpeg libav* API in an appliaction that reduces the bitrate
of MP4 files. The output MP4 file has 1 H264 video and 1 AAC audio track.
The application supports seeking on the input file to a specifc video frame
the seek API call.
I added some diagnostics to FFmpeg to help me see what happens during seek
So generally seeking works fine for me. I make seek API call on the video
track to a PTS and the MP4 demuxer
aligns its internal sample index pointers for each track, so the next time
demuxer reads for the next frame, it will
seek to position the file pointer into the required offset to get the
required frame. The behaviour is predicatble
for input files that have audio and video tracks. So ffmpeg may 2 two
phyical file/stream seeks if it need to
locate the correct frame for audio and video.
Posted this originally to ffmpeg-devel, which is the wrong mailing list for
this query so re-posting here. Apoligies for this.
However I have an issue when i Have an input flle with 6 tracks. 1 H264
Video track, 1 AAC audio
track, 2 Hint tracks (one for vidoe and audio), an OD track (has 1 sample)
and a Scenes track (which has 1 sample).
the layout of this file is ftyp-moov-mdat-free-free
When I perform the seek API call this time on this file, the MP4 demuxer as
expected aligns its internal sample index pointer for each track, so the
next time we request a frame from demuxer it will seek to the correct
postiion in the file to get the correct frame.
This works as expected, we seek into the correct location in the file, and
align correctly for each of the other tracks.
Only 4 of the tracks have samples at the desired time, audio, video and
both hint tracks.
So application is able to start demuxing the frames from this seek time
(e.g. 1 second) for
all 4 tracks.
However after reading a certain amount of data another 2 seek requests are
internally by FFmpeg to a position in bothj of the Hint tracks at a time
to the oriignal seek request e.g. 3 seconds.
Im at a loss to explain, why FFmpeg internally needs to perform these 2
seek requests into each of the hint tracks, when no other seek API call is
Surely 1 seek request, results in at maximun 1 seek request per track.
However in this
case I have 2 seeks on the hint tracks. The 'Scene' and 'OD' track dont
have any sample
for this seek location.
Im hoping someone can explain, why this happens and how predictable it is?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user