public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/opencv] rawhide: Fixed build with FFmpeg 9
@ 2026-09-05 9:46 Dominik 'Rathann' Mierzejewski
0 siblings, 0 replies; only message in thread
From: Dominik 'Rathann' Mierzejewski @ 2026-09-05 9:46 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/opencv
Branch : rawhide
Commit : 0360c67218cfc8d0108ace9177bb2c7477ad64fc
Author : Dominik 'Rathann' Mierzejewski <dominik@greysector.net>
Date : 2026-08-19T22:10:04+02:00
Stats : +99/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/opencv/c/0360c67218cfc8d0108ace9177bb2c7477ad64fc?branch=rawhide
Log:
Fixed build with FFmpeg 9
---
diff --git a/opencv-ffmpeg9.patch b/opencv-ffmpeg9.patch
new file mode 100644
index 0000000..515e50e
--- /dev/null
+++ b/opencv-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/opencv.spec b/opencv.spec
index 37b0b80..1d3accd 100644
--- a/opencv.spec
+++ b/opencv.spec
@@ -73,7 +73,7 @@ Version: 4.13.0
%global minorver %(foo=%{version}; a=(${foo//./ }); echo ${a[1]} )
%global padding %(digits=00; num=%{minorver}; echo ${digits:${#num}:${#digits}} )
%global abiver %(echo %{majorver}%{padding}%{minorver} )
-Release: 10%{?dist}
+Release: 11%{?dist}
Summary: Collection of algorithms for computer vision
# This is normal three clause BSD.
License: BSD-3-Clause AND Apache-2.0 AND ISC
@@ -103,6 +103,8 @@ Patch0: opencv-4.1.0-install_3rdparty_licenses.patch
Patch1: opencv-vtk.patch
Patch3: opencv.python.patch
Patch4: Fix-macro-definition-for-Power10-architecture.patch
+# Fix build with FFmpeg 9 - https://github.com/opencv/opencv/pull/29533
+Patch5: opencv-ffmpeg9.patch
BuildRequires: gcc-c++
@@ -401,6 +403,7 @@ popd &>/dev/null
%patch -P 0 -p1 -b .install_3rdparty_licenses
%patch -P 3 -p1 -b .python_install_binary
%patch -P 4 -p1 -b .ppc_macro
+%patch -P 5 -p1 -b .ffmpeg9
pushd %{name}_contrib-%{version}
%patch -P 1 -p1 -b .vtk
@@ -609,6 +612,9 @@ cp config-*.py %{buildroot}/%{python3_sitelib}/cv2/
%changelog
+* Wed Aug 19 2026 Dominik Mierzejewski <dominik@greysector.net> - 4.13.0-11
+- Fixed build with FFmpeg 9
+
* Wed Jul 22 2026 Python Maint <python-maint@redhat.com> - 4.13.0-10
- Rebuilt for Python 3.15.0b4 ABI change
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-05 9:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-05 9:46 [rpms/opencv] rawhide: Fixed build with FFmpeg 9 Dominik 'Rathann' Mierzejewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox