1{ lib, stdenv, fetchFromGitHub
2, cmake
3}:
4stdenv.mkDerivation rec {
5 pname = "bento4";
6 version = "1.6.0-640";
7
8 src = fetchFromGitHub {
9 owner = "axiomatic-systems";
10 repo = "Bento4";
11 rev = "v${version}";
12 hash = "sha256-VhlFfNYw3xpAIyWqDyhgXIv3JtpFJH0BL97dFX8diRY=";
13 };
14
15 patches = [
16 ./libap4.patch # include all libraries as shared, not static
17 ];
18
19 nativeBuildInputs = [ cmake ];
20
21 cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
22
23 installPhase = ''
24 runHook preInstall
25 mkdir -p $out/{lib,bin}
26 find -iname '*${stdenv.hostPlatform.extensions.sharedLibrary}' -exec mv --target-directory="$out/lib" {} \;
27 find -maxdepth 1 -executable -type f -exec mv --target-directory="$out/bin" {} \;
28 runHook postInstall
29 '';
30
31 # Patch binaries to use our dylib
32 postInstall = lib.optionalString stdenv.isDarwin ''
33 find $out/bin -maxdepth 1 -executable -type f -exec install_name_tool -change @rpath/libap4.dylib $out/lib/libap4.dylib {} \;
34 '';
35
36 meta = with lib; {
37 description = "Full-featured MP4 format and MPEG DASH library and tools";
38 homepage = "http://bento4.com";
39 license = licenses.gpl2Plus;
40 maintainers = with maintainers; [ makefu ];
41 platforms = platforms.unix;
42 };
43}