[packages/opencv] - rel 2, build fixes for ffmpeg 9 and vtk 9.7

baggins baggins at pld-linux.org
Tue Oct 20 22:04:12 CEST 2026


commit 6429be02ecd16a68171005e6fdc3ac64b14f4441
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Tue Oct 20 22:03:45 2026 +0200

    - rel 2, build fixes for ffmpeg 9 and vtk 9.7

 ffmpeg9.patch | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 opencv.spec   |  8 +++++-
 vtk9.7.patch  | 48 +++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+), 1 deletion(-)
---
diff --git a/opencv.spec b/opencv.spec
index ee09398..1b000c6 100644
--- a/opencv.spec
+++ b/opencv.spec
@@ -57,7 +57,7 @@ Summary:	A library of programming functions mainly aimed at real time computer v
 Summary(pl.UTF-8):	Biblioteka funkcji do grafiki komputerowej w czasie rzeczywistym
 Name:		opencv
 Version:	4.14.0
-Release:	1
+Release:	2
 Epoch:		1
 %if %{with unicap} || %{with xine}
 License:	GPL (enforced by used libraries), BSD (opencv itself)
@@ -111,6 +111,8 @@ Source53:	https://raw.githubusercontent.com/WeChatCV/opencv_3rdparty/a8b69ccc738
 Patch0:		%{name}-ximea.patch
 Patch1:		python-install.patch
 Patch2:		pkgconfig-paths.patch
+Patch3:		ffmpeg9.patch
+Patch4:		vtk9.7.patch
 URL:		http://www.opencv.org/
 %{?with_pvapi:BuildRequires:	AVT_GigE_SDK-devel}
 %{?with_opencl:BuildRequires:	OpenCL-devel}
@@ -336,6 +338,10 @@ Wiązania Pythona 3 do OpenCV.
 %patch -P0 -p1
 %patch -P1 -p1
 %patch -P2 -p1
+%patch -P3 -p1
+cd opencv_contrib-%{version}
+%patch -P4 -p1
+cd ..
 
 cache_file() {
 	f="$1"
diff --git a/ffmpeg9.patch b/ffmpeg9.patch
new file mode 100644
index 0000000..515e50e
--- /dev/null
+++ b/ffmpeg9.patch
@@ -0,0 +1,92 @@
+diff -up opencv-4.13.0/modules/videoio/src/cap_ffmpeg_hw.hpp.ffmpeg9 opencv-4.13.0/modules/videoio/src/cap_ffmpeg_hw.hpp
+--- opencv-4.13.0/modules/videoio/src/cap_ffmpeg_hw.hpp.ffmpeg9	2025-12-30 08:52:05.000000000 +0100
++++ opencv-4.13.0/modules/videoio/src/cap_ffmpeg_hw.hpp	2026-08-19 22:08:03.123031318 +0200
+@@ -757,6 +757,30 @@ AVCodec *hw_find_codec(AVCodecID id, AVH
+ #endif
+             if (hw_type == AV_HWDEVICE_TYPE_CUDA) // CUDA encoders don't support avcodec_get_hw_config()
+                 hw_native_fmt = AV_PIX_FMT_CUDA;
++#if LIBAVCODEC_BUILD >= AV_VERSION_INT(61, 13, 100)
++            if (av_codec_is_encoder(c) && hw_native_fmt != AV_PIX_FMT_NONE) {
++                const AVPixelFormat *pix_fmts = NULL;
++                int num_pix_fmts = 0;
++
++                int ret = avcodec_get_supported_config(
++                    NULL,
++                    c,
++                    AV_CODEC_CONFIG_PIX_FORMAT,
++                    0,
++                    (const void **)&pix_fmts,
++                    &num_pix_fmts);
++
++                if (ret >= 0 && pix_fmts && num_pix_fmts > 0) {
++                        for (int i = 0; i < num_pix_fmts; i++) {
++                            if (pix_fmts[i] == hw_native_fmt) {
++                                *hw_pix_fmt = hw_native_fmt;
++                                if (hw_check_codec(c, hw_type, disabled_codecs))
++                                    return c;
++                            }
++                        }
++                    }
++            }
++#else
+             if (av_codec_is_encoder(c) && hw_native_fmt != AV_PIX_FMT_NONE && c->pix_fmts) {
+                 for (int i = 0; c->pix_fmts[i] != AV_PIX_FMT_NONE; i++) {
+                     if (c->pix_fmts[i] == hw_native_fmt) {
+@@ -766,6 +790,7 @@ AVCodec *hw_find_codec(AVCodecID id, AVH
+                     }
+                 }
+             }
++#endif
+             for (int i = 0;; i++) {
+                 const AVCodecHWConfig *hw_config = avcodec_get_hw_config(c, i);
+                 if (!hw_config)
+diff -up opencv-4.13.0/modules/videoio/src/cap_ffmpeg_impl.hpp.ffmpeg9 opencv-4.13.0/modules/videoio/src/cap_ffmpeg_impl.hpp
+--- opencv-4.13.0/modules/videoio/src/cap_ffmpeg_impl.hpp.ffmpeg9	2025-12-30 08:52:05.000000000 +0100
++++ opencv-4.13.0/modules/videoio/src/cap_ffmpeg_impl.hpp	2026-08-19 22:08:03.123275322 +0200
+@@ -2583,6 +2583,38 @@ static AVCodecContext * icv_configure_vi
+     c->time_base.den = frame_rate;
+     c->time_base.num = frame_rate_base;
+     /* adjust time base for supported framerates */
++#if LIBAVCODEC_BUILD >= CALC_FFMPEG_VERSION(61, 13, 100)
++    if (codec){
++        const AVRational *supported_framerates = NULL;
++        int num_supported_framerates = 0;
++        int ret = avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_FRAME_RATE, 0,
++                                               (const void **)&supported_framerates, &num_supported_framerates);
++
++        if (ret >= 0 && supported_framerates && num_supported_framerates > 0){
++            AVRational req = {frame_rate, frame_rate_base};
++            const AVRational *best=NULL;
++            AVRational best_error= {INT_MAX, 1};
++            for(int i = 0; i < num_supported_framerates; i++){
++                const AVRational *p = &supported_framerates[i];
++                AVRational error = av_sub_q(req, *p);
++                if(error.num <0) error.num *= -1;
++                if(av_cmp_q(error, best_error) < 0){
++                    best_error = error;
++                    best = p;
++                }
++            }
++            if (best == NULL)
++            {
++#ifdef CV_FFMPEG_CODECPAR
++                avcodec_free_context(&c);
++#endif
++                return NULL;
++            }
++            c->time_base.den = best->num;
++            c->time_base.num = best->den;
++        }
++    }
++#else
+     if(codec && codec->supported_framerates){
+         const AVRational *p= codec->supported_framerates;
+         AVRational req = {frame_rate, frame_rate_base};
+@@ -2606,6 +2638,7 @@ static AVCodecContext * icv_configure_vi
+         c->time_base.den= best->num;
+         c->time_base.num= best->den;
+     }
++#endif
+ 
+     c->gop_size = 12; /* emit one intra frame every twelve frames at most */
+     c->pix_fmt = pixel_format;
diff --git a/vtk9.7.patch b/vtk9.7.patch
new file mode 100644
index 0000000..c6f2e73
--- /dev/null
+++ b/vtk9.7.patch
@@ -0,0 +1,48 @@
+diff --git a/modules/viz/src/vtk/vtkVizInteractorStyle.cpp b/modules/viz/src/vtk/vtkVizInteractorStyle.cpp
+index e2d33806..8943cb9f 100644
+--- a/modules/viz/src/vtk/vtkVizInteractorStyle.cpp
++++ b/modules/viz/src/vtk/vtkVizInteractorStyle.cpp
+@@ -44,6 +44,7 @@
+ //M*/
+ 
+ #include "../precomp.hpp"
++#include <iostream>
+ 
+ namespace cv { namespace viz
+ {
+@@ -96,7 +97,7 @@ void cv::viz::vtkVizInteractorStyle::saveScreenshot(const String &file)
+     snapshot_writer->SetFileName(file.c_str());
+     snapshot_writer->Write();
+ 
+-    cout << "Screenshot successfully captured (" << file.c_str() << ")" << endl;
++    std::cout << "Screenshot successfully captured (" << file.c_str() << ")" << endl;
+ }
+ 
+ //////////////////////////////////////////////////////////////////////////////////////////////
+@@ -118,7 +119,7 @@ void cv::viz::vtkVizInteractorStyle::exportScene(const String &file)
+     exporter->SetInput(Interactor->GetRenderWindow());
+     exporter->Write();
+ 
+-    cout << "Scene successfully exported (" << file.c_str() << ")" << endl;
++    std::cout << "Scene successfully exported (" << file.c_str() << ")" << endl;
+ }
+ 
+ void cv::viz::vtkVizInteractorStyle::exportScene()
+commit fe8a6898e5c013be30ae9216e0a43b42aa9bfc78
+Author: Orion Poplawski <orion at nwra.com>
+Date:   Wed Feb 25 20:51:05 2026 -0700
+
+    Include iostream for cerr in widget.cpp
+
+diff --git a/modules/viz/src/widget.cpp b/modules/viz/src/widget.cpp
+index b46d3d1c..44ce4d5c 100644
+--- a/modules/viz/src/widget.cpp
++++ b/modules/viz/src/widget.cpp
+@@ -44,6 +44,7 @@
+ //M*/
+ 
+ #include "precomp.hpp"
++#include <iostream>
+ 
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ /// widget implementation
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/opencv.git/commitdiff/6429be02ecd16a68171005e6fdc3ac64b14f4441



More information about the pld-cvs-commit mailing list