From 767cf0c71478fdd63debbd9fdb45907cbb497edb Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 2 Mar 2024 20:18:28 -0500 Subject: [PATCH] av1an: init at 0.4.2 --- pkgs/by-name/av/av1an-unwrapped/package.nix | 58 ++++++++++++++++ pkgs/by-name/av/av1an/package.nix | 77 +++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 pkgs/by-name/av/av1an-unwrapped/package.nix create mode 100644 pkgs/by-name/av/av1an/package.nix diff --git a/pkgs/by-name/av/av1an-unwrapped/package.nix b/pkgs/by-name/av/av1an-unwrapped/package.nix new file mode 100644 index 000000000000..df9364d17e1d --- /dev/null +++ b/pkgs/by-name/av/av1an-unwrapped/package.nix @@ -0,0 +1,58 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + ffmpeg, + nasm, + vapoursynth, + libaom, + rav1e, + nix-update-script, +}: +rustPlatform.buildRustPackage rec { + pname = "av1an-unwrapped"; + version = "0.4.2"; + + src = fetchFromGitHub { + owner = "master-of-zen"; + repo = "av1an"; + rev = version; + hash = "sha256-A4/1UdM8N5CHP44PBNB+ZH2Gcl84rcpUBwQRSnubBGc="; + }; + + cargoHash = "sha256-ahoiCAUREtXgXLNrWVQ2Gc65bWMo4pIJXP9xjnQAlaI="; + + nativeBuildInputs = [ + rustPlatform.bindgenHook + pkg-config + nasm + ]; + + buildInputs = [ + ffmpeg + vapoursynth + ]; + + nativeCheckInputs = [ + libaom + rav1e + ]; + + passthru = { + updateScript = nix-update-script { }; + }; + + meta = { + description = "Cross-platform command-line encoding framework"; + longDescription = '' + Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding. + It can increase your encoding speed and improve cpu utilization by running multiple encoder processes in parallel. + ''; + homepage = "https://github.com/master-of-zen/Av1an"; + changelog = "https://github.com/master-of-zen/Av1an/releases/tag/${src.rev}"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ getchoo ]; + mainProgram = "av1an"; + }; +} diff --git a/pkgs/by-name/av/av1an/package.nix b/pkgs/by-name/av/av1an/package.nix new file mode 100644 index 000000000000..ec3a4d66ae8b --- /dev/null +++ b/pkgs/by-name/av/av1an/package.nix @@ -0,0 +1,77 @@ +{ + lib, + symlinkJoin, + makeBinaryWrapper, + testers, + av1an-unwrapped, + ffmpeg, + python3Packages, + libaom, + svt-av1, + rav1e, + libvpx, + x264, + x265, + libvmaf, + withAom ? true, # AV1 reference encoder + withSvtav1 ? false, # AV1 encoder/decoder (focused on speed and correctness) + withRav1e ? false, # AV1 encoder (focused on speed and safety) + withVpx ? true, # VP8 & VP9 de/encoding + withX264 ? true, # H.264/AVC encoder + withX265 ? true, # H.265/HEVC encoder + withVmaf ? false, # Perceptual video quality assessment algorithm +}: +# av1an requires at least one encoder +assert lib.assertMsg (lib.elem true [ + withAom + withSvtav1 + withRav1e + withVpx + withX264 + withX265 +]) "At least one encoder is required!"; +symlinkJoin { + name = "av1an-${av1an-unwrapped.version}"; + + paths = [ av1an-unwrapped ]; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + postBuild = + let + runtimePrograms = + [ (ffmpeg.override { inherit withVmaf; }) ] + ++ lib.optional withAom libaom + ++ lib.optional withSvtav1 svt-av1 + ++ lib.optional withRav1e rav1e + ++ lib.optional withVpx libvpx + ++ lib.optional withX264 x264 + ++ lib.optional withX265 x265 + ++ lib.optional withVmaf libvmaf; + in + '' + wrapProgram $out/bin/av1an \ + --prefix PATH : ${lib.makeBinPath runtimePrograms} \ + --prefix PYTHONPATH : ${python3Packages.makePythonPath [ python3Packages.vapoursynth ]} + ''; + + passthru = { + # TODO: uncomment when upstream actually bumps CARGO_PKG_VERSION + #tests.version = testers.testVersion { + # package = av1an; + # inherit (av1an-unwrapped) version; + #}; + }; + + meta = { + inherit (av1an-unwrapped.meta) + description + longDescription + homepage + changelog + license + maintainers + mainProgram + ; + }; +}