Hi Vahid:
perhaps you need to take into account pStream->codec.time_base and pStream->codec.ticks_per_frame. I believe that pStream->time_base matches to frame rate for interleaved video streams, whereas pStream->codec.time_base matches to field rate. E.g. for 25fps interleaved stream you will get time_base=1/25 but codec.time_base=1/50 and codec.ticks_per_frame==2. Sincerely, LM From: [email protected] [mailto:[email protected]] On Behalf Of Vahid Kowsari Sent: Monday, July 08, 2013 3:02 AM To: [email protected] Subject: [Libav-user] Getting frame duration when decoding Hi All, 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. I use the following section of code pFrame is the input AVFrame after decoding AVStream *pStream = pCtx->pFormatCtx->streams[pCtx->activeVideoStream]; double time_base = av_q2d(pStream->time_base); double duration = time_base * av_frame_get_pkt_duration(pFrame); duration += duration * (pFrame->repeat_pict / 2); 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. What timebase is the correct timebase to use? The codec timebase or the stream timebase? How do I correctly get the duration of a frame regardless of the type of file and the encoding parameters that were used? Thanks much for your help!
_______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
