<div dir="ltr">Hi Anton<div><br></div><div>Thanks for your advice, setting to discard to AVDISCARD_ALL, worked a treat for me, thanks.</div><div><br></div><div>Is the libav-user email list active much? When i look i dont see many emails or replies on the archive. Is there an IRC channel for it ?</div><div><br></div><div>Thanks again</div><div>Declan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 19, 2015 at 11:41 AM, Anton Shekhovtsov <span dir="ltr"><<a href="mailto:shekh.anton@gmail.com" target="_blank">shekh.anton@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2015-04-19 12:55 GMT+03:00 declan harrison <span dir="ltr"><<a href="mailto:harrison.declan@gmail.com" target="_blank">harrison.declan@gmail.com</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>I need help understanding the internals of FFmpeg API seek call with certain files.</div><div><br></div><div>Im using the ffmpeg libav* API in an appliaction that reduces the bitrate</div><div>of MP4 files.  The output MP4 file has 1 H264 video and 1 AAC audio track.</div><div><br></div><div>The application supports seeking on the input file to a specifc video frame using</div><div>the seek API call. </div><div><br></div><div>I added some diagnostics to FFmpeg to help me see what happens during seek calls.</div><div><br></div><div>So generally seeking works fine for me. I make seek API call on the video track to a PTS and the MP4 demuxer</div><div>aligns its internal sample index pointers for each track, so the next time demuxer reads for the next frame, it will</div><div>seek to  position the file pointer into the required offset to get the required frame. The behaviour is predicatble</div><div>for input files that have audio and video tracks. So ffmpeg may 2 two phyical file/stream seeks if it need to </div><div>locate the correct frame for audio and video.</div><div>        </div><div>Posted this originally to ffmpeg-devel, which is the wrong mailing list for this query so re-posting here. Apoligies for this.</div><div><br></div><div><br></div><div>However I have an issue when i Have an input flle with 6 tracks. 1 H264 Video track, 1 AAC audio</div><div>track, 2 Hint tracks (one for vidoe and audio), an OD track (has 1 sample) and a Scenes track (which has 1 sample).</div><div><br></div><div>the layout of this file is ftyp-moov-mdat-free-free</div><div><br></div><div>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. </div><div><br></div><div>This works as expected, we seek into the correct  location in the file, and align correctly for each of the other tracks.</div><div>Only 4 of the tracks have samples at the desired time, audio, video and both hint tracks.</div><div><br></div><div>So application is able to start demuxing the frames from this seek time (e.g. 1 second) for</div><div>all 4 tracks. </div><div><br></div><div>However after reading a certain amount of data another 2 seek requests are made </div><div>internally by FFmpeg to a position in bothj of the Hint tracks at a time unrelated</div><div>to the oriignal seek request e.g. 3 seconds.  </div><div><br></div><div>Im at a loss to explain, why FFmpeg internally needs to perform these 2 addiitonal</div><div>seek requests into each of the hint tracks, when no other seek API call is made.</div><div><br></div><div>Surely 1 seek request, results in at maximun 1 seek request per track.  However in this</div><div>case I have 2 seeks on the hint tracks.   The 'Scene'  and 'OD' track dont have any sample</div><div>for this seek location.</div><div><br></div><div>Im hoping someone can explain, why this happens and how predictable it is?</div><div><br></div><div>Thanks</div></div>
<br></div></div>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br><div class="gmail_extra">I failed to fully understand your scenario, but you may want to set discard = AVDISCARD_ALL for streams you dont care about.<br></div>Otherwise,
 if you have stream with only one sample, this effectively means you 
always seek right to the beginning of entire file, so seek is not 
efficient.<br></div></div>
<br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br></div>