summary refs log tree commit diff
path: root/pkgs/tools/video/untrunc/default.nix
blob: c7b76e0cb6ea50f2d79aaf1a889fe28a60decc1a (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
{ stdenv, gcc, libav_12, fetchFromGitHub }:

stdenv.mkDerivation {
  pname = "untrunc";
  version = "2018.01.13";

  src = fetchFromGitHub {
    owner = "ponchio";
    repo = "untrunc";
    rev = "3a2e6d0718faf06589f7b9d95c8f966348e537f7";
    sha256 = "03ka4lr69k7mikfpcpd95smzdj62v851ididnjyps5a0j06f8087";
  };

  buildInputs = [ gcc libav_12 ];

  # Untrunc uses the internal libav headers 'h264dec.h' and 'config.h'.
  # The latter must be created through 'configure'.
  libavConfiguredSrc = libav_12.overrideAttrs (oldAttrs: {
    name = "libav-configured-src";
    outputs = [ "out" ];
    phases = [ "unpackPhase" "patchPhase" "configurePhase" "installPhase" ];
    installPhase = "cp -r . $out";
  });

  buildCommand = ''
    mkdir -p $out/bin
    g++ -o $out/bin/untrunc \
        -Wno-deprecated-declarations \
        $src/file.cpp $src/main.cpp $src/track.cpp $src/atom.cpp $src/mp4.cpp \
        -I$libavConfiguredSrc -lavformat -lavcodec -lavutil
  '';

  meta = with stdenv.lib; {
    description = "Restore a damaged (truncated) mp4, m4v, mov, 3gp video from a similar, undamaged video";
    license = licenses.gpl2;
    homepage = https://github.com/ponchio/untrunc;
    maintainers = [ maintainers.earvstedt ];
  };
}