Hello,
I probably crafted a patch, but my ffmpeg knowledge is zero, so help is
appreciated
Attached the patch.
G.
On Tue, 1 Feb 2022 23:38:47 +0100 Sebastian Ramacher <sramac...@debian.org>
wrote:
Source: hedgewars
Version: 1.0.0-14
Severity: important
X-Debbugs-Cc: sramac...@debian.org
Tags: sid bookworm ftbfs
Usertags: ffmpeg5.0
hedgewars FTBFS with ffmpeg 5.0 in experimental:
[ 6%] Generating hedgewars_it.qm
cd /<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/share/hedgewars/Data/Locale && /usr/lib/qt5/bin/lrelease
/<<PKGBUILDDIR>>/share/hedgewars/Data/Locale/hedgewars_it.ts -qm
/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/share/hedgewars/Data/Locale/hedgewars_it.qm
Updating
'/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/share/hedgewars/Data/Locale/hedgewars_gl.qm'...
Generated 223 translation(s) (177 finished and 46 unfinished)
Ignored 910 untranslated source text(s)
Updating
'/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/share/hedgewars/Data/Locale/hedgewars_hu.qm'...
Generated 1181 translation(s) (1181 finished and 0 unfinished)
Updating
'/<<PKGBUILDDIR>>/obj-x86_64-linux-gnu/share/hedgewars/Data/Locale/hedgewars_it.qm'...
Generated 1133 translation(s) (1133 finished and 0 unfinished)
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c: In function ‘AddAudioStream’:
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:174:26: error: ‘AVStream’ has
no member named ‘codec’
174 | g_pAudio = g_pAStream->codec;
| ^~
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:176:5: warning: implicit
declaration of function ‘avcodec_get_context_defaults3’ [-Wimplicit-function-declaration]
176 | avcodec_get_context_defaults3(g_pAudio, g_pACodec);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c: In function ‘WriteAudioFrame’:
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:230:5: warning:
‘av_init_packet’ is deprecated [-Wdeprecated-declarations]
230 | av_init_packet(&Packet);
| ^~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:45,
from /<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:25:
/usr/include/x86_64-linux-gnu/libavcodec/packet.h:506:6: note: declared here
506 | void av_init_packet(AVPacket *pkt);
| ^~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:247:9: warning: implicit
declaration of function ‘avcodec_encode_audio2’; did you mean ‘avcodec_encode_subtitle’?
[-Wimplicit-function-declaration]
247 | if (avcodec_encode_audio2(g_pAudio, &Packet, pFrame, &got_packet)
!= 0)
| ^~~~~~~~~~~~~~~~~~~~~
| avcodec_encode_subtitle
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c: In function ‘AddVideoStream’:
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:282:26: error: ‘AVStream’ has
no member named ‘codec’
282 | g_pVideo = g_pVStream->codec;
| ^~
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c: In function ‘WriteFrame’:
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:384:5: warning:
‘av_init_packet’ is deprecated [-Wdeprecated-declarations]
384 | av_init_packet(&Packet);
| ^~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:45,
from /<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:25:
/usr/include/x86_64-linux-gnu/libavcodec/packet.h:506:6: note: declared here
506 | void av_init_packet(AVPacket *pkt);
| ^~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:408:13: warning: implicit
declaration of function ‘avcodec_encode_video2’; did you mean ‘avcodec_encode_subtitle’?
[-Wimplicit-function-declaration]
408 | if (avcodec_encode_video2(g_pVideo, &Packet, pFrame, &got_packet)
< 0)
| ^~~~~~~~~~~~~~~~~~~~~
| avcodec_encode_subtitle
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c: In function ‘AVWrapper_Init’:
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:503:5: warning: implicit
declaration of function ‘av_register_all’ [-Wimplicit-function-declaration]
503 | av_register_all();
| ^~~~~~~~~~~~~~~
/<<PKGBUILDDIR>>/hedgewars/avwrapper/avwrapper.c:506:15: warning: assignment
discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
Description: Add compatibility with new ffmpeg 5.0, based on patch available here:
https://github.com/opencv/opencv/issues/21455
Author: Gianfranco Costamagna <locutusofb...@debian.org>
Origin: other
Bug-Debian: https://bugs.debian.org/1004825
Forwarded: irc
Last-Update: 2022-02-03
Index: hedgewars/hedgewars/avwrapper/avwrapper.c
===================================================================
--- hedgewars.orig/hedgewars/avwrapper/avwrapper.c
+++ hedgewars/hedgewars/avwrapper/avwrapper.c
@@ -27,6 +27,10 @@
#include "libavutil/avutil.h"
#include "libavutil/mathematics.h"
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+#include <libavcodec/bsf.h>
+#endif
+
#if (defined _MSC_VER)
#define AVWRAP_DECL __declspec(dllexport)
#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))
@@ -171,7 +175,13 @@
}
g_pAStream->id = 1;
+#if LIBAVCODEC_VERSION_MAJOR < 59
g_pAudio = g_pAStream->codec;
+#else
+ const AVCodec *audio_st_codec = avcodec_find_decoder(g_pAStream->codecpar->codec_id);
+ g_pAudio = avcodec_alloc_context3(audio_st_codec);
+ avcodec_parameters_to_context(g_pAudio, g_pAStream->codecpar);
+#endif
avcodec_get_context_defaults3(g_pAudio, g_pACodec);
g_pAudio->codec_id = g_pACodec->id;
@@ -279,7 +289,13 @@
if (!g_pVStream)
return FatalError("Could not allocate video stream");
+#if LIBAVCODEC_VERSION_MAJOR < 59
g_pVideo = g_pVStream->codec;
+#else
+ const AVCodec *video_st_codec = avcodec_find_decoder(g_pVStream->codecpar->codec_id);
+ g_pVideo = avcodec_alloc_context3(video_st_codec);
+ avcodec_parameters_to_context(g_pVideo, g_pVStream->codecpar);
+#endif
avcodec_get_context_defaults3(g_pVideo, g_pVCodec);
g_pVideo->codec_id = g_pVCodec->id;
@@ -499,8 +515,10 @@
g_Framerate.den = FramerateDen;
g_VQuality = VQuality;
+#if LIBAVCODEC_VERSION_MAJOR < 58
// initialize libav and register all codecs and formats
av_register_all();
+#endif
// find format
g_pFormat = av_guess_format(pFormatName, NULL, NULL);
@@ -522,8 +540,11 @@
strncpy(ext, g_pFormat->extensions, 16);
ext[15] = 0;
ext[strcspn(ext,",")] = 0;
+#if LIBAVCODEC_VERSION_MAJOR < 59
snprintf(g_pContainer->filename, sizeof(g_pContainer->filename), "%s.%s", pFilename, ext);
-
+#else
+ snprintf(g_pContainer->url, sizeof(g_pContainer->url), "%s.%s", pFilename, ext);
+#endif
// find codecs
g_pVCodec = avcodec_find_encoder_by_name(pVCodecName);
g_pACodec = avcodec_find_encoder_by_name(pACodecName);
@@ -560,13 +581,22 @@
return FatalError("No video, no audio, aborting...");
// write format info to log
+#if LIBAVCODEC_VERSION_MAJOR < 59
av_dump_format(g_pContainer, 0, g_pContainer->filename, 1);
+#else
+ av_dump_format(g_pContainer, 0, g_pContainer->url, 1);
+#endif
// open the output file, if needed
if (!(g_pFormat->flags & AVFMT_NOFILE))
{
+#if LIBAVCODEC_VERSION_MAJOR < 59
if (avio_open(&g_pContainer->pb, g_pContainer->filename, AVIO_FLAG_WRITE) < 0)
return FatalError("Could not open output file (%s)", g_pContainer->filename);
+#else
+ if (avio_open(&g_pContainer->pb, g_pContainer->url, AVIO_FLAG_WRITE) < 0)
+ return FatalError("Could not open output file (%s)", g_pContainer->url);
+#endif
}
g_pVFrame->pts = -1;
Index: hedgewars/QTfrontend/util/LibavInteraction.cpp
===================================================================
--- hedgewars.orig/QTfrontend/util/LibavInteraction.cpp
+++ hedgewars/QTfrontend/util/LibavInteraction.cpp
@@ -73,7 +73,11 @@
QMap<QString,Format> formats;
// test if given format supports given codec
+#if LIBAVCODEC_VERSION_MAJOR < 59
bool FormatQueryCodec(AVOutputFormat *ofmt, enum AVCodecID codec_id)
+#else
+bool FormatQueryCodec(const AVOutputFormat *ofmt, enum AVCodecID codec_id)
+#endif
{
#if LIBAVFORMAT_VERSION_MAJOR >= 54
return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1;
@@ -86,12 +90,19 @@
LibavInteraction::LibavInteraction() : QObject()
{
+#if LIBAVCODEC_VERSION_MAJOR < 59
// initialize libav and register all codecs and formats
av_register_all();
+#endif
// get list of all codecs
+#if LIBAVCODEC_VERSION_MAJOR < 59
AVCodec* pCodec = NULL;
while ((pCodec = av_codec_next(pCodec)))
+#else
+ const AVCodec* pCodec = NULL;
+ while ((pCodec = av_codec_iterate((void**)&pCodec)))
+#endif
{
if (!av_codec_is_encoder(pCodec))
continue;
@@ -179,8 +190,13 @@
}
// get list of all formats
+#if LIBAVCODEC_VERSION_MAJOR < 59
AVOutputFormat* pFormat = NULL;
while ((pFormat = av_oformat_next(pFormat)))
+#else
+ const AVOutputFormat* pFormat = NULL;
+ while ((pFormat = av_muxer_iterate((void**)&pFormat)))
+#endif
{
if (!pFormat->extensions)
continue;
@@ -296,12 +312,22 @@
AVStream* pStream = pContext->streams[i];
if (!pStream)
continue;
+#if LIBAVCODEC_VERSION_MAJOR < 59
AVCodecContext* pCodec = pContext->streams[i]->codec;
+#else
+ const AVCodec *st_codec = avcodec_find_decoder(pContext->streams[i]->codecpar->codec_id);
+ AVCodecContext* pCodec = avcodec_alloc_context3(st_codec);
+ avcodec_parameters_to_context(pCodec, pContext->streams[i]->codecpar);
+#endif
if (!pCodec)
continue;
+#if LIBAVCODEC_VERSION_MAJOR < 59
AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
+#else
+ const AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
+#endif
QString decoderName = pDecoder ? pDecoder->name : tr("unknown");
if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO)
{