31 stdenv.mkDerivation (finalAttrs: {
32 pname = "ccextractor";
33 version = "0.94-unstable-2024-08-12";
35 src = fetchFromGitHub {
36 owner = "CCExtractor";
38 rev = "92f2ce0fa026b01fb07db6751210e6bd8c8944d3";
39 hash = "sha256-bp7T9uJK4bauR2Co4lKqqnM6oGa3WZ+1toEKmzOx4mI=";
43 ./remove-default-commit-hash.patch
44 ./remove-vendored-libraries.patch
45 ] ++ finalAttrs.cargoDeps.patches;
49 cargoRoot = "src/rust";
51 cargoDeps = rustPlatform.fetchCargoTarball {
52 inherit (finalAttrs) src;
53 sourceRoot = "${finalAttrs.src.name}/${finalAttrs.cargoRoot}";
54 patches = [ ./use-rsmpeg-0.15.patch ];
55 patchFlags = [ "-p3" ];
56 hash = "sha256-jh8hHKAad+tCJGwuGdoJp/TMm/IsMrZmz8aag9lj0BA=";
66 rustPlatform.cargoSetupHook
67 rustPlatform.bindgenHook
83 ++ lib.optionals enableOcr [
90 # The tests are all part of one `cargo test` invocation, so let’s
91 # get the output from it.
92 (lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--verbose")
94 # TODO: This (and the corresponding patch) should probably be
95 # removed for the next stable release.
96 (lib.cmakeFeature "GIT_COMMIT_HASH" finalAttrs.src.rev)
98 ++ lib.optionals enableOcr [
99 (lib.cmakeBool "WITH_OCR" true)
100 (lib.cmakeBool "WITH_HARDSUBX" true)
104 FFMPEG_INCLUDE_DIR = "${lib.getDev ffmpeg_7}/include";
106 # Upstream’s FFmpeg binding crate needs an explicit path to a shared
107 # object to do dynamic linking. The key word is *an* explicit path;
108 # they don’t support passing more than one. This linker script hack
109 # pulls in all the FFmpeg libraries they bind to.
111 # See: <https://github.com/CCExtractor/rusty_ffmpeg/pull/69>
123 ffmpegLibDir = "${lib.getLib ffmpeg_7}/lib";
124 ffmpegLibExt = stdenv.hostPlatform.extensions.library;
125 ffmpegLibPath = ffmpegLibName: "${ffmpegLibDir}/lib${ffmpegLibName}.${ffmpegLibExt}";
126 ffmpegLinkerScript = writeTextFile {
127 name = "ccextractor-ffmpeg-linker-script";
128 destination = "/lib/ffmpeg.ld";
129 text = "INPUT(${lib.concatMapStringsSep " " ffmpegLibPath ffmpegLibNames})";
132 "${ffmpegLinkerScript}/lib/ffmpeg.ld";
137 postPatch = lib.optionalString enableOcr ''
138 substituteInPlace src/lib_ccx/ocr.c \
139 --replace-fail 'getenv("TESSDATA_PREFIX")' '"${tesseract}/share"'
143 homepage = "https://www.ccextractor.org/";
144 changelog = "${finalAttrs.src.meta.homepage}/blob/${finalAttrs.src.rev}/docs/CHANGES.TXT";
145 description = "Tool that produces subtitles from closed caption data in videos";
147 A tool that analyzes video files and produces independent subtitle files from
148 closed captions data. CCExtractor is portable, small, and very fast.
149 It works on Linux, Windows, and OSX.
151 platforms = lib.platforms.unix;
152 sourceProvenance = [ lib.sourceTypes.fromSource ];
153 license = lib.licenses.gpl2Only;
154 maintainers = [ lib.maintainers.emily ];
155 mainProgram = "ccextractor";