1 |
commit: c806301a09f1ae51a5198f110af001400e88ebed |
2 |
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 7 22:09:11 2021 +0000 |
4 |
Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 7 22:22:47 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c806301a |
7 |
|
8 |
media-video/ffmpeg-chromium: New package based on existing ffmpeg |
9 |
|
10 |
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org> |
11 |
|
12 |
media-video/ffmpeg-chromium/Manifest | 1 + |
13 |
.../ffmpeg-chromium/ffmpeg-chromium-94.ebuild | 223 +++++++++++++++++++++ |
14 |
media-video/ffmpeg-chromium/files/chromium.patch | 41 ++++ |
15 |
.../ffmpeg-chromium/files/ffmpeg-chromium-94.patch | 26 +++ |
16 |
media-video/ffmpeg-chromium/metadata.xml | 14 ++ |
17 |
5 files changed, 305 insertions(+) |
18 |
|
19 |
diff --git a/media-video/ffmpeg-chromium/Manifest b/media-video/ffmpeg-chromium/Manifest |
20 |
new file mode 100644 |
21 |
index 00000000000..3e1116a6ede |
22 |
--- /dev/null |
23 |
+++ b/media-video/ffmpeg-chromium/Manifest |
24 |
@@ -0,0 +1 @@ |
25 |
+DIST ffmpeg-chromium-94.tar.gz 14709687 BLAKE2B 06dedbd86befd8caed4c6cb34755b52cf70630f8fbd712f89d42e5b63e498f9d2a77935fbd7c87194f6d56fb0f83ff26beba00357dd51b3ac3e2e4480ff4351e SHA512 a6cf5404c892c878c50e3ba8369456db587e327bc3d77e857b9d34f3665ecfee7d3865b20e9871ccda570b30d9d34c03fd981cdc7f495809ea8f12cb8f15937e |
26 |
|
27 |
diff --git a/media-video/ffmpeg-chromium/ffmpeg-chromium-94.ebuild b/media-video/ffmpeg-chromium/ffmpeg-chromium-94.ebuild |
28 |
new file mode 100644 |
29 |
index 00000000000..ccadc52a33d |
30 |
--- /dev/null |
31 |
+++ b/media-video/ffmpeg-chromium/ffmpeg-chromium-94.ebuild |
32 |
@@ -0,0 +1,223 @@ |
33 |
+# Copyright 1999-2021 Gentoo Authors |
34 |
+# Distributed under the terms of the GNU General Public License v2 |
35 |
+ |
36 |
+EAPI=7 |
37 |
+ |
38 |
+inherit flag-o-matic toolchain-funcs |
39 |
+ |
40 |
+COMMIT="2d6591aa0835768c437c221c88840ac0c99a50dc" |
41 |
+DESCRIPTION="FFmpeg built specifically for codec support in Chromium-based browsers" |
42 |
+HOMEPAGE="https://ffmpeg.org/" |
43 |
+SRC_URI="https://dev.gentoo.org/~chewi/distfiles/${P}.tar.gz" |
44 |
+ |
45 |
+SLOT="${PV}" |
46 |
+LICENSE=" |
47 |
+ !gpl? ( LGPL-2.1 ) |
48 |
+ gpl? ( GPL-2 ) |
49 |
+" |
50 |
+ |
51 |
+KEYWORDS="~amd64 ~arm ~arm64" |
52 |
+ |
53 |
+# Options to use as use_enable in the foo[:bar] form. |
54 |
+# This will feed configure with $(use_enable foo bar) |
55 |
+# or $(use_enable foo foo) if no :bar is set. |
56 |
+# foo is added to IUSE. |
57 |
+FFMPEG_FLAG_MAP=( |
58 |
+ cpudetection:runtime-cpudetect debug |
59 |
+ +gpl |
60 |
+ vaapi vdpau vulkan |
61 |
+ # decoders |
62 |
+ mmal +opus:libopus |
63 |
+ video_cards_nvidia:ffnvcodec |
64 |
+ # Threads; we only support pthread for now but ffmpeg supports more |
65 |
+ +threads:pthreads |
66 |
+) |
67 |
+ |
68 |
+IUSE=" |
69 |
+ ${FFMPEG_FLAG_MAP[@]%:*} |
70 |
+" |
71 |
+ |
72 |
+# Strings for CPU features in the useflag[:configure_option] form |
73 |
+# if :configure_option isn't set, it will use 'useflag' as configure option |
74 |
+ARM_CPU_FEATURES=( |
75 |
+ cpu_flags_arm_thumb:armv5te |
76 |
+ cpu_flags_arm_v6:armv6 |
77 |
+ cpu_flags_arm_thumb2:armv6t2 |
78 |
+ cpu_flags_arm_neon:neon |
79 |
+ cpu_flags_arm_vfp:vfp |
80 |
+ cpu_flags_arm_vfpv3:vfpv3 |
81 |
+ cpu_flags_arm_v8:armv8 |
82 |
+) |
83 |
+ARM_CPU_REQUIRED_USE=" |
84 |
+ arm64? ( cpu_flags_arm_v8 ) |
85 |
+ cpu_flags_arm_v8? ( cpu_flags_arm_vfpv3 cpu_flags_arm_neon ) |
86 |
+ cpu_flags_arm_neon? ( cpu_flags_arm_thumb2 cpu_flags_arm_vfp ) |
87 |
+ cpu_flags_arm_vfpv3? ( cpu_flags_arm_vfp ) |
88 |
+ cpu_flags_arm_thumb2? ( cpu_flags_arm_v6 ) |
89 |
+ cpu_flags_arm_v6? ( cpu_flags_arm_thumb ) |
90 |
+" |
91 |
+X86_CPU_FEATURES_RAW=( 3dnow:amd3dnow 3dnowext:amd3dnowext aes:aesni avx:avx avx2:avx2 fma3:fma3 fma4:fma4 mmx:mmx mmxext:mmxext sse:sse sse2:sse2 sse3:sse3 ssse3:ssse3 sse4_1:sse4 sse4_2:sse42 xop:xop ) |
92 |
+X86_CPU_FEATURES=( ${X86_CPU_FEATURES_RAW[@]/#/cpu_flags_x86_} ) |
93 |
+X86_CPU_REQUIRED_USE=" |
94 |
+ cpu_flags_x86_avx2? ( cpu_flags_x86_avx ) |
95 |
+ cpu_flags_x86_fma4? ( cpu_flags_x86_avx ) |
96 |
+ cpu_flags_x86_fma3? ( cpu_flags_x86_avx ) |
97 |
+ cpu_flags_x86_xop? ( cpu_flags_x86_avx ) |
98 |
+ cpu_flags_x86_avx? ( cpu_flags_x86_sse4_2 ) |
99 |
+ cpu_flags_x86_aes? ( cpu_flags_x86_sse4_2 ) |
100 |
+ cpu_flags_x86_sse4_2? ( cpu_flags_x86_sse4_1 ) |
101 |
+ cpu_flags_x86_sse4_1? ( cpu_flags_x86_ssse3 ) |
102 |
+ cpu_flags_x86_ssse3? ( cpu_flags_x86_sse3 ) |
103 |
+ cpu_flags_x86_sse3? ( cpu_flags_x86_sse2 ) |
104 |
+ cpu_flags_x86_sse2? ( cpu_flags_x86_sse ) |
105 |
+ cpu_flags_x86_sse? ( cpu_flags_x86_mmxext ) |
106 |
+ cpu_flags_x86_mmxext? ( cpu_flags_x86_mmx ) |
107 |
+ cpu_flags_x86_3dnowext? ( cpu_flags_x86_3dnow ) |
108 |
+ cpu_flags_x86_3dnow? ( cpu_flags_x86_mmx ) |
109 |
+" |
110 |
+ |
111 |
+CPU_FEATURES_MAP=( |
112 |
+ ${ARM_CPU_FEATURES[@]} |
113 |
+ ${X86_CPU_FEATURES[@]} |
114 |
+) |
115 |
+IUSE="${IUSE} |
116 |
+ ${CPU_FEATURES_MAP[@]%:*}" |
117 |
+ |
118 |
+CPU_REQUIRED_USE=" |
119 |
+ ${ARM_CPU_REQUIRED_USE} |
120 |
+ ${X86_CPU_REQUIRED_USE} |
121 |
+" |
122 |
+ |
123 |
+RDEPEND=" |
124 |
+ mmal? ( media-libs/raspberrypi-userland ) |
125 |
+ opus? ( >=media-libs/opus-1.0.2-r2 ) |
126 |
+ vaapi? ( >=x11-libs/libva-1.2.1-r1:0= ) |
127 |
+ video_cards_nvidia? ( >=media-libs/nv-codec-headers-9.1.23.1 ) |
128 |
+ vdpau? ( >=x11-libs/libvdpau-0.7 ) |
129 |
+ vulkan? ( >=media-libs/vulkan-loader-1.1.97:= ) |
130 |
+" |
131 |
+ |
132 |
+DEPEND="${RDEPEND} |
133 |
+" |
134 |
+BDEPEND=" |
135 |
+ >=sys-devel/make-3.81 |
136 |
+ virtual/pkgconfig |
137 |
+ cpu_flags_x86_mmx? ( || ( >=dev-lang/nasm-2.13 >=dev-lang/yasm-1.3 ) ) |
138 |
+" |
139 |
+ |
140 |
+REQUIRED_USE=" |
141 |
+ ${CPU_REQUIRED_USE}" |
142 |
+RESTRICT=" |
143 |
+ test |
144 |
+" |
145 |
+ |
146 |
+S="${WORKDIR}" |
147 |
+ |
148 |
+PATCHES=( |
149 |
+ "${FILESDIR}"/${P}.patch |
150 |
+ "${FILESDIR}"/chromium.patch |
151 |
+) |
152 |
+ |
153 |
+src_prepare() { |
154 |
+ export revision=git-N-g${COMMIT:0:10} |
155 |
+ default |
156 |
+ echo 'include $(SRC_PATH)/ffbuild/libffmpeg.mak' >> Makefile || die |
157 |
+} |
158 |
+ |
159 |
+src_configure() { |
160 |
+ local myconf=( ) |
161 |
+ |
162 |
+ local ffuse=( "${FFMPEG_FLAG_MAP[@]}" ) |
163 |
+ |
164 |
+ for i in "${ffuse[@]#+}" ; do |
165 |
+ myconf+=( $(use_enable ${i%:*} ${i#*:}) ) |
166 |
+ done |
167 |
+ |
168 |
+ # CPU features |
169 |
+ for i in "${CPU_FEATURES_MAP[@]}" ; do |
170 |
+ use ${i%:*} || myconf+=( --disable-${i#*:} ) |
171 |
+ done |
172 |
+ |
173 |
+ # Try to get cpu type based on CFLAGS. |
174 |
+ # Bug #172723 |
175 |
+ # We need to do this so that features of that CPU will be better used |
176 |
+ # If they contain an unknown CPU it will not hurt since ffmpeg's configure |
177 |
+ # will just ignore it. |
178 |
+ for i in $(get-flag mcpu) $(get-flag march) ; do |
179 |
+ [[ ${i} = native ]] && i="host" # bug #273421 |
180 |
+ myconf+=( --cpu=${i} ) |
181 |
+ break |
182 |
+ done |
183 |
+ |
184 |
+ # LTO support, bug #566282, bug #754654 |
185 |
+ is-flagq "-flto*" && myconf+=( "--enable-lto" ) |
186 |
+ filter-flags "-flto*" |
187 |
+ |
188 |
+ # Mandatory configuration |
189 |
+ myconf=( |
190 |
+ --disable-stripping |
191 |
+ # This is only for hardcoded cflags; those are used in configure checks that may |
192 |
+ # interfere with proper detections, bug #671746 and bug #645778 |
193 |
+ # We use optflags, so that overrides them anyway. |
194 |
+ --disable-optimizations |
195 |
+ --disable-libcelt # bug #664158 |
196 |
+ "${myconf[@]}" |
197 |
+ ) |
198 |
+ |
199 |
+ # cross compile support |
200 |
+ if tc-is-cross-compiler ; then |
201 |
+ myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- --host-cc="$(tc-getBUILD_CC)" ) |
202 |
+ case ${CHOST} in |
203 |
+ *freebsd*) |
204 |
+ myconf+=( --target-os=freebsd ) |
205 |
+ ;; |
206 |
+ *mingw32*) |
207 |
+ myconf+=( --target-os=mingw32 ) |
208 |
+ ;; |
209 |
+ *linux*) |
210 |
+ myconf+=( --target-os=linux ) |
211 |
+ ;; |
212 |
+ esac |
213 |
+ fi |
214 |
+ |
215 |
+ set -- "${S}/configure" \ |
216 |
+ --prefix="${EPREFIX}/usr" \ |
217 |
+ --libdir="${EPREFIX}/usr/$(get_libdir)" \ |
218 |
+ --shlibdir="${EPREFIX}/usr/$(get_libdir)" \ |
219 |
+ --cc="$(tc-getCC)" \ |
220 |
+ --cxx="$(tc-getCXX)" \ |
221 |
+ --ar="$(tc-getAR)" \ |
222 |
+ --nm="$(tc-getNM)" \ |
223 |
+ --ranlib="$(tc-getRANLIB)" \ |
224 |
+ --pkg-config="$(tc-getPKG_CONFIG)" \ |
225 |
+ --optflags="${CFLAGS}" \ |
226 |
+ --disable-all \ |
227 |
+ --disable-autodetect \ |
228 |
+ --disable-error-resilience \ |
229 |
+ --disable-everything \ |
230 |
+ --disable-faan \ |
231 |
+ --disable-iconv \ |
232 |
+ --disable-lzo \ |
233 |
+ --disable-network \ |
234 |
+ --enable-avcodec \ |
235 |
+ --enable-avformat \ |
236 |
+ --enable-avutil \ |
237 |
+ --enable-decoder=aac,flac,h264,libopus,mp3,pcm_alaw,pcm_f32le,pcm_mulaw,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_s32le,pcm_u8,theora,vorbis,vp8 \ |
238 |
+ --enable-demuxer=aac,flac,matroska,mov,mp3,ogg,wav \ |
239 |
+ --enable-parser=aac,flac,h264,mpegaudio,opus,vorbis,vp3,vp8,vp9 \ |
240 |
+ --enable-pic \ |
241 |
+ --enable-static \ |
242 |
+ "${myconf[@]}" \ |
243 |
+ ${EXTRA_FFMPEG_CONF} |
244 |
+ |
245 |
+ echo "${@}" |
246 |
+ "${@}" || die |
247 |
+} |
248 |
+ |
249 |
+src_compile() { |
250 |
+ emake V=1 libffmpeg |
251 |
+} |
252 |
+ |
253 |
+src_install() { |
254 |
+ emake V=1 DESTDIR="${D}" install-libffmpeg |
255 |
+} |
256 |
|
257 |
diff --git a/media-video/ffmpeg-chromium/files/chromium.patch b/media-video/ffmpeg-chromium/files/chromium.patch |
258 |
new file mode 100644 |
259 |
index 00000000000..e24ea84b3df |
260 |
--- /dev/null |
261 |
+++ b/media-video/ffmpeg-chromium/files/chromium.patch |
262 |
@@ -0,0 +1,41 @@ |
263 |
+Allow libffmpeg to be built for Chromium-based browsers |
264 |
+https://patchwork.ffmpeg.org/patch/4500/ |
265 |
+ |
266 |
+NOTE: This patch lacks the Makefile include line. We append it |
267 |
+manually instead to make patching across different versions easier. |
268 |
+ |
269 |
+diff --git a/ffbuild/libffmpeg.mak b/ffbuild/libffmpeg.mak |
270 |
+new file mode 100644 |
271 |
+index 0000000..992cf3c |
272 |
+--- /dev/null |
273 |
++++ b/ffbuild/libffmpeg.mak |
274 |
+@@ -0,0 +1,27 @@ |
275 |
++LIBFFMPEG = $(SLIBPREF)ffmpeg$(SLIBSUF) |
276 |
++LIBFFMPEG_LINK = $(LD) -shared -Wl,-soname,$(LIBFFMPEG) -Wl,-Bsymbolic -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--gc-sections $(LDFLAGS) $(LDLIBFLAGS) -o $(LIBFFMPEG) |
277 |
++ |
278 |
++ifeq ($(CONFIG_SHARED),yes) |
279 |
++LIBFFMPEG_DEPS = libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavutil/$(SLIBPREF)avutil$(SLIBSUF) |
280 |
++else |
281 |
++LIBFFMPEG_DEPS = libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavutil/$(LIBPREF)avutil$(LIBSUF) |
282 |
++endif |
283 |
++ |
284 |
++$(LIBFFMPEG): $(LIBFFMPEG_DEPS) |
285 |
++ifeq ($(CONFIG_SHARED),yes) |
286 |
++ $(LIBFFMPEG_LINK) -Wl,--no-as-needed -lavcodec -lavformat -lavutil |
287 |
++else |
288 |
++ $(LIBFFMPEG_LINK) -Wl,--whole-archive $^ -Wl,--no-whole-archive $(EXTRALIBS-avcodec) $(EXTRALIBS-avformat) $(EXTRALIBS-avutil) |
289 |
++endif |
290 |
++ |
291 |
++libffmpeg: $(LIBFFMPEG) |
292 |
++ |
293 |
++install-libffmpeg: $(LIBFFMPEG) |
294 |
++ $(Q)mkdir -p "$(SHLIBDIR)/chromium" |
295 |
++ $(INSTALL) -m 755 $< "$(SHLIBDIR)/chromium/$<.$(SLOT)" |
296 |
++ $(STRIP) "$(SHLIBDIR)/chromium/$<.$(SLOT)" |
297 |
++ |
298 |
++uninstall-libffmpeg: |
299 |
++ $(RM) "$(SHLIBDIR)/chromium/$(LIBFFMPEG).$(SLOT)" |
300 |
++ |
301 |
++.PHONY: libffmpeg install-libffmpeg uninstall-libffmpeg |
302 |
+-- |
303 |
+2.13.1 |
304 |
|
305 |
diff --git a/media-video/ffmpeg-chromium/files/ffmpeg-chromium-94.patch b/media-video/ffmpeg-chromium/files/ffmpeg-chromium-94.patch |
306 |
new file mode 100644 |
307 |
index 00000000000..ba1dfd2c051 |
308 |
--- /dev/null |
309 |
+++ b/media-video/ffmpeg-chromium/files/ffmpeg-chromium-94.patch |
310 |
@@ -0,0 +1,26 @@ |
311 |
+--- FFmpeg-chromium/configure 2021-10-07 22:32:34.230130424 +0100 |
312 |
++++ FFmpeg/configure 2021-10-07 22:34:30.978861042 +0100 |
313 |
+@@ -6474,15 +6464,14 @@ |
314 |
+ { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } } |
315 |
+ enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++" |
316 |
+ enabled libopenvino && require libopenvino c_api/ie_c_api.h ie_c_api_version -linference_engine_c_api |
317 |
+-# Chromium uses a built in copy of libopus that is not visible to pkg-config. |
318 |
+-# enabled libopus && { |
319 |
+-# enabled libopus_decoder && { |
320 |
+-# require_pkg_config libopus opus opus_multistream.h opus_multistream_decoder_create |
321 |
+-# } |
322 |
+-# enabled libopus_encoder && { |
323 |
+-# require_pkg_config libopus opus opus_multistream.h opus_multistream_surround_encoder_create |
324 |
+-# } |
325 |
+-# } |
326 |
++enabled libopus && { |
327 |
++ enabled libopus_decoder && { |
328 |
++ require_pkg_config libopus opus opus_multistream.h opus_multistream_decoder_create |
329 |
++ } |
330 |
++ enabled libopus_encoder && { |
331 |
++ require_pkg_config libopus opus opus_multistream.h opus_multistream_surround_encoder_create |
332 |
++ } |
333 |
++} |
334 |
+ enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new |
335 |
+ enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection |
336 |
+ enabled librav1e && require_pkg_config librav1e "rav1e >= 0.4.0" rav1e.h rav1e_context_new |
337 |
|
338 |
diff --git a/media-video/ffmpeg-chromium/metadata.xml b/media-video/ffmpeg-chromium/metadata.xml |
339 |
new file mode 100644 |
340 |
index 00000000000..5e0aeba3b15 |
341 |
--- /dev/null |
342 |
+++ b/media-video/ffmpeg-chromium/metadata.xml |
343 |
@@ -0,0 +1,14 @@ |
344 |
+<?xml version="1.0" encoding="UTF-8"?> |
345 |
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> |
346 |
+<pkgmetadata> |
347 |
+<maintainer type="person"> |
348 |
+ <email>chewi@g.o</email> |
349 |
+ <name>James Le Cuirot</name> |
350 |
+</maintainer> |
351 |
+<use> |
352 |
+ <flag name="cpudetection">Enables runtime CPU detection (useful for bindist, compatibility on other CPUs)</flag> |
353 |
+ <flag name="gpl">Build GPL code. Should be enabled unless you require LGPL binaries.</flag> |
354 |
+ <flag name="mmal">Enables Multi-Media Abstraction Layer (MMAL) decoding support: Available e.g. on the Raspberry Pi.</flag> |
355 |
+ <flag name="vulkan">Enables support for the vulkan API for GPU offload.</flag> |
356 |
+</use> |
357 |
+</pkgmetadata> |