[Libav-user] MP4 files and avio_seek()

Williams, Blake bwilliams at drs.com
Wed May 18 23:22:59 CEST 2016


I'm trying to seek to a byte offset in an MP4 file.  I can't use avformat_seek_file() because the AVFMT_NO_BYTE_SEEK flag is set in the demuxer.

I'm reading the first 150 frames in the file, then seeking to a known file location.  I've been able to use avio_seek to set the m_pFormatCtx->pb->pos value to the correct offset, but the next call to av_read_frame() puts it right back to where it was, such that the next frame read is #151.  The seek code is:

                     int64_t filePos = m_posData.GetFrameOffset(frameNum);
                     int64_t ret = avio_seek(m_pFormatCtx->pb, filePos, SEEK_SET);
                     avformat_flush(m_pFormatCtx);
                     avcodec_flush_buffers(m_pVideoCodecCtx);
                     avcodec_flush_buffers(m_pAudioCodecCtx);

Is there something else that needs to be called to actually clear up the internal buffers so that av_read_frame will start at the correct location?

Thanks,
Blake


Blake Williams
Principal Software Engineer, Training and Control Systems
DRS Technologies, Inc.

[Final-New-DRS-Color.png]

645 Anchors Street
Fort Walton Beach, Florida 32548
Tel: 850.302-3281
 bwilliams at drs.com<mailto:CKuypers at DRS-DS.com>  || www.drs.com<http://www.drs.com/>

This communication is intended only for use by the addressee(s) named herein and may contain business proprietary and/or legally privileged information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution, disclosure or copying of this e-mail and its contents is strictly prohibited. If you have received this e-mail in error, kindly notify the sender by replying to this message. In addition, please permanently delete the message and any attachments without copying or disclosing the contents. Thank you for your cooperation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160518/6aadf9d4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 18844 bytes
Desc: image002.png
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160518/6aadf9d4/attachment.png>


More information about the Libav-user mailing list