Merge pull request #331615 from emilazy/push-konptvsyvlnm

ccextractor: 0.93 -> 0.94-unstable-2024-08-12
This commit is contained in:
Emily 2024-08-19 15:30:04 +01:00 committed by GitHub
commit 54df89b8ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 401 additions and 73 deletions

View File

@ -1,71 +0,0 @@
{ lib
, stdenv
, fetchFromGitHub
, pkg-config
, cmake
, libiconv
, zlib
, enableOcr ? true
, makeWrapper
, tesseract4
, leptonica
, ffmpeg_4
}:
stdenv.mkDerivation rec {
pname = "ccextractor";
version = "0.93";
src = fetchFromGitHub {
owner = "CCExtractor";
repo = pname;
rev = "v${version}";
sha256 = "sha256-usVAKBkdd8uz9cD5eLd0hnwGonOJLscRdc+iWDlNXVc=";
};
postPatch = ''
# https://github.com/CCExtractor/ccextractor/issues/1467
sed -i '/allheaders.h/a#include <leptonica/pix_internal.h>' src/lib_ccx/ocr.c
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/CMakeLists.txt \
--replace 'add_definitions(-DGPAC_CONFIG_LINUX)' 'add_definitions(-DGPAC_CONFIG_DARWIN)'
'';
cmakeDir = "../src";
nativeBuildInputs = [ pkg-config cmake makeWrapper ];
buildInputs = [ zlib ]
++ lib.optional (!stdenv.isLinux) libiconv
++ lib.optionals enableOcr [ leptonica tesseract4 ffmpeg_4 ];
cmakeFlags = [
# file RPATH_CHANGE could not write new RPATH:
"-DCMAKE_SKIP_BUILD_RPATH=ON"
] ++ lib.optionals enableOcr [ "-DWITH_OCR=on" "-DWITH_HARDSUBX=on" ];
postInstall = lib.optionalString enableOcr ''
wrapProgram "$out/bin/ccextractor" \
--set TESSDATA_PREFIX "${tesseract4}/share/"
'';
meta = with lib; {
homepage = "https://www.ccextractor.org";
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 = platforms.unix;
# undefined reference to `png_do_expand_palette_rgba8_neon'
# undefined reference to `png_riffle_palette_neon'
# undefined reference to `png_do_expand_palette_rgb8_neon'
# undefined reference to `png_init_filter_functions_neon'
# during Linking C executable ccextractor
broken = stdenv.isAarch64;
license = licenses.gpl2Only;
maintainers = [ ];
mainProgram = "ccextractor";
};
}

View File

@ -0,0 +1,157 @@
{
lib,
stdenv,
fetchFromGitHub,
writeTextFile,
pkg-config,
cmake,
ninja,
cargo,
rustc,
corrosion,
rustPlatform,
gpac,
protobufc,
libpng,
zlib,
utf8proc,
freetype,
ffmpeg_7,
libarchive,
curl,
libiconv,
enableOcr ? true,
leptonica,
tesseract,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "ccextractor";
version = "0.94-unstable-2024-08-12";
src = fetchFromGitHub {
owner = "CCExtractor";
repo = "ccextractor";
rev = "92f2ce0fa026b01fb07db6751210e6bd8c8944d3";
hash = "sha256-bp7T9uJK4bauR2Co4lKqqnM6oGa3WZ+1toEKmzOx4mI=";
};
patches = [
./remove-default-commit-hash.patch
./remove-vendored-libraries.patch
] ++ finalAttrs.cargoDeps.patches;
cmakeDir = "../src";
cargoRoot = "src/rust";
cargoDeps = rustPlatform.fetchCargoTarball {
inherit (finalAttrs) src;
sourceRoot = "${finalAttrs.src.name}/${finalAttrs.cargoRoot}";
patches = [ ./use-rsmpeg-0.15.patch ];
patchFlags = [ "-p3" ];
hash = "sha256-jh8hHKAad+tCJGwuGdoJp/TMm/IsMrZmz8aag9lj0BA=";
};
nativeBuildInputs = [
pkg-config
cmake
ninja
cargo
rustc
corrosion
rustPlatform.cargoSetupHook
rustPlatform.bindgenHook
];
buildInputs =
[
gpac
protobufc
libpng
zlib
utf8proc
freetype
ffmpeg_7
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_7}/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_7}/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";
};
})

View File

@ -0,0 +1,14 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d7fdda02e3...2738cab631 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,9 +24,6 @@
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-ELSE(EXISTS "${BASE_PROJ_DIR}/.git")
- set(GIT_BRANCH "Unknown")
- set(GIT_COMMIT_HASH "Unknown")
ENDIF(EXISTS "${BASE_PROJ_DIR}/.git")
#Get the date

View File

@ -0,0 +1,187 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2738cab631...5bb2b7d17a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -48,93 +48,20 @@
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/lib_ccx)
include_directories(${PROJECT_SOURCE_DIR}/lib_ccx/zvbi)
-include_directories(${PROJECT_SOURCE_DIR}/thirdparty)
-include_directories(${PROJECT_SOURCE_DIR}/thirdparty/protobuf-c)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/lib_hash)
-include_directories(${PROJECT_SOURCE_DIR}/thirdparty/libpng)
-# Check if the operating system is macOS (Darwin)
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm64")
- # ARM Macs
- include_directories("/opt/homebrew/include")
- include_directories(${PROJECT_SOURCE_DIR}/thirdparty/libpng/arm)
- aux_source_directory(${PROJECT_SOURCE_DIR}/thirdparty/libpng/arm SOURCEFILE)
- else()
- include_directories("/usr/local/include")
- endif()
-endif()
-
-include_directories(${PROJECT_SOURCE_DIR}/thirdparty/zlib)
-include_directories(${PROJECT_SOURCE_DIR}/thirdparty/freetype/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/thirdparty/lib_hash/ SOURCEFILE)
-aux_source_directory(${PROJECT_SOURCE_DIR}/thirdparty/libpng/ SOURCEFILE)
-aux_source_directory(${PROJECT_SOURCE_DIR}/thirdparty/protobuf-c/ SOURCEFILE)
-aux_source_directory(${PROJECT_SOURCE_DIR}/thirdparty/zlib/ SOURCEFILE)
aux_source_directory(${PROJECT_SOURCE_DIR}/lib_ccx/zvbi/ SOURCEFILE)
-set(UTF8PROC_SOURCE ${PROJECT_SOURCE_DIR}/thirdparty/utf8proc/utf8proc.c)
+set(UTF8PROC_SOURCE)
-set(FREETYPE_SOURCE
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/autofit/autofit.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftbase.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftbbox.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftbdf.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftbitmap.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftcid.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftfntfmt.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftfstype.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftgasp.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftglyph.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftgxval.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftinit.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftlcdfil.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftmm.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftotval.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftpatent.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftpfr.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftstroke.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftsynth.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftsystem.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/fttype1.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/base/ftwinfnt.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/bdf/bdf.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/bzip2/ftbzip2.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/cache/ftcache.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/cff/cff.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/cid/type1cid.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/gzip/ftgzip.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/lzw/ftlzw.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/pcf/pcf.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/pfr/pfr.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/psaux/psaux.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/pshinter/pshinter.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/psnames/psnames.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/raster/raster.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/sfnt/sfnt.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/smooth/smooth.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/truetype/truetype.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/type1/type1.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/type42/type42.c
- ${PROJECT_SOURCE_DIR}/thirdparty/freetype/winfonts/winfnt.c
- )
+set(FREETYPE_SOURCE)
#Windows specific libraries and linker flags
if(WIN32)
include_directories ("${PROJECT_SOURCE_DIR}/thirdparty/win_spec_incld/")
include_directories ("${PROJECT_SOURCE_DIR}/thirdparty/win_iconv/")
aux_source_directory ("${PROJECT_SOURCE_DIR}/thirdparty/win_iconv/" SOURCEFILE)
set (EXTRA_LIBS ${EXTRA_LIBS} ws2_32 winmm Bcrypt)
-else (WIN32)
- # Adding some platform specific library path
- if(UNIX AND NOT APPLE)
- link_directories (/usr/local/lib)
- endif()
-
- if(APPLE)
- # Homebrew library paths
- link_directories(/usr/local/lib)
- link_directories(/opt/homebrew/lib)
- endif()
endif(WIN32)
if(MSVC)
@@ -212,9 +139,6 @@
pkg_check_modules (NANOMSG REQUIRED libnanomsg)
set (EXTRA_LIBS ${EXTRA_LIBS} ${NANOMSG_STATIC_LIBRARIES})
- include_directories ("${PROJECT_SOURCE_DIR}/thirdparty/protobuf-c/")
- aux_source_directory ("${PROJECT_SOURCE_DIR}/thirdparty/protobuf-c/" SOURCEFILE)
-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_SHARING")
endif (PKG_CONFIG_FOUND AND WITH_SHARING)
diff --git a/src/lib_ccx/CMakeLists.txt b/src/lib_ccx/CMakeLists.txt
index 4f329bcaab...a334d20c4d 100644
--- a/src/lib_ccx/CMakeLists.txt
+++ b/src/lib_ccx/CMakeLists.txt
@@ -13,9 +13,39 @@
find_package(PkgConfig)
pkg_check_modules (GPAC REQUIRED gpac)
+set (REQUIRES_PRIVATE "libpng libprotobuf-c")
+
+if (WITH_FFMPEG)
+ set (REQUIRES_PRIVATE "${REQUIRES_PRIVATE} libavutil")
+endif (WITH_FFMPEG)
+
+if (WITH_HARDSUBX)
+ set (REQUIRES_PRIVATE "${REQUIRES_PRIVATE} libavcodec libavformat libswscale tesseract lept")
+endif (WITH_HARDSUBX)
+
set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${GPAC_INCLUDE_DIRS})
set (EXTRA_LIBS ${EXTRA_LIBS} ${GPAC_LIBRARIES})
+pkg_check_modules (PROTOBUFC REQUIRED libprotobuf-c)
+set (EXTRA_LIBS ${EXTRA_LIBS} ${PROTOBUFC_LIBRARIES})
+set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${PROTOBUFC_INCLUDE_DIRS}/protobuf-c)
+
+pkg_check_modules (LIBPNG REQUIRED libpng)
+set (EXTRA_LIBS ${EXTRA_LIBS} ${LIBPNG_LIBRARIES})
+set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${LIBPNG_INCLUDE_DIRS})
+
+pkg_check_modules (ZLIB REQUIRED zlib)
+set (EXTRA_LIBS ${EXTRA_LIBS} ${ZLIB_LIBRARIES})
+set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${ZLIB_INCLUDE_DIRS})
+
+pkg_check_modules (UTF8PROC REQUIRED libutf8proc)
+set (EXTRA_LIBS ${EXTRA_LIBS} ${UTF8PROC_LIBRARIES})
+set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${UTF8PROC_INCLUDE_DIRS})
+
+pkg_check_modules (FREETYPE REQUIRED freetype2)
+set (EXTRA_LIBS ${EXTRA_LIBS} ${FREETYPE_LIBRARIES})
+set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${FREETYPE_INCLUDE_DIRS})
+
if (WITH_FFMPEG)
find_package(PkgConfig)
@@ -94,7 +124,7 @@
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_RUST")
endif (WITHOUT_RUST)
-file (GLOB HeaderFiles *.h)
+file (GLOB_RECURSE HeaderFiles *.h)
file (WRITE ccx.pc "prefix=${CMAKE_INSTALL_PREFIX}\n"
"includedir=\${prefix}/include\n"
"libdir=\${prefix}/lib\n\n"
@@ -102,8 +132,8 @@
"Description: Closed Caption Extraction library\n"
"Version: 0.75\n"
"Cflags: -I\${includedir}/\n"
- "Libs: -L\${libdir} -lccx -lpng\n"
- "Libs.private: -lpng\n"
+ "Libs: -L\${libdir} -lccx\n"
+ "Requires.private: ${REQUIRES_PRIVATE}\n"
)
install (TARGETS ccx DESTINATION lib)
diff --git a/src/lib_ccx/params.c b/src/lib_ccx/params.c
index eb1562e50c...984070a285 100644
--- a/src/lib_ccx/params.c
+++ b/src/lib_ccx/params.c
@@ -14,7 +14,7 @@
#include "../lib_hash/sha2.h"
#include <string.h>
#include <stdio.h>
-#include <utf8proc/utf8proc.h>
+#include <utf8proc.h>
#ifdef ENABLE_OCR
#include <tesseract/capi.h>

View File

@ -0,0 +1,43 @@
diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock
index 5c49573775..3e855aa637 100644
--- a/src/rust/Cargo.lock
+++ b/src/rust/Cargo.lock
@@ -665,11 +665,10 @@
[[package]]
name = "rsmpeg"
-version = "0.14.2+ffmpeg.6.1"
+version = "0.15.1+ffmpeg.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "927012cd6ae43519f519741f4a69602ce3a47cf84750784da124dffd03527cc0"
+checksum = "d3ffbead667d06e0c77c4363f83d49a3481cc3838bc9a61882aa07b01e3f63e1"
dependencies = [
- "libc",
"paste",
"rusty_ffmpeg",
"thiserror",
@@ -711,9 +710,9 @@
[[package]]
name = "rusty_ffmpeg"
-version = "0.13.3+ffmpeg.6.1"
+version = "0.14.1+ffmpeg.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "716adffa5f909c8533611b1dab9ab5666bece35687845865b75ed6a990fc239c"
+checksum = "40f4db8e3e23d4a3044d53a41aba5324eae70d3e7fe82375ce833521533bc315"
dependencies = [
"bindgen 0.69.4",
"camino",
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index 4c1e73dcf0..68502915dc 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -15,7 +15,7 @@
env_logger = "0.8.4"
iconv = "0.1.1"
palette = "0.6.0"
-rsmpeg = { version = "0.14.1", optional = true, features = [
+rsmpeg = { version = "0.15.1", optional = true, features = [
"link_system_ffmpeg",
] }
tesseract-sys = { version = "0.5.14", optional = true, default-features = false }

View File

@ -3499,8 +3499,6 @@ with pkgs;
fedora-backgrounds = callPackage ../data/misc/fedora-backgrounds { };
ccextractor = callPackage ../applications/video/ccextractor { };
cconv = callPackage ../tools/text/cconv { };
go-check = callPackage ../development/tools/check { };