On Fri, Jul 10, 2009 at 11:36 PM, d3fault <[email protected]> wrote:
> How do I get libav to tell me the fps for an input file? Currently, I'm
> using:
> double fps =
> av_q2d(inputFormatCtx->streams[videoStreamIndex]->r_frame_rate);
> but it seems to be an unreliable way to get it. Windows Media Video files
> report 1000fps, certain mpeg videos report double their own fps, etc...
> Am I missing something obvious?
>
>
I'm not sure that my solution can solve the "full" problem related to
frame-rate but i have meet the same and solve it in the following way
libav provide the fps in 2 ways, 1) in the stream infos, 2) in the codecs
infos. The position of the "good" informations depends of container
(avi/wmv,...) and/or codec (mpg2, vc1, ...)
To solve this issue, i have use the code below. Good Luck
Alex.
#ifdef _TRACE_STDOUT_
fprintf(stdout, "STREAM TIME BASE%d - FPS : %d / %d \n",
ParentFilter->AVVideoStreamIndex,
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->time_base.num,
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->time_base.den);
fprintf(stdout, "STREAM R_FRAMERATE %d - FPS : %d / %d \n",
ParentFilter->AVVideoStreamIndex,
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->r_frame_rate.num,
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->r_frame_rate.den);
fprintf(stdout, "CODEC %d - FPS : %d / %d \n",
ParentFilter->AVVideoStreamIndex,
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->codec->time_base.num,
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->codec->time_base.den);
#endif
if
(ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->time_base.den
!=
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->r_frame_rate.num
||
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->time_base.num
!=
ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->r_frame_rate.den){
pVo->AvgTimePerFrame =
(((double)(ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->r_frame_rate.den))
/((double)(ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->r_frame_rate.num)))*10000000;
} else {
pVo->AvgTimePerFrame =
(((double)(ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->time_base.num))
/((double)(ParentFilter->AVInputContext->streams[ParentFilter->AVVideoStreamIndex]->time_base.den)))*10000000;
}
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user