Skip to content

Commit

Permalink
Use video stream fps first in FFmpeg backend for VideoCapture.
Browse files Browse the repository at this point in the history
  • Loading branch information
asmorkalov committed Nov 3, 2023
1 parent ea47cb3 commit e0d72ec
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/videoio/src/cap_ffmpeg_impl.hpp
Expand Up @@ -1877,23 +1877,24 @@ int64_t CvCapture_FFMPEG::get_bitrate() const

double CvCapture_FFMPEG::get_fps() const
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 1, 100) && LIBAVFORMAT_VERSION_MICRO >= 100
double fps = r2d(av_guess_frame_rate(ic, ic->streams[video_stream], NULL));
#else
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0) || LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
double fps = r2d(ic->streams[video_stream]->avg_frame_rate);
#else
double fps = r2d(ic->streams[video_stream]->r_frame_rate);
#endif

#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 1, 100) && LIBAVFORMAT_VERSION_MICRO >= 100
if (fps < eps_zero)
{
fps = r2d(ic->streams[video_stream]->avg_frame_rate);
fps = r2d(av_guess_frame_rate(ic, ic->streams[video_stream], NULL));
}
#endif

if (fps < eps_zero)
{
fps = 1.0 / r2d(ic->streams[video_stream]->time_base);
}
#endif

return fps;
}

Expand Down

0 comments on commit e0d72ec

Please sign in to comment.