c++ - ffmpeg,C++ - 在程序中获取 fps

标签 c++ ffmpeg

我有一个 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/

相关文章:

c++ - 如何通过mongocxx C++驱动上传MongoDB中的文件?

ffmpeg 以高精度获取最后 x 秒

如果目标分辨率大于源,ffmpeg 缩放不起作用

c++ - 初学者在 2D 网格上与 Lee 算法作斗争

c++ - OpenCV:检查像素是否在边界矩形内,由等高线分隔

c++ - 结构中的模板结构问题 -

c++ - 使用 gdb 检测 sh 中的段错误?

OpenCV 不再打开视频文件 VideoCapture

android - JavaCPP BytePointer OutOfMemory 错误

html - 如何使用 Clear Key 加密 webm 文件以使用 Google 的 Shaka Player 播放?