我有一个 23.98 fps 的视频,这可以从命令行中的 Quicktime 和 ffmpeg 中看到。 OpenCV 错误地认为它有 23 fps。我有兴趣找到一种从 ffmpeg 中找出视频 fps 的编程方式。
最佳答案
使用 FFMPEG-C++ 获取视频每秒帧数 (fps)
/* find first stream */
for(int i=0; i<pAVFormatContext->nb_streams ;i++ )
{
if( pAVFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
/* if video stream found then get the index */
{
VideoStreamIndx = i;
break;
}
}
/* if video stream not availabe */
if((VideoStreamIndx) == -1)
{
std::cout<<"video streams not found"<<std::endl;
return -1;
}
/* get video fps */
double videoFPS = av_q2d(ptrAVFormatContext->streams[VideoStreamIndx]->r_frame_rate);
std::cout<<"fps :"<<videoFPS<<std::endl;
关于c++ - ffmpeg,C++ - 在程序中获取 fps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20638173/