@@ -0,0 +1,39 @@
1+{ stdenv, gcc, libav_12, fetchFromGitHub }:
2+
3+stdenv.mkDerivation rec {
4+ name = "untrunc-${version}";
5+ version = "2018.01.13";
6+
7+ src = fetchFromGitHub {
8+ owner = "ponchio";
9+ repo = "untrunc";
10+ rev = "3a2e6d0718faf06589f7b9d95c8f966348e537f7";
11+ sha256 = "03ka4lr69k7mikfpcpd95smzdj62v851ididnjyps5a0j06f8087";
12+ };
13+
14+ buildInputs = [ gcc libav_12 ];
15+
16+ # Untrunc uses the internal libav headers 'h264dec.h' and 'config.h'.
17+ # The latter must be created through 'configure'.
18+ libavConfiguredSrc = libav_12.overrideAttrs (oldAttrs: {
19+ name = "libav-configured-src";
20+ outputs = [ "out" ];
21+ phases = [ "unpackPhase" "patchPhase" "configurePhase" "installPhase" ];
22+ installPhase = "cp -r . $out";
23+ });
24+
25+ buildCommand = ''
26+ mkdir -p $out/bin
27+ g++ -o $out/bin/untrunc \
28+ -Wno-deprecated-declarations \
29+ $src/file.cpp $src/main.cpp $src/track.cpp $src/atom.cpp $src/mp4.cpp \
30+ -I$libavConfiguredSrc -lavformat -lavcodec -lavutil
31+ '';
32+
33+ meta = with stdenv.lib; {
34+ description = "Restore a damaged (truncated) mp4, m4v, mov, 3gp video from a similar, undamaged video";
35+ license = licenses.gpl2;
36+ homepage = https://github.com/ponchio/untrunc;
37+ maintainers = [ maintainers.earvstedt ];
38+ };
39+}