Hi Alexandre,<div><br></div><div>thanks for your reply and apologies for the delayed reaction.</div><div>As an experiment, I am first reading through all the packets, so that I know that I have an X number of packets. Each packet has a pts value, from 1 to X.</div>


<div><br></div><div>Later on I would like the user to be able to jump to any packet, and then I need av_seek_frame() to move the header to the right timestamp.  My reasoning to move it to packet Y has been:</div><div><br>

</div><div><font face="courier new, monospace">const int64_t pti = pFormatContext.duration / (int64_t)X; // duration of a packet</font></div><div><font face="courier new, monospace">const int64_t packetTimestamp = Y * pti;</font></div>

<div><font face="courier new, monospace">av_seek_frame(pFormatCtx, videoStream, packetTimestamp * AV_TIME_BASE, backwardFlag).</font></div><div><br></div><div>to test it, I do this in a loop and try to extract the first ten packets and use the </div>

<div><br></div><div><font face="courier new, monospace">avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);</font></div><div><br></div><div>after this I check which packet has been extracted from packet.pts. </div>

<div>At this point, when I do ten times in a row the av_seek_frame() call with X going from 1 to 10, the avcodec_decode_video2() call, the packet.pts that I extract is always the same number (250) and indeed if I print the frame on screen it is always the same frame.</div>

<div><br></div><div>I will keep trying. At the moment I am trying to build this in a JNI environment but I think I'll go to a simple C program to play around with.</div><div><br></div><div>Thank you very much for your attention and help,</div>

<div>Fabio</div><div><br></div><div><br></div><div><br></div><div><div class="gmail_quote">On Mon, Jul 16, 2012 at 3:45 PM, Alexandre Millette <span dir="ltr"><<a href="mailto:amillett@matrox.com" target="_blank">amillett@matrox.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Fabio.<br>
I can't say I have much experience with av_seek_frame(), but since no one else answered you, I might as well try to help.<div><br>
<br>
> Every time a read a packet I can see its position<br>
> in the timeframe with AVPacket.pts.<br>
> Now I am struggling with the seek functionality.<br>
<br></div>
So you are first reading the entire video and storing the pts value for later use?<br>
Because if you have the AVPacket, then you have the encoded frame. The only use of av_seek_frame with pts would be to go back to a packet that you previously read but have since lost.<br>
<br>
> av_seek_frame(pFormatCtx, videoStream, pts, backwardFlag)<br>
<br>
What exactly do you mean when you say that it doesn't work? Does an exception occur? Does the current frame change at all?<br>
av_seek_frame will only move the position of the file reader, meaning that you have to read the packet again and the decode it.<br>
<br>
Also be careful with pts... the doc specifies that it is a timestamp in AVStream->time_base units, but some tutorials (like <a href="http://dranger.com/ffmpeg/tutorial07.html" target="_blank">http://dranger.com/ffmpeg/<u></u>tutorial07.html</a> ) suggest that this timestamp should be multiplied by AV_TIME_BASE.<br>



<br>
I guess a bit more code would be better if you wish for more help.<br>
<br>
Alex M<br>
______________________________<u></u>_________________<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/<u></u>listinfo/libav-user</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><br></div><a href="http://famsterdamlife.com" target="_blank">http://famsterdamlife.com</a><br>
</div>