diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/video/mpv')
27 files changed, 1300 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/video/mpv/default.nix b/nixpkgs/pkgs/applications/video/mpv/default.nix new file mode 100644 index 000000000000..252f1637172f --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/default.nix @@ -0,0 +1,266 @@ +{ config +, lib +, stdenv +, fetchFromGitHub +, fetchpatch +, addOpenGLRunpath +, bash +, docutils +, meson +, ninja +, pkg-config +, python3 +, ffmpeg +, freefont_ttf +, freetype +, libass +, libpthreadstubs +, nv-codec-headers +, lua +, libuchardet +, libiconv +, xcbuild +, sigtool + +, waylandSupport ? stdenv.isLinux + , wayland + , wayland-protocols + , wayland-scanner + , libxkbcommon + +, x11Support ? stdenv.isLinux + , libGLU, libGL + , libX11 + , libXext + , libXxf86vm + , libXrandr + , libXpresent + +, cddaSupport ? false + , libcdio + , libcdio-paranoia + +, vulkanSupport ? stdenv.isLinux + , libplacebo + , shaderc # instead of spirv-cross + , vulkan-headers + , vulkan-loader + +, drmSupport ? stdenv.isLinux + , libdrm + , mesa + +, alsaSupport ? stdenv.isLinux, alsa-lib +, archiveSupport ? true, libarchive +, bluraySupport ? true, libbluray +, bs2bSupport ? true, libbs2b +, cacaSupport ? true, libcaca +, cmsSupport ? true, lcms2 +, dvdnavSupport ? stdenv.isLinux, libdvdnav +, dvbinSupport ? stdenv.isLinux +, jackaudioSupport ? false, libjack2 +, javascriptSupport ? true, mujs +, libpngSupport ? true, libpng +, openalSupport ? true, openalSoft +, pulseSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio +, pipewireSupport ? stdenv.isLinux, pipewire +, rubberbandSupport ? true, rubberband +, screenSaverSupport ? true, libXScrnSaver +, sdl2Support ? true, SDL2 +, sixelSupport ? false, libsixel +, speexSupport ? true, speex +, swiftSupport ? stdenv.isDarwin, swift +, theoraSupport ? true, libtheora +, vaapiSupport ? x11Support || waylandSupport, libva +, vapoursynthSupport ? false, vapoursynth +, vdpauSupport ? true, libvdpau +, xineramaSupport ? stdenv.isLinux, libXinerama +, xvSupport ? stdenv.isLinux, libXv +, zimgSupport ? true, zimg +, darwin +}: + +let + inherit (darwin.apple_sdk_11_0.frameworks) + AVFoundation CoreFoundation CoreMedia Cocoa CoreAudio MediaPlayer Accelerate; + luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); + + overrideSDK = platform: version: + platform // lib.optionalAttrs (platform ? darwinMinVersion) { + darwinMinVersion = version; + }; + + stdenv' = if swiftSupport && stdenv.isDarwin && stdenv.isx86_64 + then stdenv.override (old: { + buildPlatform = overrideSDK old.buildPlatform "10.15"; + hostPlatform = overrideSDK old.hostPlatform "10.15"; + targetPlatform = overrideSDK old.targetPlatform "10.15"; + }) + else stdenv; +in stdenv'.mkDerivation (finalAttrs: { + pname = "mpv"; + version = "0.36.0"; + + outputs = [ "out" "dev" "man" ]; + + src = fetchFromGitHub { + owner = "mpv-player"; + repo = "mpv"; + rev = "v${finalAttrs.version}"; + hash = "sha256-82moFbWvfc1awXih0d0D+dHqYbIoGNZ77RmafQ80IOY="; + }; + + patches = [ + # Revert "meson: use the new build_options method" to avoid a + # cycle between the out and dev outputs. + (fetchpatch { + url = "https://github.com/mpv-player/mpv/commit/3c1686488b48bd2760e9b19f42e7d3be1363d00a.patch"; + hash = "sha256-eYXfX8Y08q4Bl41VHBpwbxYRMZgm/iziXeK6AOp8O6I="; + revert = true; + }) + ]; + + postPatch = '' + patchShebangs version.* ./TOOLS/ + ''; + + NIX_LDFLAGS = lib.optionalString x11Support "-lX11 -lXext "; + + preConfigure = lib.optionalString swiftSupport '' + # Ensure we reference 'lib' (not 'out') of Swift. + export SWIFT_LIB_DYNAMIC=${lib.getLib swift.swift}/lib/swift/macosx + ''; + + mesonFlags = [ + (lib.mesonOption "default_library" "shared") + (lib.mesonBool "libmpv" true) + (lib.mesonEnable "libarchive" archiveSupport) + (lib.mesonEnable "manpage-build" true) + (lib.mesonEnable "cdda" cddaSupport) + (lib.mesonEnable "dvbin" dvbinSupport) + (lib.mesonEnable "dvdnav" dvdnavSupport) + (lib.mesonEnable "openal" openalSupport) + (lib.mesonEnable "sdl2" sdl2Support) + # Disable whilst Swift isn't supported + (lib.mesonEnable "swift-build" swiftSupport) + (lib.mesonEnable "macos-cocoa-cb" swiftSupport) + ]; + + mesonAutoFeatures = "auto"; + + nativeBuildInputs = [ + addOpenGLRunpath + docutils # for rst2man + meson + ninja + pkg-config + ] + ++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun sigtool ] + ++ lib.optionals swiftSupport [ swift ] + ++ lib.optionals waylandSupport [ wayland-scanner ]; + + buildInputs = [ + bash + ffmpeg + freetype + libass + libpthreadstubs + libuchardet + luaEnv + python3 + ] ++ lib.optionals alsaSupport [ alsa-lib ] + ++ lib.optionals archiveSupport [ libarchive ] + ++ lib.optionals bluraySupport [ libbluray ] + ++ lib.optionals bs2bSupport [ libbs2b ] + ++ lib.optionals cacaSupport [ libcaca ] + ++ lib.optionals cddaSupport [ libcdio libcdio-paranoia ] + ++ lib.optionals cmsSupport [ lcms2 ] + ++ lib.optionals drmSupport [ libdrm mesa ] + ++ lib.optionals dvdnavSupport [ libdvdnav libdvdnav.libdvdread ] + ++ lib.optionals jackaudioSupport [ libjack2 ] + ++ lib.optionals javascriptSupport [ mujs ] + ++ lib.optionals libpngSupport [ libpng ] + ++ lib.optionals openalSupport [ openalSoft ] + ++ lib.optionals pipewireSupport [ pipewire ] + ++ lib.optionals pulseSupport [ libpulseaudio ] + ++ lib.optionals rubberbandSupport [ rubberband ] + ++ lib.optionals screenSaverSupport [ libXScrnSaver ] + ++ lib.optionals sdl2Support [ SDL2 ] + ++ lib.optionals sixelSupport [ libsixel ] + ++ lib.optionals speexSupport [ speex ] + ++ lib.optionals theoraSupport [ libtheora ] + ++ lib.optionals vaapiSupport [ libva ] + ++ lib.optionals vapoursynthSupport [ vapoursynth ] + ++ lib.optionals vdpauSupport [ libvdpau ] + ++ lib.optionals vulkanSupport [ libplacebo shaderc vulkan-headers vulkan-loader ] + ++ lib.optionals waylandSupport [ wayland wayland-protocols libxkbcommon ] + ++ lib.optionals x11Support [ libX11 libXext libGLU libGL libXxf86vm libXrandr libXpresent ] + ++ lib.optionals xineramaSupport [ libXinerama ] + ++ lib.optionals xvSupport [ libXv ] + ++ lib.optionals zimgSupport [ zimg ] + ++ lib.optionals stdenv.isLinux [ nv-codec-headers ] + ++ lib.optionals stdenv.isDarwin [ libiconv ] + ++ lib.optionals stdenv.isDarwin [ CoreFoundation Cocoa CoreAudio MediaPlayer Accelerate ] + ++ lib.optionals (stdenv.isDarwin && swiftSupport) [ AVFoundation CoreMedia ]; + + postBuild = lib.optionalString stdenv.isDarwin '' + pushd .. # Must be run from the source dir because it uses relative paths + python3 TOOLS/osxbundle.py -s build/mpv + # Swap binary and bundle symlink to sign bundle executable as symlinks cannot be signed + rm build/mpv.app/Contents/MacOS/mpv-bundle + mv build/mpv.app/Contents/MacOS/mpv build/mpv.app/Contents/MacOS/mpv-bundle + ln -s mpv-bundle build/mpv.app/Contents/MacOS/mpv + codesign --force --sign - build/mpv.app/Contents/MacOS/mpv-bundle + popd + ''; + + postInstall = '' + # Use a standard font + mkdir -p $out/share/mpv + ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf + + cp ../TOOLS/mpv_identify.sh $out/bin + cp ../TOOLS/umpv $out/bin + cp $out/share/applications/mpv.desktop $out/share/applications/umpv.desktop + sed -i '/Icon=/ ! s/mpv/umpv/g; s/^Exec=.*/Exec=umpv %U/' $out/share/applications/umpv.desktop + printf "NoDisplay=true\n" >> $out/share/applications/umpv.desktop + '' + lib.optionalString stdenv.isDarwin '' + mkdir -p $out/Applications + cp -r mpv.app $out/Applications + ''; + + # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + postFixup = lib.optionalString stdenv.isLinux '' + addOpenGLRunpath $out/bin/mpv + patchShebangs --update --host $out/bin/umpv $out/bin/mpv_identify.sh + ''; + + passthru = { + inherit + # The wrapper consults luaEnv and lua.version + luaEnv + lua + # In the wrapper, we want to reference vapoursynth which has the `python3` + # passthru attribute (which has the `sitePrefix` attribute). This way we'll + # be sure that in the wrapper we'll use the same python3.sitePrefix used to + # build vapoursynth. + vapoursynthSupport + vapoursynth + ; + }; + + meta = with lib; { + homepage = "https://mpv.io"; + description = "General-purpose media player, fork of MPlayer and mplayer2"; + longDescription = '' + mpv is a free and open-source general-purpose video player, based on the + MPlayer and mplayer2 projects, with great improvements above both. + ''; + changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}"; + license = licenses.gpl2Plus; + mainProgram = "mpv"; + maintainers = with maintainers; [ AndersonTorres fpletz globin ma27 tadeokondrak ]; + platforms = platforms.unix; + }; +}) diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix new file mode 100644 index 000000000000..d82d12f163e7 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix @@ -0,0 +1,17 @@ +{ lib +, buildLua +, mpv-unwrapped +}: + +buildLua { + inherit (mpv-unwrapped) src version; + pname = "mpv-acompressor"; + scriptPath = "TOOLS/lua/acompressor.lua"; + + meta = with lib; { + inherit (mpv-unwrapped.meta) license; + description = "Script to toggle and control ffmpeg's dynamic range compression filter."; + homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/acompressor.lua"; + maintainers = with maintainers; [ nicoo ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/autocrop.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/autocrop.nix new file mode 100644 index 000000000000..645a4dd16899 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/autocrop.nix @@ -0,0 +1,19 @@ +{ stdenvNoCC, mpv-unwrapped, lib }: + +stdenvNoCC.mkDerivation rec { + pname = "mpv-autocrop"; + version = mpv-unwrapped.version; + src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/autocrop.lua"; + dontBuild = true; + dontUnpack = true; + installPhase = '' + install -Dm644 ${src} $out/share/mpv/scripts/autocrop.lua + ''; + passthru.scriptName = "autocrop.lua"; + + meta = { + description = "This script uses the lavfi cropdetect filter to automatically insert a crop filter with appropriate parameters for the currently playing video."; + homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autocrop.lua"; + license = lib.licenses.gpl2Plus; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/autodeint.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/autodeint.nix new file mode 100644 index 000000000000..b5369b748faf --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/autodeint.nix @@ -0,0 +1,19 @@ +{ stdenvNoCC, mpv-unwrapped, lib }: + +stdenvNoCC.mkDerivation rec { + pname = "mpv-autodeint"; + version = mpv-unwrapped.version; + src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/autodeint.lua"; + dontBuild = true; + dontUnpack = true; + installPhase = '' + install -Dm644 ${src} $out/share/mpv/scripts/autodeint.lua + ''; + passthru.scriptName = "autodeint.lua"; + + meta = { + description = "This script uses the lavfi idet filter to automatically insert the appropriate deinterlacing filter based on a short section of the currently playing video."; + homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autodeint.lua"; + license = lib.licenses.gpl2Plus; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/autoload.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/autoload.nix new file mode 100644 index 000000000000..c4a85c50d938 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/autoload.nix @@ -0,0 +1,20 @@ +{ stdenvNoCC, mpv-unwrapped, lib }: + +stdenvNoCC.mkDerivation rec { + pname = "mpv-autoload"; + version = mpv-unwrapped.version; + src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/autoload.lua"; + dontBuild = true; + dontUnpack = true; + installPhase = '' + install -Dm644 ${src} $out/share/mpv/scripts/autoload.lua + ''; + passthru.scriptName = "autoload.lua"; + + meta = { + description = "This script automatically loads playlist entries before and after the currently played file"; + homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autoload.lua"; + maintainers = [ lib.maintainers.dawidsowa ]; + license = lib.licenses.gpl2Plus; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix new file mode 100644 index 000000000000..046b0fa2ea96 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix @@ -0,0 +1,63 @@ +{ lib +, stdenvNoCC }: + +let + inherit (lib) hasPrefix hasSuffix removeSuffix; + escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'"); + fileName = pathStr: lib.last (lib.splitString "/" pathStr); + nameFromPath = pathStr: + let fN = fileName pathStr; in + if hasSuffix ".lua" fN then + fN + else if !(hasPrefix "." fN) then + "${fN}.lua" + else + null + ; + scriptsDir = "$out/share/mpv/scripts"; +in +lib.makeOverridable ( + { pname + , extraScripts ? [] + , ... }@args: + let + # either passthru.scriptName, inferred from scriptPath, or from pname + scriptName = (args.passthru or {}).scriptName or ( + if args ? scriptPath && nameFromPath args.scriptPath != null + then nameFromPath args.scriptPath + else "${pname}.lua" + ); + scriptPath = args.scriptPath or "./${scriptName}"; + in + stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate { + dontBuild = true; + preferLocalBuild = true; + + outputHashMode = "recursive"; + installPhase = '' + runHook preInstall + + if [ -d "${scriptPath}" ]; then + [ -f "${scriptPath}/main.lua" ] || { + echo "Script directory '${scriptPath}' does not contain 'main.lua'" >&2 + exit 1 + } + [ ${with builtins; toString (length extraScripts)} -eq 0 ] || { + echo "mpvScripts.buildLua does not support 'extraScripts'" \ + "when 'scriptPath' is a directory" + exit 1 + } + mkdir -p "${scriptsDir}" + cp -a "${scriptPath}" "${scriptsDir}/${lib.removeSuffix ".lua" scriptName}" + else + install -m644 -Dt "${scriptsDir}" \ + ${escapedList ([ scriptPath ] ++ extraScripts)} + fi + + runHook postInstall + ''; + + passthru = { inherit scriptName; }; + meta.platforms = lib.platforms.all; + } args) +) diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/chapterskip.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/chapterskip.nix new file mode 100644 index 000000000000..bffc27bd1eac --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/chapterskip.nix @@ -0,0 +1,20 @@ +{ lib +, fetchFromGitHub +, buildLua }: + +buildLua { + pname = "chapterskip"; + + version = "unstable-2022-09-08"; + src = fetchFromGitHub { + owner = "po5"; + repo = "chapterskip"; + rev = "b26825316e3329882206ae78dc903ebc4613f039"; + hash = "sha256-OTrLQE3rYvPQamEX23D6HttNjx3vafWdTMxTiWpDy90="; + }; + + meta = { + homepage = "https://github.com/po5/chapterskip"; + maintainers = with lib.maintainers; [ nicoo ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/convert.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/convert.nix new file mode 100644 index 000000000000..4f90b0c62ed0 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/convert.nix @@ -0,0 +1,40 @@ +{ lib, fetchgit, buildLua +, yad, mkvtoolnix-cli, libnotify }: + +buildLua { + pname = "mpv-convert-script"; + version = "2016-03-18"; + src = fetchgit { + url = "https://gist.github.com/Zehkul/25ea7ae77b30af959be0"; + rev = "f95cee43e390e843a47e8ec9d1711a12a8cd343d"; + sha256 = "13m7l4sy2r8jv2sfrb3vvqvnim4a9ilnv28q5drlg09v298z3mck"; + }; + + patches = [ ./convert.patch ]; + + postPatch = '' + substituteInPlace convert_script.lua \ + --replace 'mkvpropedit_exe = "mkvpropedit"' \ + 'mkvpropedit_exe = "${mkvtoolnix-cli}/bin/mkvpropedit"' \ + --replace 'mkvmerge_exe = "mkvmerge"' \ + 'mkvmerge_exe = "${mkvtoolnix-cli}/bin/mkvmerge"' \ + --replace 'yad_exe = "yad"' \ + 'yad_exe = "${yad}/bin/yad"' \ + --replace 'notify_send_exe = "notify-send"' \ + 'notify_send_exe = "${libnotify}/bin/notify-send"' \ + ''; + + scriptPath = "convert_script.lua"; + + meta = with lib; { + description = "Convert parts of a video while you are watching it in mpv"; + homepage = "https://gist.github.com/Zehkul/25ea7ae77b30af959be0"; + maintainers = [ maintainers.Profpatsch ]; + longDescription = '' + When this script is loaded into mpv, you can hit Alt+W to mark the beginning + and Alt+W again to mark the end of the clip. Then a settings window opens. + ''; + # author was asked to add a license https://gist.github.com/Zehkul/25ea7ae77b30af959be0#gistcomment-3715700 + license = licenses.unfree; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/convert.patch b/nixpkgs/pkgs/applications/video/mpv/scripts/convert.patch new file mode 100644 index 000000000000..d3a891bb34cd --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/convert.patch @@ -0,0 +1,102 @@ +diff --git "a/Convert Script \342\200\223 README.md" "b/Convert Script \342\200\223 README.md" +index 8e062c1..6e0d798 100644 +--- "a/Convert Script \342\200\223 README.md" ++++ "b/Convert Script \342\200\223 README.md" +@@ -68,7 +68,7 @@ and set some options in ``mpv/lua-settings/convert_script.conf`` or with ``--scr + If you don’t want to upgrade your yad. Features like appending segments won’t be available. + + libvpx_fps +- Default: --oautofps ++ Default: "" + FPS settings (or any other settings really) for libvpx encoding. Set it to --ofps=24000/1001 for example. + +-Warning: Some of these options aren’t very robust and setting them to bogus values will break the script. +\ No newline at end of file ++Warning: Some of these options aren’t very robust and setting them to bogus values will break the script. +diff --git a/convert_script.lua b/convert_script.lua +index 17d3100..90f88ec 100644 +--- a/convert_script.lua ++++ b/convert_script.lua +@@ -3,6 +3,12 @@ local msg = require 'mp.msg' + local opt = require 'mp.options' + local utils = require 'mp.utils' + ++-- executables ++local mkvpropedit_exe = "mkvpropedit" ++local mkvmerge_exe = "mkvmerge" ++local yad_exe = "yad" ++local notify_send_exe = "notify-send" ++ + -- default options, convert_script.conf is read + local options = { + bitrate_multiplier = 0.975, -- to make sure the file won’t go over the target file size, set it to 1 if you don’t care +@@ -14,7 +20,7 @@ local options = { + libvpx_options = "--ovcopts-add=cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good", + libvpx_vp9_options = "", + legacy_yad = false, -- if you don’t want to upgrade to at least yad 0.18 +- libvpx_fps = "--oautofps", -- --ofps=24000/1001 for example ++ libvpx_fps = "", -- --ofps=24000/1001 for example + audio_bitrate = 112, -- mpv default, in kbps + } + +@@ -247,12 +253,12 @@ function encode(enc) + if string.len(vf) > 0 then + vf = vf .. "," + end +- local sub_file_table = mp.get_property_native("options/sub-file") ++ local sub_file_table = mp.get_property_native("options/sub-files") + local sub_file = "" + for index, param in pairs(sub_file_table) do + sub_file = sub_file .. " --sub-file='" .. string.gsub(tostring(param), "'", "'\\''") .. "'" + end +- local audio_file_table = mp.get_property_native("options/audio-file") ++ local audio_file_table = mp.get_property_native("options/audio-files") + local audio_file = "" + for index, param in pairs(audio_file_table) do + audio_file = audio_file .. " --audio-file='" .. string.gsub(tostring(param), "'", "'\\''") .. "'" +@@ -354,9 +360,9 @@ function encode(enc) + if ovc == "gif" then + full_command = full_command .. ' --vf-add=lavfi=graph=\\"framestep=' .. framestep .. '\\" && convert ' + .. tmpfolder .. '/*.png -set delay ' .. delay .. ' -loop 0 -fuzz ' .. fuzz .. '% ' .. dither .. ' -layers optimize ' +- .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && notify-send "Gif done") & disown' ++ .. full_output_path .. ' && rm -rf ' .. tmpfolder .. ' && ' .. notify_send_exe .. ' "Gif done") & disown' + else +- full_command = full_command .. ' && notify-send "Encoding done"; mkvpropedit ' ++ full_command = full_command .. ' && ' .. notify_send_exe .. ' "Encoding done"; ' .. mkvpropedit_exe .. ' ' + .. full_output_path .. ' -s title="' .. metadata_title .. '") & disown' + end + +@@ -409,7 +415,7 @@ function encode_copy(enc) + sep = ",+" + + if enc then +- local command = "mkvmerge '" .. video .. "' " .. mkvmerge_parts .. " -o " .. full_output_path ++ local command = mkvmerge_exe .. " '" .. video .. "' " .. mkvmerge_parts .. " -o " .. full_output_path + msg.info(command) + os.execute(command) + clear() +@@ -508,7 +514,7 @@ function call_gui () + end + + +- local yad_command = [[LC_NUMERIC=C yad --title="Convert Script" --center --form --fixed --always-print-result \ ++ local yad_command = [[LC_NUMERIC=C ]] .. yad_exe .. [[ --title="Convert Script" --center --form --fixed --always-print-result \ + --name "convert script" --class "Convert Script" --field="Resize to height:NUM" "]] .. scale_sav --yad_table 1 + .. [[" --field="Resize to width instead:CHK" ]] .. resize_to_width_instead .. " " --yad_table 2 + if options.legacy_yad then +@@ -524,7 +530,7 @@ function call_gui () + yad_command = yad_command + .. [[--field="2pass:CHK" "false" ]] --yad_table 5 + .. [[--field="Encode options::CBE" '! --ovcopts=b=2000,cpu-used=0,auto-alt-ref=1,lag-in-frames=25,quality=good,threads=4' ]] --yad_table 6 +- .. [[--field="Output format::CBE" ' --ovc=libx264! --oautofps --of=webm --ovc=libvpx' ]] ++ .. [[--field="Output format::CBE" ' --ovc=libx264! --of=webm --ovc=libvpx' ]] + .. [[--field="Simple:FBTN" 'bash -c "echo \"simple\" && kill -s SIGUSR1 \"$YAD_PID\""' ]] + advanced = true + else +@@ -734,4 +740,4 @@ mp.set_key_bindings({ + + mp.add_key_binding("alt+w", "convert_script", convert_script_hotkey_call) + +-mp.register_event("tick", tick) +\ No newline at end of file ++mp.register_event("tick", tick) diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/cutter.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/cutter.nix new file mode 100644 index 000000000000..498fcb530a41 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/cutter.nix @@ -0,0 +1,47 @@ +{ lib, stdenvNoCC, fetchFromGitHub, makeWrapper }: + +stdenvNoCC.mkDerivation { + pname = "video-cutter"; + version = "unstable-2021-02-03"; + + src = fetchFromGitHub { + owner = "rushmj"; + repo = "mpv-video-cutter"; + rev = "718d6ce9356e63fdd47208ec44f575a212b9068a"; + sha256 = "sha256-ramID1DPl0UqEzevpqdYKb9aaW3CAy3Dy9CPb/oJ4eY="; + }; + + dontBuild = true; + dontCheck = true; + + nativeBuildInputs = [ makeWrapper ]; + + postPatch = '' + substituteInPlace cutter.lua \ + --replace '~/.config/mpv/scripts/c_concat.sh' '${placeholder "out"}/share/mpv/scripts/c_concat.sh' + + # needs to be ran separately so that we can replace everything, and not every single mention explicitly + # original script places them in the scripts folder, just spawning unnecessary errors + # i know that hardcoding .config and especially the .mpv directory isn't best practice, but I didn't want to deviate too much from upstream + substituteInPlace cutter.lua \ + --replace '~/.config/mpv/scripts' "''${XDG_CONFIG_HOME:-~/.config}/mpv/cutter" + ''; + + installPhase = '' + install -Dm755 c_concat.sh $out/share/mpv/scripts/c_concat.sh + install cutter.lua $out/share/mpv/scripts/cutter.lua + + wrapProgram $out/share/mpv/scripts/c_concat.sh \ + --run "mkdir -p ~/.config/mpv/cutter/" + ''; + + passthru.scriptName = "cutter.lua"; + + meta = with lib; { + description = "Cut videos and concat them automatically"; + homepage = "https://github.com/rushmj/mpv-video-cutter"; + # repo doesn't have a license + license = licenses.unfree; + maintainers = with maintainers; [ lom ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix new file mode 100644 index 000000000000..9d16deb1c529 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix @@ -0,0 +1,34 @@ +{ lib +, callPackage +, config +}: + +let buildLua = callPackage ./buildLua.nix { }; +in lib.recurseIntoAttrs + ({ + acompressor = callPackage ./acompressor.nix { inherit buildLua; }; + autocrop = callPackage ./autocrop.nix { }; + autodeint = callPackage ./autodeint.nix { }; + autoload = callPackage ./autoload.nix { }; + chapterskip = callPackage ./chapterskip.nix { inherit buildLua; }; + convert = callPackage ./convert.nix { inherit buildLua; }; + inhibit-gnome = callPackage ./inhibit-gnome.nix { }; + mpris = callPackage ./mpris.nix { }; + mpv-playlistmanager = callPackage ./mpv-playlistmanager.nix { inherit buildLua; }; + mpv-webm = callPackage ./mpv-webm.nix { }; + mpvacious = callPackage ./mpvacious.nix { inherit buildLua; }; + quality-menu = callPackage ./quality-menu.nix { inherit buildLua; }; + simple-mpv-webui = callPackage ./simple-mpv-webui.nix { inherit buildLua; }; + sponsorblock = callPackage ./sponsorblock.nix { }; + thumbfast = callPackage ./thumbfast.nix { inherit buildLua; }; + thumbnail = callPackage ./thumbnail.nix { inherit buildLua; }; + uosc = callPackage ./uosc.nix { }; + visualizer = callPackage ./visualizer.nix { }; + vr-reversal = callPackage ./vr-reversal.nix { }; + webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { }; + cutter = callPackage ./cutter.nix { }; + } + // (callPackage ./occivink.nix { inherit buildLua; })) + // lib.optionalAttrs config.allowAliases { + youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14 +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix new file mode 100644 index 000000000000..2955dfb7c0c8 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/inhibit-gnome.nix @@ -0,0 +1,31 @@ +{ lib, stdenv, fetchFromGitHub, pkg-config, dbus, mpv-unwrapped }: + +stdenv.mkDerivation rec { + pname = "mpv-inhibit-gnome"; + version = "0.1.3"; + + src = fetchFromGitHub { + owner = "Guldoman"; + repo = "mpv_inhibit_gnome"; + rev = "v${version}"; + hash = "sha256-LSGg5gAQE2JpepBqhz6D6d3NlqYaU4bjvYf1F+oLphQ="; + }; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ dbus mpv-unwrapped ]; + + passthru.scriptName = "mpv_inhibit_gnome.so"; + + installPhase = '' + install -D ./lib/mpv_inhibit_gnome.so $out/share/mpv/scripts/mpv_inhibit_gnome.so + ''; + + meta = with lib; { + description = "This mpv plugin prevents screen blanking in GNOME"; + homepage = "https://github.com/Guldoman/mpv_inhibit_gnome"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ myaats ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix new file mode 100644 index 000000000000..cc230c2f1f43 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpris.nix @@ -0,0 +1,37 @@ +{ lib, stdenv, fetchFromGitHub, pkg-config, glib, mpv-unwrapped, ffmpeg }: + +stdenv.mkDerivation rec { + pname = "mpv-mpris"; + version = "1.1"; + + src = fetchFromGitHub { + owner = "hoyon"; + repo = "mpv-mpris"; + rev = version; + hash = "sha256-vZIO6ILatIWa9nJYOp4AMKwvaZLahqYWRLMDOizyBI0="; + }; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ glib mpv-unwrapped ffmpeg ]; + + postPatch = '' + substituteInPlace Makefile --replace 'PKG_CONFIG =' 'PKG_CONFIG ?=' + ''; + + installFlags = [ "SCRIPTS_DIR=${placeholder "out"}/share/mpv/scripts" ]; + + # Otherwise, the shared object isn't `strip`ped. See: + # https://discourse.nixos.org/t/debug-why-a-derivation-has-a-reference-to-gcc/7009 + stripDebugList = [ "share/mpv/scripts" ]; + passthru.scriptName = "mpris.so"; + + meta = with lib; { + description = "MPRIS plugin for mpv"; + homepage = "https://github.com/hoyon/mpv-mpris"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ ajs124 ]; + changelog = "https://github.com/hoyon/mpv-mpris/releases/tag/${version}"; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix new file mode 100644 index 000000000000..8ec05a3cf691 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix @@ -0,0 +1,28 @@ +{ lib, buildLua, fetchFromGitHub, yt-dlp }: + +buildLua rec { + pname = "mpv-playlistmanager"; + version = "unstable-2023-08-09"; + + src = fetchFromGitHub { + owner = "jonniek"; + repo = "mpv-playlistmanager"; + rev = "e479cbc7e83a07c5444f335cfda13793681bcbd8"; + sha256 = "sha256-Nh4g8uSkHWPjwl5wyqWtM+DW9fkEbmCcOsZa4eAF6Cs="; + }; + + postPatch = '' + substituteInPlace playlistmanager.lua \ + --replace 'youtube_dl_executable = "youtube-dl",' \ + 'youtube_dl_executable = "${lib.getBin yt-dlp}/bin/yt-dlp"', + ''; + + scriptPath = "playlistmanager.lua"; + + meta = with lib; { + description = "Mpv lua script to create and manage playlists"; + homepage = "https://github.com/jonniek/mpv-playlistmanager"; + license = licenses.unlicense; + maintainers = with maintainers; [ lunik1 ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-webm.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-webm.nix new file mode 100644 index 000000000000..983003d79d71 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-webm.nix @@ -0,0 +1,36 @@ +{ lib +, stdenvNoCC +, fetchFromGitHub +, luaPackages +}: + +stdenvNoCC.mkDerivation { + pname = "mpv-webm"; + version = "unstable-2023-02-23"; + + src = fetchFromGitHub { + owner = "ekisu"; + repo = "mpv-webm"; + rev = "a18375932e39e9b2a40d9c7ab52ea367b41e2558"; + hash = "sha256-aetkQ1gU/6Yys5FJS/N06ED9tCSvL6BAgUGdNmNmpbU="; + }; + + nativeBuildInputs = [ luaPackages.moonscript ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/share/mpv/scripts + install -m 644 build/webm.lua $out/share/mpv/scripts/ + runHook postInstall + ''; + + passthru.scriptName = "webm.lua"; + + meta = with lib; { + description = "Simple WebM maker for mpv, with no external dependencies"; + homepage = "https://github.com/ekisu/mpv-webm"; + license = licenses.mit; + platforms = platforms.all; + maintainers = with maintainers; [ pbsds ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix new file mode 100644 index 000000000000..93e1402289cd --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix @@ -0,0 +1,41 @@ +{ lib +, buildLua +, fetchFromGitHub +, curl +, wl-clipboard +, xclip +}: + +buildLua rec { + pname = "mpvacious"; + version = "0.25"; + + src = fetchFromGitHub { + owner = "Ajatt-Tools"; + repo = "mpvacious"; + rev = "v${version}"; + sha256 = "sha256-XTnib4cguWFEvZtmsLfkesbjFbkt2YoyYLT587ajyUM="; + }; + + postPatch = '' + substituteInPlace utils/forvo.lua \ + --replace "'curl" "'${curl}/bin/curl" + substituteInPlace platform/nix.lua \ + --replace "'curl" "'${curl}/bin/curl" \ + --replace "'wl-copy" "'${wl-clipboard}/bin/wl-copy" \ + --replace "'xclip" "'${xclip}/bin/xclip" + ''; + + installPhase = '' + runHook preInstall + make PREFIX=$out/share/mpv install + runHook postInstall + ''; + + meta = with lib; { + description = "Adds mpv keybindings to create Anki cards from movies and TV shows"; + homepage = "https://github.com/Ajatt-Tools/mpvacious"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ kmicklas ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix new file mode 100644 index 000000000000..167e2fef6ac0 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix @@ -0,0 +1,45 @@ +{ lib +, fetchFromGitHub +, buildLua +}: + +let + camelToKebab = let + inherit (lib.strings) match stringAsChars toLower; + isUpper = match "[A-Z]"; + in stringAsChars (c: if isUpper c != null then "-${toLower c}" else c); + + mkScript = name: args: + buildLua (lib.attrsets.recursiveUpdate rec { + pname = camelToKebab name; + src = fetchFromGitHub { + owner = "occivink"; + repo = "mpv-scripts"; + rev = "af360f332897dda907644480f785336bc93facf1"; + hash = "sha256-KdCrUkJpbxxqmyUHksVVc8KdMn8ivJeUA2eerFZfEE8="; + }; + version = "unstable-2022-10-02"; + + scriptPath = "scripts/${pname}.lua"; + + meta = with lib; { + homepage = "https://github.com/occivink/mpv-scripts"; + license = licenses.unlicense; + maintainers = with maintainers; [ nicoo ]; + }; + } args); + +in +lib.mapAttrs (name: lib.makeOverridable (mkScript name)) { + + # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` + seekTo = { + meta.description = "Mpv script for seeking to a specific position"; + outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs="; + }; + + blacklistExtensions = { + meta.description = "Automatically remove playlist entries based on their extension."; + outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE="; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/quality-menu.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/quality-menu.nix new file mode 100644 index 000000000000..e4d82d17ca39 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/quality-menu.nix @@ -0,0 +1,27 @@ +{ lib +, buildLua +, fetchFromGitHub +, oscSupport ? false +}: + +buildLua rec { + pname = "mpv-quality-menu"; + version = "4.1.1"; + + src = fetchFromGitHub { + owner = "christoph-heinrich"; + repo = "mpv-quality-menu"; + rev = "v${version}"; + hash = "sha256-yrcTxqpLnOI1Tq3khhflO3wzhyeTPuvKifyH5/P57Ns="; + }; + + scriptPath = "quality-menu.lua"; + extraScripts = lib.optional oscSupport "quality-menu-osc.lua"; + + meta = with lib; { + description = "A userscript for MPV that allows you to change youtube video quality (ytdl-format) on the fly"; + homepage = "https://github.com/christoph-heinrich/mpv-quality-menu"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ lunik1 ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix new file mode 100644 index 000000000000..c3b53c618396 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix @@ -0,0 +1,29 @@ +{ lib, buildLua +, fetchFromGitHub }: +buildLua rec { + pname = "simple-mpv-ui"; + version = "3.0.0"; + + src = fetchFromGitHub { + owner = "open-dynaMIX"; + repo = "simple-mpv-webui"; + rev = "v${version}"; + hash = "sha256-I8lwpo3Hfpy3UnPMmHEJCdArVQnNL245NkxsYVmnMF0="; + sparseCheckout = [ "main.lua" "webui-page" ]; + }; + + scriptPath = "."; + passthru.scriptName = "webui.lua"; + + meta = with lib; { + description = "A web based user interface with controls for the mpv mediaplayer"; + homepage = "https://github.com/open-dynaMIX/simple-mpv-webui"; + maintainers = with maintainers; [ cript0nauta zopieux ]; + longDescription = '' + You can access the webui when accessing http://127.0.0.1:8080 or + http://[::1]:8080 in your webbrowser. By default it listens on + 0.0.0.0:8080 and [::0]:8080 + ''; + license = licenses.mit; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix new file mode 100644 index 000000000000..35f5fcb549f1 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix @@ -0,0 +1,56 @@ +{ lib, stdenvNoCC, fetchFromGitHub, fetchpatch, python3, nix-update-script }: + +# Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.sponsorblock ]; }` +stdenvNoCC.mkDerivation { + pname = "mpv_sponsorblock"; + version = "unstable-2023-01-30"; + + src = fetchFromGitHub { + owner = "po5"; + repo = "mpv_sponsorblock"; + rev = "7785c1477103f2fafabfd65fdcf28ef26e6d7f0d"; + sha256 = "sha256-iUXaTWWFEdxhxClu2NYbQcThlvYty3A2dEYGooeAVAQ="; + }; + + dontBuild = true; + + patches = [ + # Use XDG_DATA_HOME and XDG_CACHE_HOME if defined for UID and DB + # Necessary to avoid sponsorblock to write in the nix store at runtime. + # https://github.com/po5/mpv_sponsorblock/pull/17 + (fetchpatch { + url = "https://github.com/po5/mpv_sponsorblock/pull/17/commits/e65b360a7d03a3430b4829e457a6670b2f617b09.patch"; + sha256 = "00wv0pvbz0dz2ibka66zhl2jk0pil4pyv6ipjfz37i81q6szyhs5"; + }) + (fetchpatch { + url = "https://github.com/po5/mpv_sponsorblock/pull/17/commits/3832304d959205e99120a14c0560ed3c37104b08.patch"; + sha256 = "149ffvn714n2m3mqs8mgrbs24bcr74kqfkx7wyql36ndhm88xd2z"; + }) + ]; + + postPatch = '' + substituteInPlace sponsorblock.lua \ + --replace "python3" "${python3}/bin/python3" \ + --replace 'mp.find_config_file("scripts")' "\"$out/share/mpv/scripts\"" + ''; + + installPhase = '' + mkdir -p $out/share/mpv/scripts + cp -r sponsorblock.lua sponsorblock_shared $out/share/mpv/scripts/ + ''; + + passthru = { + scriptName = "sponsorblock.lua"; + updateScript = nix-update-script { + extraArgs = [ "--version=branch" ]; + }; + }; + + meta = with lib; { + description = "Script for mpv to skip sponsored segments of YouTube videos"; + homepage = "https://github.com/po5/mpv_sponsorblock"; + license = licenses.gpl3; + platforms = platforms.all; + maintainers = with maintainers; [ pacien ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix new file mode 100644 index 000000000000..0226074ca31b --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbfast.nix @@ -0,0 +1,27 @@ +{ lib, fetchFromGitHub, buildLua, mpv-unwrapped }: + +buildLua { + pname = "mpv-thumbfast"; + version = "unstable-2023-06-04"; + + src = fetchFromGitHub { + owner = "po5"; + repo = "thumbfast"; + rev = "4241c7daa444d3859b51b65a39d30e922adb87e9"; + hash = "sha256-7EnFJVjEzqhWXAvhzURoOp/kad6WzwyidWxug6u8lVw="; + }; + + postPatch = '' + substituteInPlace thumbfast.lua \ + --replace 'mpv_path = "mpv"' 'mpv_path = "${lib.getExe mpv-unwrapped}"' + ''; + + scriptPath = "thumbfast.lua"; + + meta = { + description = "High-performance on-the-fly thumbnailer for mpv"; + homepage = "https://github.com/po5/thumbfast"; + license = lib.licenses.mpl20; + maintainers = with lib.maintainers; [ apfelkuchen6 ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix new file mode 100644 index 000000000000..4ed545363839 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/thumbnail.nix @@ -0,0 +1,30 @@ +{ lib, buildLua, fetchFromGitHub, python3 }: + +buildLua rec { + pname = "mpv-thumbnail-script"; + version = "0.5.3"; + + src = fetchFromGitHub { + owner = "marzzzello"; + repo = "mpv_thumbnail_script"; + rev = version; + sha256 = "sha256-J24Rou7BTE7zoiPlBkWuO9dtYJiuzkuwB4FROuzXzag="; + }; + + nativeBuildInputs = [ python3 ]; + postPatch = "patchShebangs concat_files.py"; + dontBuild = false; + + scriptPath = "mpv_thumbnail_script_client_osc.lua"; + extraScripts = [ "mpv_thumbnail_script_server.lua" ]; + passthru.scriptName = "mpv_thumbnail_script_{client_osc,server}.lua"; + + meta = with lib; { + description = "A lua script to show preview thumbnails in mpv's OSC seekbar"; + homepage = "https://github.com/marzzzello/mpv_thumbnail_script"; + changelog = "https://github.com/marzzzello/mpv_thumbnail_script/releases/tag/${version}"; + license = licenses.gpl3Plus; + platforms = platforms.all; + maintainers = with maintainers; [ figsoda ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix new file mode 100644 index 000000000000..b88cd2c5b968 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/uosc.nix @@ -0,0 +1,48 @@ +{ stdenvNoCC, lib, fetchFromGitHub, makeFontsConf }: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "uosc"; + version = "4.7.0"; + + src = fetchFromGitHub { + owner = "tomasklaen"; + repo = "uosc"; + rev = finalAttrs.version; + hash = "sha256-JqlBjhwRgmXl6XfHYTwtNWZj656EDHjcdWOlCgihF5I="; + }; + + postPatch = '' + substituteInPlace scripts/uosc.lua \ + --replace "mp.find_config_file('scripts')" "\"$out/share/mpv/scripts\"" + ''; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/mpv/ + cp -r scripts $out/share/mpv + cp -r fonts $out/share + + runHook postInstall + ''; + + passthru.scriptName = "uosc.lua"; + # the script uses custom "texture" fonts as the background for ui elements. + # In order for mpv to find them, we need to adjust the fontconfig search path. + passthru.extraWrapperArgs = [ + "--set" + "FONTCONFIG_FILE" + (toString (makeFontsConf { + fontDirectories = [ "${finalAttrs.finalPackage}/share/fonts" ]; + })) + ]; + + meta = with lib; { + description = "Feature-rich minimalist proximity-based UI for MPV player"; + homepage = "https://github.com/tomasklaen/uosc"; + license = licenses.gpl3Only; + maintainers = with lib.maintainers; [ apfelkuchen6 ]; + }; +}) diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/visualizer.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/visualizer.nix new file mode 100644 index 000000000000..a248b63d503a --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/visualizer.nix @@ -0,0 +1,34 @@ +{ + lib, + stdenvNoCC, + fetchFromGitHub, +}: +stdenvNoCC.mkDerivation { + pname = "visualizer"; + version = "unstable-2021-07-10"; + + src = fetchFromGitHub { + owner = "mfcc64"; + repo = "mpv-scripts"; + rev = "a0cd87eeb974a4602c5d8086b4051b5ab72f42e1"; + sha256 = "1xgd1nd117lpj3ppynhgaa5sbkfm7l8n6c9a2fy8p07is2dkndrq"; + }; + + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/share/mpv/scripts + cp visualizer.lua $out/share/mpv/scripts + runHook postInstall + ''; + + passthru.scriptName = "visualizer.lua"; + + meta = with lib; { + description = "various audio visualization"; + homepage = "https://github.com/mfcc64/mpv-scripts"; + platforms = platforms.all; + maintainers = with maintainers; [kmein]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/vr-reversal.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/vr-reversal.nix new file mode 100644 index 000000000000..4c4aacef31dc --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/vr-reversal.nix @@ -0,0 +1,35 @@ +{ lib, stdenvNoCC, fetchFromGitHub, ffmpeg }: + +stdenvNoCC.mkDerivation rec { + pname = "vr-reversal"; + version = "1.1"; + + src = fetchFromGitHub { + owner = "dfaker"; + repo = pname; + rev = "v${version}"; + sha256 = "1wn2ngcvn7wcsl3kmj782x5q9130qw951lj6ilrkafp6q6zscpqr"; + }; + + dontBuild = true; + + # reset_rot is only available in ffmpeg 5.0, see 5bcc61ce87922ecccaaa0bd303a7e195929859a8 + postPatch = lib.optionalString (lib.versionOlder ffmpeg.version "5.0") '' + substituteInPlace 360plugin.lua --replace ":reset_rot=1:" ":" + ''; + + installPhase = '' + mkdir -p $out/share/mpv/scripts + cp -r 360plugin.lua $out/share/mpv/scripts/ + ''; + + passthru.scriptName = "360plugin.lua"; + + meta = with lib; { + description = "Script for mpv to play VR video with optional saving of head tracking data."; + homepage = "https://github.com/dfaker/VR-reversal"; + license = licenses.unlicense; + platforms = platforms.all; + maintainers = with maintainers; [ schnusch ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix new file mode 100644 index 000000000000..a1713e24375f --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/webtorrent-mpv-hook.nix @@ -0,0 +1,40 @@ +{ lib, buildNpmPackage, fetchFromGitHub, nodejs, python3 }: + +buildNpmPackage rec { + pname = "webtorrent-mpv-hook"; + version = "1.3.3"; + + src = fetchFromGitHub { + owner = "mrxdst"; + repo = pname; + rev = "v${version}"; + hash = "sha256-AFKX31kriacXygZy0Mw+QwO+SwFEu13687mJ/WeAoKY="; + }; + + postPatch = '' + substituteInPlace src/webtorrent.ts --replace "node_path: 'node'" "node_path: '${nodejs}/bin/node'" + # This executable is just for telling non-Nix users how to install + substituteInPlace package.json --replace '"bin": "build/bin.js",' "" + rm -rf src/bin.ts + ''; + + npmDepsHash = "sha256-GpNUJ5ZCgMjSYLqsIE/RwkTSFT3uAhxrHPe7XvGDRHE="; + makeCacheWritable = true; + + nativeBuildInputs = [ + python3 # Fixes node-gyp on aarch64-linux + ]; + + postInstall = '' + mkdir -p $out/share/mpv/scripts/ + ln -s $out/lib/node_modules/webtorrent-mpv-hook/build/webtorrent.js $out/share/mpv/scripts/ + ''; + passthru.scriptName = "webtorrent.js"; + + meta = { + description = "Adds a hook that allows mpv to stream torrents"; + homepage = "https://github.com/mrxdst/webtorrent-mpv-hook"; + maintainers = [ lib.maintainers.chuangzhu ]; + license = lib.licenses.isc; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/wrapper.nix b/nixpkgs/pkgs/applications/video/mpv/wrapper.nix new file mode 100644 index 000000000000..a86c9671a481 --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/wrapper.nix @@ -0,0 +1,109 @@ +# Arguments that this derivation gets when it is created with `callPackage` +{ stdenv +, buildEnv +, lib +, makeWrapper +, mpvScripts +, symlinkJoin +, writeTextDir +, yt-dlp +}: + +# the unwrapped mpv derivation - 1st argument to `wrapMpv` +mpv: + +let + # arguments to the function (exposed as `wrapMpv` in all-packages.nix) + wrapper = { + extraMakeWrapperArgs ? [], + youtubeSupport ? true, + # a set of derivations (probably from `mpvScripts`) where each is + # expected to have a `scriptName` passthru attribute that points to the + # name of the script that would reside in the script's derivation's + # `$out/share/mpv/scripts/`. + # A script can optionally also provide an `extraWrapperArgs` passthru attribute. + scripts ? [], + extraUmpvWrapperArgs ? [] + }: + let + binPath = lib.makeBinPath ([ + mpv.luaEnv + ] ++ lib.optionals youtubeSupport [ + yt-dlp + ] ++ lib.optionals mpv.vapoursynthSupport [ + mpv.vapoursynth.python3 + ]); + # All arguments besides the input and output binaries (${mpv}/bin/mpv and + # $out/bin/mpv). These are used by the darwin specific makeWrapper call + # used to wrap $out/Applications/mpv.app/Contents/MacOS/mpv as well. + mostMakeWrapperArgs = lib.strings.escapeShellArgs ([ "--inherit-argv0" + # These are always needed (TODO: Explain why) + "--prefix" "LUA_CPATH" ";" "${mpv.luaEnv}/lib/lua/${mpv.lua.luaversion}/?.so" + "--prefix" "LUA_PATH" ";" "${mpv.luaEnv}/share/lua/${mpv.lua.luaversion}/?.lua" + ] ++ lib.optionals mpv.vapoursynthSupport [ + "--prefix" "PYTHONPATH" ":" "${mpv.vapoursynth}/${mpv.vapoursynth.python3.sitePackages}" + ] ++ lib.optionals (binPath != "") [ + "--prefix" "PATH" ":" binPath + ] ++ (lib.lists.flatten (map + # For every script in the `scripts` argument, add the necessary flags to the wrapper + (script: + [ + "--add-flags" + # Here we rely on the existence of the `scriptName` passthru + # attribute of the script derivation from the `scripts` + "--script=${script}/share/mpv/scripts/${script.scriptName}" + ] + # scripts can also set the `extraWrapperArgs` passthru + ++ (script.extraWrapperArgs or []) + ) scripts + )) ++ extraMakeWrapperArgs) + ; + umpvWrapperArgs = lib.strings.escapeShellArgs ([ + "--inherit-argv0" + "--set" "MPV" "${placeholder "out"}/bin/mpv" + ] ++ extraUmpvWrapperArgs) + ; + in + symlinkJoin { + name = "mpv-with-scripts-${mpv.version}"; + + # TODO: don't link all mpv outputs and convert package to mpv-unwrapped? + paths = [ mpv.all ]; + + nativeBuildInputs = [ makeWrapper ]; + + passthru.unwrapped = mpv; + + passthru.tests.mpv-scripts-should-not-collide = buildEnv { + name = "mpv-scripts-env"; + paths = lib.pipe mpvScripts [ + # filters "override" "overrideDerivation" "recurseForDerivations" + (lib.filterAttrs (key: script: lib.isDerivation script)) + # replaces unfree and meta.broken scripts with decent placeholders + (lib.mapAttrsToList (key: script: + if (builtins.tryEval script.outPath).success + then script + else writeTextDir "share/mpv/scripts/${script.scriptName}" "placeholder of ${script.name}" + )) + ]; + }; + + postBuild = '' + # wrapProgram can't operate on symlinks + rm "$out/bin/mpv" + makeWrapper "${mpv}/bin/mpv" "$out/bin/mpv" ${mostMakeWrapperArgs} + rm "$out/bin/umpv" + makeWrapper "${mpv}/bin/umpv" "$out/bin/umpv" ${umpvWrapperArgs} + '' + lib.optionalString stdenv.isDarwin '' + # wrapProgram can't operate on symlinks + rm "$out/Applications/mpv.app/Contents/MacOS/mpv" + makeWrapper "${mpv}/Applications/mpv.app/Contents/MacOS/mpv-bundle" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs} + ''; + + meta = { + inherit (mpv.meta) homepage description longDescription maintainers; + mainProgram = "mpv"; + }; + }; +in + lib.makeOverridable wrapper |