summary refs log tree commit diff
path: root/pkgs/development/libraries/mlt/default.nix
blob: 8bd2bc80362c044d7eb5954fcf0b8b6fb38d7428 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{ lib, stdenv, fetchFromGitHub, makeWrapper
, SDL, ffmpeg, frei0r, libjack2, libdv, libsamplerate, libexif
, libvorbis, libxml2, movit, pkg-config, sox, fftw, opencv4, SDL2
, gtk2, genericUpdater, common-updater-scripts, libebur128
, jack2, ladspa-sdk, swig, which, ncurses
, enablePython ? false, python
}:

stdenv.mkDerivation rec {
  pname = "mlt";
  version = "6.26.0";

  src = fetchFromGitHub {
    owner = "mltframework";
    repo = "mlt";
    rev = "v${version}";
    sha256 = "FPXROiX7A6oB1VMipw3slyhk7q4fO6m9amohnC67lnA=";
  };

  buildInputs = [
    SDL ffmpeg frei0r libjack2 libdv libsamplerate libvorbis libxml2.dev
    movit sox libexif gtk2 fftw libebur128 opencv4 SDL2 jack2
    ladspa-sdk
  ] ++ lib.optional enablePython ncurses;

  nativeBuildInputs = [ pkg-config makeWrapper which ]
  ++ lib.optionals enablePython [ python swig ];

  # Mostly taken from:
  # http://www.kdenlive.org/user-manual/downloading-and-installing-kdenlive/installing-source/installing-mlt-rendering-engine
  configureFlags = [
    "--avformat-swscale" "--enable-gpl" "--enable-gpl3" "--enable-opengl"
  ] ++ lib.optional enablePython "--swig-languages=python";

  enableParallelBuilding = true;
  outPythonPath = lib.optionalString enablePython "$(toPythonPath $out)";

  postInstall = ''
    wrapProgram $out/bin/melt --prefix FREI0R_PATH : ${frei0r}/lib/frei0r-1

    # Remove an unnecessary reference to movit.dev.
    s=${movit.dev}/include
    t=$(for ((i = 0; i < ''${#s}; i++)); do echo -n X; done)
    sed -i $out/lib/mlt/libmltopengl.so -e "s|$s|$t|g"
  '' + lib.optionalString enablePython ''
    mkdir -p ${outPythonPath}/mlt
    cp -a src/swig/python/_mlt.so ${outPythonPath}/mlt/
    cp -a src/swig/python/mlt.py ${outPythonPath}/mlt/__init__.py
    sed -i ${outPythonPath}/mlt/__init__.py -e "s|return importlib.import_module('_mlt')|return importlib.import_module('mlt._mlt')|g"
  '';

  passthru.updateScript = genericUpdater {
    inherit pname version;
    versionLister = "${common-updater-scripts}/bin/list-git-tags ${src.meta.homepage}";
    rev-prefix = "v";
  };

  meta = with lib; {
    description = "Open source multimedia framework, designed for television broadcasting";
    homepage = "https://www.mltframework.org";
    license = with licenses; [ gpl3Only gpl2Only lgpl21Only ];
    maintainers = with maintainers; [ tohl peti ];
    platforms = platforms.linux;
  };
}