mirror of
https://github.com/opencv/opencv.git
synced 2024-12-18 11:28:02 +08:00
Merge pull request #24492 from asmorkalov:as/reprioritize_fps_source_ffmpeg
Use video stream fps first in FFmpeg backend for VideoCapture
This commit is contained in:
commit
ceebfa1bee
@ -1877,15 +1877,16 @@ int64_t CvCapture_FFMPEG::get_bitrate() const
|
|||||||
|
|
||||||
double CvCapture_FFMPEG::get_fps() const
|
double CvCapture_FFMPEG::get_fps() const
|
||||||
{
|
{
|
||||||
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 1, 100) && LIBAVFORMAT_VERSION_MICRO >= 100
|
#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(54, 1, 0) || LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
|
||||||
double fps = r2d(av_guess_frame_rate(ic, ic->streams[video_stream], NULL));
|
|
||||||
#else
|
|
||||||
double fps = r2d(ic->streams[video_stream]->avg_frame_rate);
|
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)
|
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
|
#endif
|
||||||
|
|
||||||
@ -1893,7 +1894,7 @@ double CvCapture_FFMPEG::get_fps() const
|
|||||||
{
|
{
|
||||||
fps = 1.0 / r2d(ic->streams[video_stream]->time_base);
|
fps = 1.0 / r2d(ic->streams[video_stream]->time_base);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return fps;
|
return fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ TEST_P(videoio_encapsulate, write)
|
|||||||
ASSERT_TRUE(capActualRaw.isOpened());
|
ASSERT_TRUE(capActualRaw.isOpened());
|
||||||
const double fpsReference = capReference.get(CAP_PROP_FPS);
|
const double fpsReference = capReference.get(CAP_PROP_FPS);
|
||||||
const double fpsActual = capActual.get(CAP_PROP_FPS);
|
const double fpsActual = capActual.get(CAP_PROP_FPS);
|
||||||
ASSERT_EQ(fpsReference, fpsActual);
|
ASSERT_NEAR(fpsReference, fpsActual, 1e-2);
|
||||||
const int nFramesActual = static_cast<int>(capActual.get(CAP_PROP_FRAME_COUNT));
|
const int nFramesActual = static_cast<int>(capActual.get(CAP_PROP_FRAME_COUNT));
|
||||||
ASSERT_EQ(nFrames, nFramesActual);
|
ASSERT_EQ(nFrames, nFramesActual);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user