<div dir="ltr">Hi Alex,<div><br></div><div>Seems I couldn't find the source code of <span style="font-family:arial,sans-serif;font-size:14px">av_frame_get_best_effort_</span><span style="font-family:arial,sans-serif;font-size:14px">timestamp, so I have to ask here, because I found that ffmpeg 1.1.3 return -1 for every frame of same file. </span></div>
<div><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14px">So definitely </span></div><div><span style="font-family:arial,sans-serif;font-size:14px">int64_t position = </span><span style="font-family:arial,sans-serif;font-size:14px">av_frame_get_best_effort_</span><span style="font-family:arial,sans-serif;font-size:14px">timestamp(pFrame);</span></div>
<div><span style="font-family:arial,sans-serif;font-size:14px">if ((position != AV_NOPTS_VALUE) && (position >=0)) </span></div><div><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div>
<span style="font-family:arial,sans-serif;font-size:14px">is needed to check if best effort timestamp is valid, but I'd like to know if it's enough.</span></div><div><span style="font-family:arial,sans-serif;font-size:14px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:14px">As you can see in ffmpeg2.0.1 (with which </span><span style="font-family:arial,sans-serif;font-size:14px">av_frame_get_best_effort_</span><span style="font-family:arial,sans-serif;font-size:14px">timestamp returns correct value</span><span style="font-family:arial,sans-serif;font-size:14px">) the best effort time stamp returned equals to </span><span style="font-family:arial,sans-serif;font-size:14px"> </span><span style="font-family:arial,sans-serif;font-size:14px">frame.pkt_dts, that's ok.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14px">But if it's possible, for exmpale, </span><span style="font-family:arial,sans-serif;font-size:14px">av_frame_get_best_effort_</span><span style="font-family:arial,sans-serif;font-size:14px">timestamp returns all 0 for every frame?</span></div>
<div><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14px">So in summary I'd like to know on what condition can I totally trust time stamp returned by this function (so I can forget about those packet.dts, packet.pts, frame.pkt_dts)</span></div>
<div><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:14px">Thanks!</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/10/30 YIRAN LI <span dir="ltr"><<a href="mailto:mrfun.china@gmail.com" target="_blank">mrfun.china@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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="HOEnZb"><div class="h5"><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><div>On Wed, Oct 30, 2013 at 5:51 AM, YIRAN LI <<a href="mailto:mrfun.china@gmail.com" target="_blank">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" 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>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>