<div dir="ltr">Thanks Alex,<div><br></div><div>I just had a quick check, called av_frame_get_best_effort_timestamp(pFrame); and seems pFrame->best_effort_timestamp was filled with desired values (1st frame having 0, 2nd having 1 and so on).</div>
<div><br></div><div>I'll read through the link you gave me later on.</div><div><br></div><div>Great Thanks!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/30 Alex Cohn <span dir="ltr"><<a href="mailto:alexcohn@netvision.net.il" target="_blank">alexcohn@netvision.net.il</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Oct 30, 2013 at 5:51 AM, YIRAN LI <<a href="mailto:mrfun.china@gmail.com">mrfun.china@gmail.com</a>> wrote:<br>

><br>
> Hi friends,<br>
><br>
> Here I have a question about AVFrame pts needs your help.<br>
><br>
> My application uses av_read_frame to get packets and then calls  avcodec_decode_video2 to get video frames. But recently I found one specific video file generates strange pts/dts.<br>
><br>
> Below is a part of the log:<br>
><br>
> 00:00:17.301  MAIN  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 0<br>
> 00:00:17.301  MAIN  timestamp_debug:            frame.pkt_pts = -9223372036854775808, frame.pkt_dts = -9223372036854775808, frame.pts = -9223372036854775808<br>
> 00:00:17.301  1108  FFMPEG: looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag<br>
><br>
> 00:00:17.301  MAIN  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 1<br>
> 00:00:17.301  MAIN  timestamp_debug:            frame.pkt_pts = -9223372036854775808, frame.pkt_dts = -9223372036854775808, frame.pts = -9223372036854775808<br>
> 00:00:17.301  MAIN  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 2<br>
> 00:00:17.301  MAIN  timestamp_debug:            frame.pkt_pts = -9223372036854775808, frame.pkt_dts = -9223372036854775808, frame.pts = -9223372036854775808<br>
> 00:00:17.301  MAIN  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 3<br>
> 00:00:17.301  MAIN  timestamp_debug:            frame.pkt_pts = -9223372036854775808, frame.pkt_dts = -9223372036854775808, frame.pts = -9223372036854775808<br>
> 00:00:17.301  MAIN  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 4<br>
> 00:00:17.301  MAIN  timestamp_debug:  [a full frame : frame.pkt_pts = -9223372036854775808, frame.pkt_dts = 0], frame.pts = 0<br>
> 00:00:18.393  LVid236  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 5<br>
> 00:00:18.408  LVid236  timestamp_debug:  [a full frame : frame.pkt_pts = -9223372036854775808, frame.pkt_dts = 1], frame.pts = 0<br>
> 00:00:18.439  LVid236  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 6<br>
> 00:00:18.439  LVid236  timestamp_debug:  [a full frame : frame.pkt_pts = -9223372036854775808, frame.pkt_dts = 2], frame.pts = 0<br>
> 00:00:18.439  LSou259  FFMPEG: first_dts 0 not matching first dts 113424 in the queue<br>
> 00:00:18.486  LVid236  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 7<br>
> 00:00:18.486  LVid236  timestamp_debug:  [a full frame : frame.pkt_pts = -9223372036854775808, frame.pkt_dts = 3], frame.pts = 0<br>
> 00:00:18.517  LVid236  timestamp_debug:  pkt.pts = -9223372036854775808, dts = 8<br>
> 00:00:18.517  LVid236  timestamp_debug:  [a full frame : frame.pkt_pts = -9223372036854775808, frame.pkt_dts = 4], frame.pts = 0<br>
> 00:00:18.549  LSou259  FFMPEG: first_dts 0 not matching first dts 114675 in the queue<br>
><br>
> We can see that, it was until 4th packet is sent to decode function that we got the first full frame. and all frames had pts = 0<br>
><br>
> So here I want to know, frame.pts, frame.pkt_dts, packet,dts. which is best to represent the time stamp of a video frame (I mean pts, but in this case, no pts is valid).<br>
><br>
> For example, in this case, for the 1st frame, should I use frame.pkt_dts (that's 0), or pkt.pts (the last packet that generates this frame, in this case 4) as the time  position<br>
> of the frame?<br>
><br>
> The file I used to test is here <a href="https://dl.dropboxusercontent.com/u/89678527/av_divx_24_yuv420p_mp3_44100_2_1.avi" target="_blank">https://dl.dropboxusercontent.com/u/89678527/av_divx_24_yuv420p_mp3_44100_2_1.avi</a><br>

><br>
> Thanks<br>
<br>
<br>
</div></div>That's what best_effort_timestamp is for. See<br>
<a href="http://dranger.com/ffmpeg/tutorial05.html" target="_blank">http://dranger.com/ffmpeg/tutorial05.html</a> about different values of<br>
pts/dts.<br>
<br>
BR,<br>
Alex Cohn<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>
</blockquote></div><br></div>