1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{10..13} )
8 inherit edo flag-o-matic multiprocessing python-any-r1 toolchain-funcs xdg
10 DESCRIPTION="Open-source, GPL-licensed, multiplatform, multithreaded video transcoder"
11 HOMEPAGE="https://handbrake.fr/ https://github.com/HandBrake/HandBrake"
13 if [[ ${PV} == *9999* ]]; then
14 EGIT_REPO_URI="https://github.com/HandBrake/HandBrake.git"
17 MY_P="HandBrake-${PV}"
18 SRC_URI="https://github.com/HandBrake/HandBrake/releases/download/${PV}/${MY_P}-source.tar.bz2 -> ${P}.tar.bz2"
19 S="${WORKDIR}/${MY_P}"
20 KEYWORDS="~amd64 ~arm64 ~x86"
23 # contrib/<project>/module.defs
25 # Heavily patched in an incompatible way.
26 # Issues related to using system ffmpeg historically.
27 # See bug #829595 and #922828
28 [ffmpeg]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/ffmpeg-7.1.tar.bz2;"
29 # Patched in an incompatible way
30 [x265]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
31 [x265_8bit]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
32 [x265_10bit]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
33 [x265_12bit]="https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs2/x265_4.1.tar.gz;x265"
37 for name in "${!BUNDLED[@]}"; do
38 IFS=$';' read -r uri use <<< ${BUNDLED[${name}]}
39 local tarball=${uri##*/}
40 if [[ -n ${use} ]]; then
41 SRC_URI+=" ${use}? ( ${uri} -> handbrake-${tarball} )"
43 SRC_URI+=" ${uri} -> handbrake-${tarball}"
52 IUSE="amf +fdk gui libdovi numa nvenc qsv x265"
54 REQUIRED_USE="numa? ( x265 )"
58 >=app-arch/xz-utils-5.2.6
60 >=media-libs/dav1d-1.0.0:=
61 >=media-libs/libjpeg-turbo-2.1.4:=
62 >=media-libs/libass-0.16.0:=
63 >=media-libs/libbluray-1.3.4:=
65 >=media-libs/libdvdread-6.1.3:=
68 >=media-libs/libvpx-1.12.0:=
70 >=media-libs/speex-1.2.1
71 >=media-libs/svt-av1-1.4.1:=
72 >=media-libs/x264-0.0.20220222:=
73 >=media-libs/zimg-3.0.4
76 fdk? ( media-libs/fdk-aac:= )
77 libdovi? ( media-libs/libdovi:= )
79 >=gui-libs/gtk-4.4:4[gstreamer]
81 >=dev-libs/libxml2-2.10.3
85 numa? ( sys-process/numactl )
86 nvenc? ( media-libs/nv-codec-headers )
94 amf? ( media-video/amdgpu-pro-amf )
98 amf? ( media-libs/amf-headers )
100 # cmake needed for custom script: bug #852701
112 "${FILESDIR}"/handbrake-1.9.0-link-libdovi-properly.patch
113 "${FILESDIR}"/handbrake-1.9.0-include-vpl-properly.patch
117 if [[ ${PV} == 9999 ]]; then
125 mkdir download || die
126 for name in "${!BUNDLED[@]}"; do
127 IFS=$';' read -r uri use <<< ${BUNDLED[${name}]}
128 local tarball="${uri##*/}"
129 if [[ -n ${use} ]]; then
130 use ${use} || continue
132 cp "${DISTDIR}/handbrake-${tarball}" download/${tarball} || die
135 # Get rid of leftover bundled library build definitions
137 -e "/MODULES \+= contrib\// { /($(IFS=$'|'; echo "${!BUNDLED[*]}"))$/! d }" \
138 "${S}"/make/include/main.defs || die
141 sed -i -e '/DF..*.exe/ { s/= .*/= true/ }' make/include/tool.defs || die
145 -e "s/\(strip\s*= ToolProbe( 'STRIP.exe',\s*'strip',\s*\)'strip'/\1'true'/" \
146 make/configure.py || die
148 # Use whichever python is set by portage
149 sed -i -e "s/for p in .*/for p in ${EPYTHON}/" configure || die
151 for tool in ar ranlib libtool; do
152 # Detect system tools - bug 738110
154 -e "s/\(${tool}\s*= ToolProbe( '${tool^^}.exe',\s*'${tool}',\s*\)'${tool}'/\1os.environ.get('${tool^^}', '${tool}')/" \
155 make/configure.py || die
164 # ODR violations, lto-type-mismatches
173 --launch-jobs=$(get_makeopts_jobs)
174 --prefix="${EPREFIX}/usr"
176 --no-harden #bug #890279
177 $(use_enable amf vce)
178 $(use_enable fdk fdk-aac)
179 $(use_enable gui gtk)
180 $(use_enable libdovi)
187 edo ./configure ${myconfargs[@]}
195 emake -C build DESTDIR="${D}" install
196 dodoc README.markdown AUTHORS.markdown NEWS.markdown THANKS.markdown
200 einfo "Gentoo builds of HandBrake are NOT SUPPORTED by upstream as they"
201 einfo "do not use the bundled (and often patched) upstream libraries."
203 einfo "Please do not raise bugs with upstream because of these ebuilds,"
204 einfo "report bugs to Gentoo's bugzilla or Multimedia forum instead."
206 einfo "For the CLI version of HandBrake, you can use \`HandBrakeCLI\`."
208 einfo "For the GUI version of HandBrake, you can run \`ghb\`."