1 |
commit: e63a1ba6346da70d5a896393f0c28cef6a6fd868 |
2 |
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jul 24 21:53:18 2017 +0000 |
4 |
Commit: Alexis Ballier <aballier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 27 06:33:37 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e63a1ba6 |
7 |
|
8 |
media-video/ffmpeg: Allow building libffmpeg for Chromium via USE flag |
9 |
|
10 |
Chromium is built from source and therefore can be built against the |
11 |
system ffmpeg. Google Chrome already ships with support for |
12 |
proprietary codecs and has libffmpeg.so built in. |
13 |
|
14 |
Opera and Vivaldi, on the other hand, do not support proprietary |
15 |
codecs and actively encourage you to replace the libffmpeg.so they |
16 |
provide. Official instructions involve downloading the huge Chromium |
17 |
tarball and building tons of baggage that you don't actually need, |
18 |
despite the fact that libffmpeg.so is really just the main ffmpeg |
19 |
libraries combined. |
20 |
|
21 |
In order to build this, I felt it was worthwhile leveraging our |
22 |
existing feature-rich ffmpeg package rather than duplicating it or |
23 |
creating some poor imitation. This commit shows what little extra code |
24 |
is required. |
25 |
|
26 |
It would be possible to link to the regular libraries directly instead |
27 |
of buildling additional copies if it weren't for the fact that these |
28 |
browsers are usually built with -DFF_API_CONVERGENCE_DURATION=0, |
29 |
making the ABI incompatible, at least until libavcodec hits 59. |
30 |
|
31 |
That aside, all Chromium versions between 59 and 61 (maybe earlier?) |
32 |
use the 55.57.57 ffmpeg ABI found in the 3.x series. Having these |
33 |
browsers optionally RDEPEND on ffmpeg:0/55.57.57[chromium] should |
34 |
therefore not be a problem for the time being. They simply need to |
35 |
provide a symlink. |
36 |
|
37 |
I have tested this with current versions of vivaldi, vivaldi-snapshot, |
38 |
opera, opera-beta, and opera-developer. None were able to play videos |
39 |
on news.bbc.co.uk without Flash until swapping in this library. |
40 |
|
41 |
It has been noted that Vivaldi could potentially be built from |
42 |
source. I may explore this possibility but I believe this change is |
43 |
still useful, especially as some lack sufficient hardware to build |
44 |
these browsers from source. |
45 |
|
46 |
Package-Manager: Portage-2.3.6, Repoman-2.3.2 |
47 |
|
48 |
media-video/ffmpeg/ffmpeg-9999.ebuild | 34 ++++++++++++++++++++++++- |
49 |
media-video/ffmpeg/files/chromium.patch | 45 +++++++++++++++++++++++++++++++++ |
50 |
media-video/ffmpeg/metadata.xml | 1 + |
51 |
3 files changed, 79 insertions(+), 1 deletion(-) |
52 |
|
53 |
diff --git a/media-video/ffmpeg/ffmpeg-9999.ebuild b/media-video/ffmpeg/ffmpeg-9999.ebuild |
54 |
index e2ab9a865dc..55572458a50 100644 |
55 |
--- a/media-video/ffmpeg/ffmpeg-9999.ebuild |
56 |
+++ b/media-video/ffmpeg/ffmpeg-9999.ebuild |
57 |
@@ -96,7 +96,7 @@ FFMPEG_ENCODER_FLAG_MAP=( |
58 |
) |
59 |
|
60 |
IUSE=" |
61 |
- alsa doc +encode jack oss pic static-libs test v4l |
62 |
+ alsa chromium doc +encode jack oss pic static-libs test v4l |
63 |
${FFMPEG_FLAG_MAP[@]%:*} |
64 |
${FFMPEG_ENCODER_FLAG_MAP[@]%:*} |
65 |
" |
66 |
@@ -289,6 +289,10 @@ RESTRICT=" |
67 |
|
68 |
S=${WORKDIR}/${P/_/-} |
69 |
|
70 |
+PATCHES=( |
71 |
+ "${FILESDIR}"/chromium.patch |
72 |
+) |
73 |
+ |
74 |
MULTILIB_WRAPPED_HEADERS=( |
75 |
/usr/include/libavutil/avconfig.h |
76 |
) |
77 |
@@ -419,6 +423,20 @@ multilib_src_configure() { |
78 |
"${myconf[@]}" |
79 |
echo "${@}" |
80 |
"${@}" || die |
81 |
+ |
82 |
+ if multilib_is_native_abi && use chromium; then |
83 |
+ einfo "Configuring for Chromium" |
84 |
+ mkdir -p ../chromium || die |
85 |
+ pushd ../chromium >/dev/null || die |
86 |
+ set -- "${@}" \ |
87 |
+ --disable-shared \ |
88 |
+ --enable-static \ |
89 |
+ --enable-pic \ |
90 |
+ --extra-cflags="-DFF_API_CONVERGENCE_DURATION=0" |
91 |
+ echo "${@}" |
92 |
+ "${@}" || die |
93 |
+ popd >/dev/null || die |
94 |
+ fi |
95 |
} |
96 |
|
97 |
multilib_src_compile() { |
98 |
@@ -430,6 +448,13 @@ multilib_src_compile() { |
99 |
emake V=1 tools/${i} |
100 |
fi |
101 |
done |
102 |
+ |
103 |
+ if use chromium; then |
104 |
+ einfo "Compiling for Chromium" |
105 |
+ pushd ../chromium >/dev/null || die |
106 |
+ emake V=1 libffmpeg |
107 |
+ popd >/dev/null || die |
108 |
+ fi |
109 |
fi |
110 |
} |
111 |
|
112 |
@@ -442,6 +467,13 @@ multilib_src_install() { |
113 |
dobin tools/${i} |
114 |
fi |
115 |
done |
116 |
+ |
117 |
+ if use chromium; then |
118 |
+ einfo "Installing for Chromium" |
119 |
+ pushd ../chromium >/dev/null || die |
120 |
+ emake V=1 DESTDIR="${D}" install-libffmpeg |
121 |
+ popd >/dev/null || die |
122 |
+ fi |
123 |
fi |
124 |
} |
125 |
|
126 |
|
127 |
diff --git a/media-video/ffmpeg/files/chromium.patch b/media-video/ffmpeg/files/chromium.patch |
128 |
new file mode 100644 |
129 |
index 00000000000..bc8b8d38698 |
130 |
--- /dev/null |
131 |
+++ b/media-video/ffmpeg/files/chromium.patch |
132 |
@@ -0,0 +1,45 @@ |
133 |
+Allow libffmpeg to be built for Chromium-based browsers |
134 |
+https://patchwork.ffmpeg.org/patch/4500/ |
135 |
+ |
136 |
+diff --git a/Makefile b/Makefile |
137 |
+index 29870d7..1e267e7 100644 |
138 |
+--- a/Makefile |
139 |
++++ b/Makefile |
140 |
+@@ -65,6 +65,7 @@ all: all-yes |
141 |
+ |
142 |
+ include $(SRC_PATH)/tools/Makefile |
143 |
+ include $(SRC_PATH)/ffbuild/common.mak |
144 |
++include $(SRC_PATH)/ffbuild/libffmpeg.mak |
145 |
+ |
146 |
+ FF_EXTRALIBS := $(FFEXTRALIBS) |
147 |
+ FF_DEP_LIBS := $(DEP_LIBS) |
148 |
+diff --git a/ffbuild/libffmpeg.mak b/ffbuild/libffmpeg.mak |
149 |
+new file mode 100644 |
150 |
+index 0000000..992cf3c |
151 |
+--- /dev/null |
152 |
++++ b/ffbuild/libffmpeg.mak |
153 |
+@@ -0,0 +1,21 @@ |
154 |
++LIBFFMPEG = $(SLIBPREF)ffmpeg$(SLIBSUF) |
155 |
++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) |
156 |
++ |
157 |
++libffmpeg-: libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavutil/$(LIBPREF)avutil$(LIBSUF) libswresample/$(LIBPREF)swresample$(LIBSUF) |
158 |
++ $(LIBFFMPEG_LINK) -Wl,--whole-archive $^ -Wl,--no-whole-archive $(FFEXTRALIBS) |
159 |
++ |
160 |
++libffmpeg-yes: libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavutil/$(SLIBPREF)avutil$(SLIBSUF) |
161 |
++ $(LIBFFMPEG_LINK) -Wl,--no-as-needed -lavcodec -lavformat -lavutil |
162 |
++ |
163 |
++$(LIBFFMPEG): libffmpeg-$(CONFIG_SHARED) |
164 |
++libffmpeg: $(LIBFFMPEG) |
165 |
++ |
166 |
++install-libffmpeg: $(LIBFFMPEG) |
167 |
++ $(Q)mkdir -p "$(SHLIBDIR)/chromium" |
168 |
++ $(INSTALL) -m 755 $< "$(SHLIBDIR)/chromium/$<" |
169 |
++ $(STRIP) "$(SHLIBDIR)/chromium/$<" |
170 |
++ |
171 |
++uninstall-libffmpeg: |
172 |
++ $(RM) "$(SHLIBDIR)/chromium/$(LIBFFMPEG)" |
173 |
++ |
174 |
++.PHONY: libffmpeg libffmpeg-* install-libffmpeg |
175 |
+-- |
176 |
+2.13.1 |
177 |
+ |
178 |
|
179 |
diff --git a/media-video/ffmpeg/metadata.xml b/media-video/ffmpeg/metadata.xml |
180 |
index b8773a83a67..ef95f758afd 100644 |
181 |
--- a/media-video/ffmpeg/metadata.xml |
182 |
+++ b/media-video/ffmpeg/metadata.xml |
183 |
@@ -17,6 +17,7 @@ |
184 |
<flag name="cdio">Enables audio CD grabbing with <pkg>dev-libs/libcdio</pkg>.</flag> |
185 |
<flag name="celt">Adds Xiph CELT audio decoding support via <pkg>media-libs/celt</pkg></flag> |
186 |
<flag name="chromaprint">Enables audio fingerprinting support with <pkg>media-libs/chromaprint</pkg>.</flag> |
187 |
+ <flag name="chromium">Builds libffmpeg.so to enable media playback in Chromium-based browsers like Opera and Vivaldi.</flag> |
188 |
<flag name="cpudetection">Enables runtime CPU detection (useful for bindist, compatibility on other CPUs)</flag> |
189 |
<flag name="ebur128">Enables EBU R128 loudness normalization filter via <pkg>media-libs/libebur128</pkg></flag> |
190 |
<flag name="faac">Use external faac library for AAC encoding</flag> |