<div dir="ltr">Hi All,<div><br></div><div>I am decoding some MPEG-2 and H264 streams from file and have a problem getting the correct duration of a frame. Some files are MPEG2 transport streams while other are wrapped in mp4 or MOV container.</div>
<div><br></div><div>I use the following section of code </div>
<div> pFrame is the input AVFrame after decoding</div><div><br></div><div><div> AVStream *pStream = pCtx->pFormatCtx->streams[pCtx->activeVideoStream];</div><div> double time_base = av_q2d(pStream->time_base);</div>
<div> double duration = time_base * av_frame_get_pkt_duration(pFrame);</div>
<div> duration += duration * (pFrame->repeat_pict / 2);</div><div><br></div><div>My problem is that for alot of streams this works while for others streams the duration needs to be multipled by 2 for the timing to work correctly...even though repeat_pic is 0. I checked interlace flag but in the files that I had the problem, they are both interlaced.</div>
<div><br></div><div>What timebase is the correct timebase to use? The codec timebase or the stream timebase?</div><div><br></div><div>How do I correctly get the duration of a frame regardless of the type of file and the encoding parameters that were used?</div>
<div><br></div><div>Thanks much for your help!</div><div><br></div></div></div>