From 5128c1ff1fd4f872e7dd6a595ada0e7aee548dfe Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 29 May 2018 11:28:38 +0000 Subject: [PATCH] videoio(ffmpeg): specify stream->time_base Using codec->time_base is deprecated to specify muxer settings. Resolves issue with FPS value for AVI files with FFmpeg 4.0. Related FFmpeg commits: - https://github.com/FFmpeg/FFmpeg/commit/194be1f43ea391eb986732707435176e579265aa - https://github.com/FFmpeg/FFmpeg/commit/91736025b2807995e29bd0661807c1c84f515fef --- modules/videoio/src/cap_ffmpeg_impl.hpp | 3 +++ modules/videoio/test/test_ffmpeg.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index 0317831d3a..af26218941 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -1587,6 +1587,9 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, #if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(52, 42, 0) st->avg_frame_rate = (AVRational){frame_rate, frame_rate_base}; #endif +#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(55, 20, 0) + st->time_base = c->time_base; +#endif return st; } diff --git a/modules/videoio/test/test_ffmpeg.cpp b/modules/videoio/test/test_ffmpeg.cpp index 2baeeb8b41..6da1273353 100644 --- a/modules/videoio/test/test_ffmpeg.cpp +++ b/modules/videoio/test/test_ffmpeg.cpp @@ -357,6 +357,8 @@ public: for (unsigned int i = 0; i < frameCount && next; ++i) { + SCOPED_TRACE(cv::format("frame=%d", (int)frameCount)); + Mat actual; (*capture) >> actual;