Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-video/obs-studio/, media-video/obs-studio/files/
Date: Wed, 19 Jan 2022 01:16:04
Message-Id: 1642554929.49e4794474d6d730937ae3649dcca86598f3407e.sam@gentoo
1 commit: 49e4794474d6d730937ae3649dcca86598f3407e
2 Author: James Beddek <telans <AT> posteo <DOT> de>
3 AuthorDate: Sun Jan 16 04:14:22 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 19 01:15:29 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=49e47944
7
8 media-video/obs-studio: add ffmpeg 5.0 patch
9
10 Signed-off-by: James Beddek <telans <AT> posteo.de>
11 Closes: https://github.com/gentoo/gentoo/pull/23821
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13
14 .../files/obs-studio-27.1.3-ffmpeg-5.0.patch | 314 +++++++++++++++++++++
15 media-video/obs-studio/obs-studio-27.1.3-r1.ebuild | 3 +-
16 2 files changed, 316 insertions(+), 1 deletion(-)
17
18 diff --git a/media-video/obs-studio/files/obs-studio-27.1.3-ffmpeg-5.0.patch b/media-video/obs-studio/files/obs-studio-27.1.3-ffmpeg-5.0.patch
19 new file mode 100644
20 index 000000000000..a529dca715a9
21 --- /dev/null
22 +++ b/media-video/obs-studio/files/obs-studio-27.1.3-ffmpeg-5.0.patch
23 @@ -0,0 +1,314 @@
24 +# https://git.exherbo.org/media.git/commit/?id=10c891cb37f4f7e42e95a00b27a5d4636266353e
25 +# https://git.exherbo.org/media.git/commit/?id=e888c31724357431dbd0e73014ca87a552850d45
26 +
27 +From 08547a1696fa381d0bda18aed57b9f87a6b1b334 Mon Sep 17 00:00:00 2001
28 +From: Ryan Foster <RytoEX@×××××.com>
29 +Date: Sat, 6 Nov 2021 18:57:35 -0400
30 +Subject: [PATCH] obs-ffmpeg: Include avcodec header for AVCodecContext
31 +
32 +FFmpeg commit e67e02d15672 [1] drops avcodec.h from avformat.h includes.
33 +Therefore we need to include it explicitly.
34 +
35 +[1]: https://github.com/FFmpeg/FFmpeg/commit/e67e02d15672a87da1b0566e197a1e19dc7e1e33
36 + lavf/avformat.h: drop the avcodec.h include
37 +---
38 + plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c | 1 +
39 + plugins/obs-ffmpeg/obs-ffmpeg-formats.h | 2 ++
40 + plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c | 1 +
41 + plugins/obs-ffmpeg/obs-ffmpeg-output.h | 1 +
42 + 4 files changed, 5 insertions(+)
43 +
44 +diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
45 +index 1c160ced4b1f..e4c6cdb9fa2f 100644
46 +--- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
47 ++++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
48 +@@ -27,6 +27,7 @@
49 + #include "ffmpeg-mux.h"
50 +
51 + #include <util/dstr.h>
52 ++#include <libavcodec/avcodec.h>
53 + #include <libavformat/avformat.h>
54 +
55 + #define ANSI_COLOR_RED "\x1b[0;91m"
56 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-formats.h b/plugins/obs-ffmpeg/obs-ffmpeg-formats.h
57 +index 62e3866d037a..b40ef37293b4 100644
58 +--- a/plugins/obs-ffmpeg/obs-ffmpeg-formats.h
59 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg-formats.h
60 +@@ -1,5 +1,7 @@
61 + #pragma once
62 +
63 ++#include <libavcodec/avcodec.h>
64 ++
65 + static inline int64_t rescale_ts(int64_t val, AVCodecContext *context,
66 + AVRational new_base)
67 + {
68 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c b/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c
69 +index f2d93d2def89..e66010ce5f9c 100644
70 +--- a/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c
71 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c
72 +@@ -24,6 +24,7 @@
73 +
74 + #include <libavutil/opt.h>
75 + #include <libavutil/pixdesc.h>
76 ++#include <libavcodec/avcodec.h>
77 + #include <libavformat/avformat.h>
78 +
79 + #include "obs-ffmpeg-formats.h"
80 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.h b/plugins/obs-ffmpeg/obs-ffmpeg-output.h
81 +index 99f4dcd13b44..72d89dfacc4c 100644
82 +--- a/plugins/obs-ffmpeg/obs-ffmpeg-output.h
83 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.h
84 +@@ -2,6 +2,7 @@
85 +
86 + #include <libavutil/opt.h>
87 + #include <libavutil/pixdesc.h>
88 ++#include <libavcodec/avcodec.h>
89 + #include <libavformat/avformat.h>
90 + #include <libswscale/swscale.h>
91 +
92 +From abf1d609d29196921df8f09ab6e07340b7cf9660 Mon Sep 17 00:00:00 2001
93 +From: Ryan Foster <RytoEX@×××××.com>
94 +Date: Sat, 6 Nov 2021 18:58:05 -0400
95 +Subject: [PATCH] obs-ffmpeg: Include channel_layout.h
96 +
97 +avcodec.h stopped including channel_layout.h per FFmpeg commit
98 +1be3d8a0cb77 [1]. avformat.h stopped including avcodec.h per FFmpeg
99 +commit e67e02d15672 [2]. As a result, we need to explicitly include
100 +avutil/channel_layout.h when needed. Fixes compilation error against
101 +FFmpeg later than the two mentioned commits.
102 +
103 +[1]: https://github.com/FFmpeg/FFmpeg/commit/1be3d8a0cb77f8d34c1f39b47bf5328fe10c82d7
104 +[2]: https://github.com/FFmpeg/FFmpeg/commit/e67e02d15672a87da1b0566e197a1e19dc7e1e33
105 +---
106 + plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c | 1 +
107 + 1 file changed, 1 insertion(+)
108 +
109 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c
110 +index 2e3899464362..cbcb9ac31bcb 100644
111 +--- a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c
112 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c
113 +@@ -21,6 +21,7 @@
114 + #include <util/dstr.h>
115 + #include <obs-module.h>
116 +
117 ++#include <libavutil/channel_layout.h>
118 + #include <libavutil/opt.h>
119 + #include <libavformat/avformat.h>
120 +
121 +From ce734366bc0b95ff91930f463e7ebe528cf8eabf Mon Sep 17 00:00:00 2001
122 +From: Ryan Foster <RytoEX@×××××.com>
123 +Date: Sat, 6 Nov 2021 18:58:36 -0400
124 +Subject: [PATCH] obs-ffmpeg: Respect AVFormatContext and AVOutputFormat
125 + constness
126 +
127 +AVFormatContext::oformat was made const on April 27, 2021 [1]. If we
128 +respect the constness of AVOutputFormat and do not cast results from
129 +FFmpeg functions to non-const, we cannot modify the results after the
130 +fact. Our choices are either to cast them to non-const (and presumably
131 +have them implicitly casted back to const on later function calls), or
132 +only try to modify the results in versions of FFmpeg where these are not
133 +expected to be const.
134 +
135 +Instead of relying on casts, we can set the encoder values in the
136 +ffmpeg_cfg struct, which are later passed to new_stream.
137 +
138 +Also modifies deps/media-playback. Removes compiler warnings.
139 +Some avformat functions return const AV(In/Out)putFormat per [1], so
140 +ifdef as needed.
141 +
142 +[1]: https://github.com/FFmpeg/FFmpeg/commit/56450a0ee4fdda160f4039fc2ae33edfd27765c9
143 + lavf 59.0.100 avformat.h
144 + avformat: Constify the API wrt AV(In|Out)putFormat
145 +
146 + Also constify AVProbeData.
147 +---
148 + deps/media-playback/media-playback/media.c | 4 ++++
149 + plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c | 10 ++++++++++
150 + plugins/obs-ffmpeg/obs-ffmpeg-output.c | 19 ++++++++++++++++++-
151 + 3 files changed, 32 insertions(+), 1 deletion(-)
152 +
153 +diff --git a/deps/media-playback/media-playback/media.c b/deps/media-playback/media-playback/media.c
154 +index 9041b62e9cdd..a09b58ed5d10 100644
155 +--- a/deps/media-playback/media-playback/media.c
156 ++++ b/deps/media-playback/media-playback/media.c
157 +@@ -608,7 +608,11 @@ static int interrupt_callback(void *data)
158 +
159 + static bool init_avformat(mp_media_t *m)
160 + {
161 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
162 + AVInputFormat *format = NULL;
163 ++#else
164 ++ const AVInputFormat *format = NULL;
165 ++#endif
166 +
167 + if (m->format_name && *m->format_name) {
168 + format = av_find_input_format(m->format_name);
169 +diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
170 +index e4c6cdb9fa2f..ffce3ee33eec 100644
171 +--- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
172 ++++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
173 +@@ -565,7 +565,11 @@ static inline bool ffmpeg_mux_get_extra_data(struct ffmpeg_mux *ffm)
174 +
175 + static inline int open_output_file(struct ffmpeg_mux *ffm)
176 + {
177 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
178 + AVOutputFormat *format = ffm->output->oformat;
179 ++#else
180 ++ const AVOutputFormat *format = ffm->output->oformat;
181 ++#endif
182 + int ret;
183 +
184 + if ((format->flags & AVFMT_NOFILE) == 0) {
185 +@@ -631,7 +635,11 @@ static bool ffmpeg_mux_is_network(struct ffmpeg_mux *ffm)
186 +
187 + static int ffmpeg_mux_init_context(struct ffmpeg_mux *ffm)
188 + {
189 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
190 + AVOutputFormat *output_format;
191 ++#else
192 ++ const AVOutputFormat *output_format;
193 ++#endif
194 + int ret;
195 + bool is_http = false;
196 + is_http = (strncmp(ffm->params.file, HTTP_PROTO,
197 +@@ -665,8 +673,10 @@ static int ffmpeg_mux_init_context(struct ffmpeg_mux *ffm)
198 + return FFM_ERROR;
199 + }
200 +
201 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
202 + ffm->output->oformat->video_codec = AV_CODEC_ID_NONE;
203 + ffm->output->oformat->audio_codec = AV_CODEC_ID_NONE;
204 ++#endif
205 +
206 + if (!init_streams(ffm)) {
207 + free_avformat(ffm);
208 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c
209 +index 6bc1637b1796..7447e952b9c2 100644
210 +--- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c
211 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c
212 +@@ -543,6 +543,7 @@ static enum AVCodecID get_codec_id(const char *name, int id)
213 + return codec->id;
214 + }
215 +
216 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
217 + static void set_encoder_ids(struct ffmpeg_data *data)
218 + {
219 + data->output->oformat->video_codec = get_codec_id(
220 +@@ -551,6 +552,7 @@ static void set_encoder_ids(struct ffmpeg_data *data)
221 + data->output->oformat->audio_codec = get_codec_id(
222 + data->config.audio_encoder, data->config.audio_encoder_id);
223 + }
224 ++#endif
225 +
226 + bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config)
227 + {
228 +@@ -570,7 +572,13 @@ bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config)
229 +
230 + is_rtmp = (astrcmpi_n(config->url, "rtmp://", 7) == 0);
231 +
232 +- AVOutputFormat *output_format = av_guess_format(
233 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
234 ++ AVOutputFormat *output_format;
235 ++#else
236 ++ const AVOutputFormat *output_format;
237 ++#endif
238 ++
239 ++ output_format = av_guess_format(
240 + is_rtmp ? "flv" : data->config.format_name, data->config.url,
241 + is_rtmp ? NULL : data->config.format_mime_type);
242 +
243 +@@ -596,6 +604,7 @@ bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config)
244 + goto fail;
245 + }
246 +
247 ++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 0, 100)
248 + if (is_rtmp) {
249 + data->output->oformat->video_codec = AV_CODEC_ID_H264;
250 + data->output->oformat->audio_codec = AV_CODEC_ID_AAC;
251 +@@ -603,6 +612,14 @@ bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config)
252 + if (data->config.format_name)
253 + set_encoder_ids(data);
254 + }
255 ++#else
256 ++ if (is_rtmp) {
257 ++ data->config.audio_encoder = "aac";
258 ++ data->config.audio_encoder_id = AV_CODEC_ID_AAC;
259 ++ data->config.video_encoder = "libx264";
260 ++ data->config.video_encoder_id = AV_CODEC_ID_H264;
261 ++ }
262 ++#endif
263 +
264 + if (!init_streams(data))
265 + goto fail;
266 +
267 +From d78971b4db34d5fffbd11d2acabf37a65e11cd58 Mon Sep 17 00:00:00 2001
268 +From: pkv <pkv@××××××××××.com>
269 +Date: Fri, 17 Dec 2021 20:52:11 +0100
270 +Subject: [PATCH] obs-ffmpeg: Further FFmpeg deprecations fixes for FFmpeg 4.4+
271 +
272 +avcodec.h stopped including channel_layout.h per FFmpeg commit
273 +1be3d8a0cb77 [1]. Fixes compilation error on macOS against
274 +FFmpeg later than the mentioned commit.
275 +[1] https://github.com/FFmpeg/FFmpeg/commit/1be3d8a0cb77f8d34c1f39b47bf5328fe10c82d7
276 +---
277 + plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c | 1 +
278 + plugins/obs-ffmpeg/obs-ffmpeg-output.c | 1 +
279 + 2 files changed, 2 insertions(+)
280 +
281 +diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
282 +index c07e22abe266..db26cb425ce5 100644
283 +--- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
284 ++++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
285 +@@ -29,6 +29,7 @@
286 + #include <util/dstr.h>
287 + #include <libavcodec/avcodec.h>
288 + #include <libavformat/avformat.h>
289 ++#include <libavutil/channel_layout.h>
290 +
291 + #define ANSI_COLOR_RED "\x1b[0;91m"
292 + #define ANSI_COLOR_MAGENTA "\x1b[0;95m"
293 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c
294 +index d3637ebbb59b..7d1f12a60393 100644
295 +--- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c
296 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c
297 +@@ -25,6 +25,7 @@
298 + #include "obs-ffmpeg-output.h"
299 + #include "obs-ffmpeg-formats.h"
300 + #include "obs-ffmpeg-compat.h"
301 ++#include <libavutil/channel_layout.h>
302 +
303 + struct ffmpeg_output {
304 + obs_output_t *output;
305 +
306 +From c398ac9739a82bc95632eef9544dd0fb5bc5f0cf Mon Sep 17 00:00:00 2001
307 +From: pkv <pkv@××××××××××.com>
308 +Date: Sat, 6 Nov 2021 18:59:37 -0400
309 +Subject: [PATCH] obs-ffmpeg: Fix NVENC old codec naming removed in FFmpeg
310 +
311 +Per FFmpeg commit 337f777f378c [1], FFmpeg removed nvenc_h264_encoder
312 +and nvenc_hevc_encoder after deprecation in FFmpeg commit 888a5c794778
313 +[2]. The names to be used are ff_h264_nvenc_encoder and
314 +ff_hevc_nvenc_encoder. So we must allow alternative search of codec as
315 +h264_nvenc or nvenc_h264 in obs-ffmpeg.c.
316 +
317 +[1]: https://github.com/FFmpeg/FFmpeg/commit/337f777f378cfcc0d6f0d01fb7125905e8b0da55
318 +[2]: https://github.com/FFmpeg/FFmpeg/commit/888a5c794778a2f2aad22e9b4a3952dff92b11fa
319 +---
320 + plugins/obs-ffmpeg/obs-ffmpeg.c | 4 +++-
321 + 1 file changed, 3 insertions(+), 1 deletion(-)
322 +
323 +diff --git a/plugins/obs-ffmpeg/obs-ffmpeg.c b/plugins/obs-ffmpeg/obs-ffmpeg.c
324 +index 7330b2273544..399c5bfa64b6 100644
325 +--- a/plugins/obs-ffmpeg/obs-ffmpeg.c
326 ++++ b/plugins/obs-ffmpeg/obs-ffmpeg.c
327 +@@ -180,7 +180,9 @@ static bool nvenc_supported(void)
328 + bool success = false;
329 +
330 + if (!nvenc) {
331 +- goto cleanup;
332 ++ nvenc = avcodec_find_encoder_by_name("h264_nvenc");
333 ++ if (!nvenc)
334 ++ goto cleanup;
335 + }
336 +
337 + #if defined(_WIN32)
338
339 diff --git a/media-video/obs-studio/obs-studio-27.1.3-r1.ebuild b/media-video/obs-studio/obs-studio-27.1.3-r1.ebuild
340 index 9cd43053e715..34b197508564 100644
341 --- a/media-video/obs-studio/obs-studio-27.1.3-r1.ebuild
342 +++ b/media-video/obs-studio/obs-studio-27.1.3-r1.ebuild
343 @@ -1,4 +1,4 @@
344 -# Copyright 1999-2021 Gentoo Authors
345 +# Copyright 1999-2022 Gentoo Authors
346 # Distributed under the terms of the GNU General Public License v2
347
348 EAPI=8
349 @@ -121,6 +121,7 @@ QA_PREBUILT="
350
351 PATCHES=(
352 "${FILESDIR}/${PN}-26.1.2-python-3.8.patch"
353 + "${FILESDIR}/${PN}-27.1.3-ffmpeg-5.0.patch"
354 )
355
356 pkg_setup() {