From 50771bd1dc9e1d1bc960ecaea922ffb246f39903 Mon Sep 17 00:00:00 2001 From: simon987 Date: Fri, 26 Mar 2021 19:48:16 -0400 Subject: [PATCH] Read subtitles from media files, fix bug in text_buffer --- docs/USAGE.md | 4 +++- src/cli.h | 1 + src/main.c | 2 ++ third-party/argparse | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index bc7278b..a1cb6de 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -46,6 +46,7 @@ Scan options --fast Only index file names & mime type --treemap-threshold= Relative size threshold for treemap (see USAGE.md). DEFAULT: 0.0005 --mem-buffer= Maximum memory buffer size per thread in MB for files inside archives (see USAGE.md). DEFAULT: 2000 + --read-subtitles Read subtitles from media files Index options -t, --threads= Number of threads. DEFAULT=1 @@ -91,7 +92,7 @@ Made by simon987 . Released under GPL-3.0 Specify an existing index. Information about files in this index that were not modified (based on *mtime* attribute) will be copied to the new index and will not be parsed again. * `-o, --output` Output directory. -* `--rewrite-url` Set the `rewrite_url` option for the web module (See [rewrite_url](#rewrite_url)) +* `--rewrite-url` Set the `rewrite_url` option for the web module (See [rewrite_url](#rewrite_url)) * `--name` Set the `name` option for the web module * `--depth` Maximum scan dept. Set to 0 only scan files directly in the root directory, set to -1 for infinite depth * `--archive` Archive file mode. @@ -123,6 +124,7 @@ Made by simon987 . Released under GPL-3.0 larger than this number will be read sequentially and no *seek* operations will be supported. To check if a media file can be parsed without *seek*, execute `cat file.mp4 | ffprobe -` +* `--read-subtitles` When enabled, will attempt to read the subtitles stream from media files. ### Scan examples diff --git a/src/cli.h b/src/cli.h index 27139ef..90242aa 100644 --- a/src/cli.h +++ b/src/cli.h @@ -25,6 +25,7 @@ typedef struct scan_args { const char* treemap_threshold_str; double treemap_threshold; int max_memory_buffer; + int read_subtitles; } scan_args_t; scan_args_t *scan_args_create(); diff --git a/src/main.c b/src/main.c index d5b5593..54d8b14 100644 --- a/src/main.c +++ b/src/main.c @@ -132,6 +132,7 @@ void initialize_scan_context(scan_args_t *args) { ScanCtx.media_ctx.logf = _logf; ScanCtx.media_ctx.store = _store; ScanCtx.media_ctx.max_media_buffer = (long) args->max_memory_buffer * 1024 * 1024; + ScanCtx.media_ctx.read_subtitles = args->read_subtitles; init_media(); // OOXML @@ -448,6 +449,7 @@ int main(int argc, const char *argv[]) { OPT_INTEGER(0, "mem-buffer", &scan_args->max_memory_buffer, "Maximum memory buffer size per thread in MB for files inside archives " "(see USAGE.md). DEFAULT: 2000"), + OPT_BOOLEAN(0, "read-subtitles", &scan_args->read_subtitles, "Read subtitles from media files."), OPT_GROUP("Index options"), OPT_INTEGER('t', "threads", &common_threads, "Number of threads. DEFAULT=1"), diff --git a/third-party/argparse b/third-party/argparse index 3f4e359..ffd9c23 160000 --- a/third-party/argparse +++ b/third-party/argparse @@ -1 +1 @@ -Subproject commit 3f4e3594a6891b942d5a711781d5425111aa13bf +Subproject commit ffd9c23427d0cb105e27f27f0cf97b463b6a8bf8