Unverified Commit 36811450 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

Merge pull request #314397 from qubitnano/pr/handbrake

handbrake: 1.7.3 -> 1.8.0
parents af13d4e6 2e31e2ee
Loading
Loading
Loading
Loading
+44 −44
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
, numactl
, writeText
  # Processing, video codecs, containers
, ffmpeg-full
, ffmpeg_7-full
, nv-codec-headers
, libogg
, x264
@@ -69,14 +69,14 @@
  # for now we disable GTK GUI support on Darwin. (It may be possible to remove
  # this restriction later.)
, useGtk ? !stdenv.isDarwin
, bzip2
, appstream
, desktop-file-utils
, meson
, ninja
, wrapGAppsHook3
, wrapGAppsHook4
, intltool
, glib
, gtk3
, gtk4
, libappindicator-gtk3
, libnotify
, gst_all_1
@@ -90,13 +90,14 @@
}:

let
  version = "1.7.3";
  version = "1.8.0";

  src = fetchFromGitHub {
    owner = "HandBrake";
    repo = "HandBrake";
    rev = version;
    hash = "sha256-4Q//UU/CPgWvhtpROfNPLzBvZlB02hbFe9Z9FA7mX04=";
    # uses version commit for logic in version.txt
    rev = "5edf59c1da54fe1c9a487d09e8f52561fe49cb2a";
    hash = "sha256-gr2UhqPY5mZOP8KBvk9yydl4AkTlqE83hYAcLwSv1Is=";
  };

  # Handbrake maintains a set of ffmpeg patches. In particular, these
@@ -104,12 +105,12 @@ let
  # 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: {
  ffmpeg-version = "7.0";
  ffmpeg-hb = ffmpeg_7-full.overrideAttrs (old: {
    version = ffmpeg-version;
    src = fetchurl {
      url = "https://www.ffmpeg.org/releases/ffmpeg-${ffmpeg-version}.tar.bz2";
      hash = "sha256-632j3n3TzkiplGq0R6c0a9EaOoXm77jyws5jfn9UdhE=";
      hash = "sha256-ok2QdL9VI6Zaqp570Cr+QQnOedab130QT+09q0uTTXo=";
    };
    patches = (old.patches or [ ]) ++ [
      "${src}/contrib/ffmpeg/A01-mov-read-name-track-tag-written-by-movenc.patch"
@@ -119,22 +120,23 @@ let
      "${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"
      "${src}/contrib/ffmpeg/A08-dvdsubdec-do-not-discard-zero-sized-rects.patch"
      "${src}/contrib/ffmpeg/A09-ccaption_dec-fix-pts-in-real_time-mode.patch"
      "${src}/contrib/ffmpeg/A10-matroskaenc-aac-extradata-updated.patch"
      "${src}/contrib/ffmpeg/A11-videotoolbox-disable-H.264-10-bit-on-Intel-macOS.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/A12-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"
      "${src}/contrib/ffmpeg/A13-qsv-fix-decode-10bit-hdr.patch"
      "${src}/contrib/ffmpeg/A14-amfenc-Add-support-for-pict_type-field.patch"
      "${src}/contrib/ffmpeg/A15-amfenc-Fixes-the-color-information-in-the-ou.patch"
      "${src}/contrib/ffmpeg/A16-amfenc-HDR-metadata.patch"
      "${src}/contrib/ffmpeg/A17-av1dec-dovi-rpu.patch"
      "${src}/contrib/ffmpeg/A18-avformat-mov-add-support-audio-fallback-track-ref.patch"
      "${src}/contrib/ffmpeg/A19-mov-ignore-old-infe-box.patch"
      "${src}/contrib/ffmpeg/A20-mov-free-infe-on-failure.patch"
    ];
  });

@@ -144,24 +146,26 @@ let
    # patches which don't cleanly apply are commented out.
    postPatch = (old.postPatch or "") + ''
      pushd ..
      # 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
      # patch -p1 < ${src}/contrib/x265/A06-crosscompile-fix.patch
      popd
    '';
  });

  versionFile = writeText "version.txt" ''
    BRANCH=${versions.majorMinor version}.x
    DATE=1970-01-01 00:00:01 +0000
    URL=${src.meta.homepage}.git
    HASH=${src.rev}
    REV=${src.rev}
    SHORTHASH=${src.rev}
    SHORTHASH=${lib.substring 0 9 src.rev}
    TAG=${version}
    URL=${src.meta.homepage}
    TAG_HASH=${src.rev}
    REV=0
    BRANCH=
    REMOTE=${src.meta.homepage}.git
    DATE=1970-01-01 00:00:01 +0000
  '';

  inherit (lib) optional optionals optionalString versions;
@@ -176,9 +180,10 @@ let
      install -Dm444 ${versionFile} ${versionFile.name}

      patchShebangs scripts
      patchShebangs gtk/data/

      substituteInPlace libhb/hb.c \
        --replace 'return hb_version;' 'return "${version}";'
        --replace-fail 'return hb_version;' 'return "${version}";'

      # Force using nixpkgs dependencies
      sed -i '/MODULES += contrib/d' make/include/main.defs
@@ -186,30 +191,23 @@ let
          -e '/    ## Additional library and tool checks/,/    ## MinGW specific library and tool checks/d' \
          -i make/configure.py
    '' + optionalString stdenv.isDarwin ''
      # Use the Nix-provided libxml2 instead of the patched version available on
      # the Handbrake website.
      substituteInPlace libhb/module.defs \
        --replace '$(CONTRIB.build/)include/libxml2' ${libxml2.dev}/include/libxml2

      # Prevent the configure script from failing if xcodebuild isn't available,
      # which it isn't in the Nix context. (The actual build goes fine without
      # xcodebuild.)
      sed -e '/xcodebuild = ToolProbe/s/abort=.\+)/abort=False)/' -i make/configure.py
    '' + optionalString stdenv.isLinux ''
      # 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')" \
        --replace-fail \
          "hb_incdirs = include_directories(hb_dir / 'libhb', hb_dir / 'contrib/include')" \
          "hb_incdirs = include_directories(hb_dir / 'libhb')" \
          "hb_incdirs = include_directories(hb_dir / 'libhb')"
      substituteInPlace gtk/ghb.spec \
        --replace-fail "gtk-update-icon-cache" "gtk4-update-icon-cache"
      substituteInPlace gtk/data/post_install.py \
        --replace-fail "gtk-update-icon-cache" "gtk4-update-icon-cache"
    '';

    nativeBuildInputs = [
@@ -220,7 +218,7 @@ let
      pkg-config
      python3
    ]
    ++ optionals useGtk [ desktop-file-utils intltool meson ninja wrapGAppsHook3 ];
    ++ optionals useGtk [ appstream desktop-file-utils intltool meson ninja wrapGAppsHook4 ];

    buildInputs = [
      a52dec
@@ -255,12 +253,14 @@ let
    ]
    ++ optional (!stdenv.isDarwin) numactl
    ++ optionals useGtk [
      bzip2
      dbus-glib
      glib
      gst_all_1.gst-libav
      gst_all_1.gst-plugins-bad
      gst_all_1.gst-plugins-base
      gst_all_1.gst-plugins-good
      gst_all_1.gstreamer
      gtk3
      gtk4
      hicolor-icon-theme
      libappindicator-gtk3
      libgudev