···
# Processing, video codecs, containers
···
# for now we disable GTK GUI support on Darwin. (It may be possible to remove
# this restriction later.)
, useGtk ? !stdenv.isDarwin
···
+
hash = "sha256-4Q//UU/CPgWvhtpROfNPLzBvZlB02hbFe9Z9FA7mX04=";
# Handbrake maintains a set of ffmpeg patches. In particular, these
# patches are required for subtitle timing to work correctly. See:
# https://github.com/HandBrake/HandBrake/issues/4029
+
# base ffmpeg version is specified in:
+
# https://github.com/HandBrake/HandBrake/blob/master/contrib/ffmpeg/module.defs
+
ffmpeg-version = "6.1";
+
ffmpeg-hb = ffmpeg-full.overrideAttrs (old: {
version = ffmpeg-version;
url = "https://www.ffmpeg.org/releases/ffmpeg-${ffmpeg-version}.tar.bz2";
+
hash = "sha256-632j3n3TzkiplGq0R6c0a9EaOoXm77jyws5jfn9UdhE=";
+
patches = (old.patches or [ ]) ++ [
+
"${src}/contrib/ffmpeg/A01-mov-read-name-track-tag-written-by-movenc.patch"
+
"${src}/contrib/ffmpeg/A02-movenc-write-3gpp-track-titl-tag.patch"
+
"${src}/contrib/ffmpeg/A03-mov-read-3gpp-udta-tags.patch"
+
"${src}/contrib/ffmpeg/A04-movenc-write-3gpp-track-names-tags-for-all-available.patch"
+
"${src}/contrib/ffmpeg/A05-dvdsubdec-fix-processing-of-partial-packets.patch"
+
"${src}/contrib/ffmpeg/A06-dvdsubdec-return-number-of-bytes-used.patch"
+
"${src}/contrib/ffmpeg/A07-dvdsubdec-use-pts-of-initial-packet.patch"
+
"${src}/contrib/ffmpeg/A08-ccaption_dec-fix-pts-in-real_time-mode.patch"
+
"${src}/contrib/ffmpeg/A09-matroskaenc-aac-extradata-updated.patch"
+
"${src}/contrib/ffmpeg/A10-amfenc-Add-support-for-pict_type-field.patch"
+
"${src}/contrib/ffmpeg/A11-amfenc-Fixes-the-color-information-in-the-ou.patch"
+
"${src}/contrib/ffmpeg/A12-amfenc-HDR-metadata.patch"
+
"${src}/contrib/ffmpeg/A13-libavcodec-amfenc-Fix-issue-with-missing-headers-in-.patch"
+
"${src}/contrib/ffmpeg/A14-avcodec-add-ambient-viewing-environment-packet-side-.patch"
+
"${src}/contrib/ffmpeg/A15-avformat-mov-add-support-for-amve-ambient-viewing-en.patch"
+
"${src}/contrib/ffmpeg/A16-videotoolbox-dec-h264.patch"
+
# patch to fix <https://github.com/HandBrake/HandBrake/issues/5011>
+
# commented out because it causes ffmpeg's filter-pixdesc-p010le test to fail.
+
# "${src}/contrib/ffmpeg/A17-libswscale-fix-yuv420p-to-p01xle-color-conversion-bu.patch"
+
"${src}/contrib/ffmpeg/A18-qsv-fix-decode-10bit-hdr.patch"
+
"${src}/contrib/ffmpeg/A19-ffbuild-common-use-gzip-n-flag-for-cuda.patch"
+
x265-hb = x265.overrideAttrs (old: {
+
# nixpkgs' x265 sourceRoot is x265-.../source whereas handbrake's x265 patches
+
# are written with respect to the parent directory instead of that source directory.
+
# patches which don't cleanly apply are commented out.
+
postPatch = (old.postPatch or "") + ''
+
# patch -p1 < ${src}/contrib/x265/A00-crosscompile-fix.patch
+
patch -p1 < ${src}/contrib/x265/A01-threads-priority.patch
+
patch -p1 < ${src}/contrib/x265/A02-threads-pool-adjustments.patch
+
patch -p1 < ${src}/contrib/x265/A03-sei-length-crash-fix.patch
+
patch -p1 < ${src}/contrib/x265/A04-ambient-viewing-enviroment-sei.patch
+
# patch -p1 < ${src}/contrib/x265/A05-memory-leaks.patch
versionFile = writeText "version.txt" ''
···
# Use the Nix-provided libxml2 instead of the system-provided one.
substituteInPlace libhb/module.defs \
--replace /usr/include/libxml2 ${libxml2.dev}/include/libxml2
+
'' + optionalString useGtk ''
+
substituteInPlace gtk/module.rules \
+
--replace-fail '$(MESON.exe)' 'meson' \
+
--replace-fail '$(NINJA.exe)' 'ninja' \
+
# Force using nixpkgs dependencies
+
substituteInPlace gtk/meson.build \
+
--replace-fail "cc.find_library('bz2', dirs: hb_libdirs)" "cc.find_library('bz2')" \
+
--replace-fail "cc.find_library('mp3lame', dirs: hb_libdirs)" "cc.find_library('mp3lame')" \
+
"hb_incdirs = include_directories(hb_dir / 'libhb', hb_dir / 'contrib/include')" \
+
"hb_incdirs = include_directories(hb_dir / 'libhb')" \
···
+
++ optionals useGtk [ desktop-file-utils intltool meson ninja wrapGAppsHook ];
···
++ optional (!stdenv.isDarwin) numactl
gst_all_1.gst-plugins-base
···
++ optional (!useGtk) "--disable-gtk"
++ optional useFdk "--enable-fdk-aac"
···
# NOTE: 2018-12-27: Check NixOS HandBrake test if changing
NIX_LDFLAGS = [ "-lx265" ];
+
# meson/ninja are used only for the subprojects, not the toplevel
+
dontUseMesonConfigure = true;
+
dontUseMesonInstall = true;
+
dontUseNinjaBuild = true;
+
dontUseNinjaInstall = true;
makeFlags = [ "--directory=build" ];
+
inherit ffmpeg-hb x265-hb;
+
tests.basic-conversion =
# Big Buck Bunny example, licensed under CC Attribution 3.0.
···
HandBrakeCLI -i ${testMkv} -o test.mkv -e x264 -q 20 -B 160
+
tests.version = testers.testVersion { package = self; command = "HandBrakeCLI --version"; };
···
license = licenses.gpl2Only;
maintainers = with maintainers; [ Anton-Latukha wmertens ];
platforms = with platforms; unix;
+
broken = stdenv.isDarwin; # https://github.com/NixOS/nixpkgs/pull/297984#issuecomment-2016503434