Files
nixpkgs/pkgs/by-name/cc/ccextractor/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

155 lines
3.7 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
lib,
stdenv,
fetchFromGitHub,
writeTextFile,
pkg-config,
cmake,
ninja,
cargo,
rustc,
corrosion,
rustPlatform,
gpac,
protobufc,
libpng,
zlib,
utf8proc,
freetype,
ffmpeg,
libarchive,
curl,
libiconv,
enableOcr ? true,
leptonica,
tesseract,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "ccextractor";
version = "0.94-unstable-2025-05-20";
src = fetchFromGitHub {
owner = "CCExtractor";
repo = "ccextractor";
rev = "407d0f4e93611c5b0ceb14b7fc01d4a4c2e90433";
hash = "sha256-BfsQmCNB4HRafqJ3pC2ECiwhOgwKuIqiLjr2/bvHr7Q=";
};
patches = [
./remove-default-commit-hash.patch
./remove-vendored-libraries.patch
]
++ finalAttrs.cargoDeps.vendorStaging.patches;
cmakeDir = "../src";
cargoRoot = "src/rust";
cargoDeps = rustPlatform.fetchCargoVendor {
inherit (finalAttrs) src cargoRoot;
patches = [ ./use-rsmpeg-0.15.patch ];
hash = "sha256-68Y8nzPHxhVIRHoPXOy9tc71177lCBuOf//z3cqyDGQ=";
};
nativeBuildInputs = [
pkg-config
cmake
ninja
cargo
rustc
corrosion
rustPlatform.cargoSetupHook
rustPlatform.bindgenHook
];
buildInputs = [
gpac
protobufc
libpng
zlib
utf8proc
freetype
ffmpeg
libarchive
curl
libiconv
]
++ lib.optionals enableOcr [
leptonica
tesseract
];
cmakeFlags = [
# The tests are all part of one `cargo test` invocation, so lets
# get the output from it.
(lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--verbose")
# TODO: This (and the corresponding patch) should probably be
# removed for the next stable release.
(lib.cmakeFeature "GIT_COMMIT_HASH" finalAttrs.src.rev)
]
++ lib.optionals enableOcr [
(lib.cmakeBool "WITH_OCR" true)
(lib.cmakeBool "WITH_HARDSUBX" true)
];
env = {
FFMPEG_INCLUDE_DIR = "${lib.getDev ffmpeg}/include";
# Upstreams FFmpeg binding crate needs an explicit path to a shared
# object to do dynamic linking. The key word is *an* explicit path;
# they dont support passing more than one. This linker script hack
# pulls in all the FFmpeg libraries they bind to.
#
# See: <https://github.com/CCExtractor/rusty_ffmpeg/pull/69>
FFMPEG_DLL_PATH =
let
ffmpegLibNames = [
"avcodec"
"avdevice"
"avfilter"
"avformat"
"avutil"
"swresample"
"swscale"
];
ffmpegLibDir = "${lib.getLib ffmpeg}/lib";
ffmpegLibExt = stdenv.hostPlatform.extensions.library;
ffmpegLibPath = ffmpegLibName: "${ffmpegLibDir}/lib${ffmpegLibName}.${ffmpegLibExt}";
ffmpegLinkerScript = writeTextFile {
name = "ccextractor-ffmpeg-linker-script";
destination = "/lib/ffmpeg.ld";
text = "INPUT(${lib.concatMapStringsSep " " ffmpegLibPath ffmpegLibNames})";
};
in
"${ffmpegLinkerScript}/lib/ffmpeg.ld";
};
doCheck = true;
postPatch = lib.optionalString enableOcr ''
substituteInPlace src/lib_ccx/ocr.c \
--replace-fail 'getenv("TESSDATA_PREFIX")' '"${tesseract}/share"'
'';
meta = {
homepage = "https://www.ccextractor.org/";
changelog = "${finalAttrs.src.meta.homepage}/blob/${finalAttrs.src.rev}/docs/CHANGES.TXT";
description = "Tool that produces subtitles from closed caption data in videos";
longDescription = ''
A tool that analyzes video files and produces independent subtitle files from
closed captions data. CCExtractor is portable, small, and very fast.
It works on Linux, Windows, and OSX.
'';
platforms = lib.platforms.unix;
sourceProvenance = [ lib.sourceTypes.fromSource ];
license = lib.licenses.gpl2Only;
maintainers = [ lib.maintainers.emily ];
mainProgram = "ccextractor";
};
})