Unverified Commit 48d7dc7f authored by Alex James's avatar Alex James
Browse files

dash-mpd-cli: add dependencies to $PATH

dash-mpd-cli [depends on several binaries in `$PATH`][1] for certain
functionality (e.g., `ffmpeg` for muxing). Use a wrapper to prepend
these binaries to `$PATH` while running `dash-mpd-cli`.

I only included `ffmpeg`, `shaka-packager`, and `xsltproc` as they
should cover most of the functionality supported by `dash-mpd-cli`. The
upstream container [image includes additional (redundant)
dependencies][2], such as `mp4decrypt`.
parent 6f905ffd
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  stdenvNoCC,
  rustPlatform,
  fetchFromGitHub,
  makeWrapper,
  protobuf,
  ffmpeg,
  libxslt,
  shaka-packager,
}:

let
  # dash-mpd-cli looks for a binary named `shaka-packager`, while
  # shaka-packager provides `packager`.
  shaka-packager-wrapped = stdenvNoCC.mkDerivation {
    name = "shaka-packager-wrapped";
    phases = [ "installPhase" ];
    installPhase = ''
      mkdir -p $out/bin
      ln -s ${lib.getExe shaka-packager} $out/bin/shaka-packager
    '';
  };
in
rustPlatform.buildRustPackage rec {
  pname = "dash-mpd-cli";
  version = "0.2.24";
@@ -17,13 +33,31 @@ rustPlatform.buildRustPackage rec {
    hash = "sha256-Q4zzKdp8GROL8vHi8XETErqufSqgZH/zf/mqEH2lIzE=";
  };

  patches = [
    ./use-shaka-by-default.patch
  ];

  cargoHash = "sha256-R54Np08hYpDoidsHr3rmhpX/QZZkZHGcCSoKk6nw9R8=";

  nativeBuildInputs = [ protobuf ];
  nativeBuildInputs = [
    makeWrapper
    protobuf
  ];

  # The tests depend on network access.
  doCheck = false;

  postInstall = ''
    wrapProgram $out/bin/dash-mpd-cli \
      --prefix PATH : ${
        lib.makeBinPath [
          ffmpeg.bin
          libxslt.bin
          shaka-packager-wrapped
        ]
      }
  '';

  meta = {
    description = "Download media content from a DASH-MPEG or DASH-WebM MPD manifest";
    longDescription = ''
+12 −0
Original line number Diff line number Diff line
diff --git a/src/main.rs b/src/main.rs
index f720d4c..a3c6c85 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -325,6 +325,7 @@ async fn main () -> Result<()> {
              .value_name("APP")
              .num_args(1)
              .value_parser(["mp4decrypt", "shaka"])
+             .default_value("shaka")
              .help("Application to use to decrypt encrypted media streams (either mp4decrypt or shaka)."))
         .arg(Arg::new("save-fragments")
              .long("save-fragments")