Embedded subtitles provider: add timeout option

This commit is contained in:
Vitiko 2022-04-16 15:05:11 -04:00
parent ec24f3c854
commit d3e3e31fa1
4 changed files with 10 additions and 2 deletions

View File

@ -210,7 +210,8 @@ defaults = {
'include_ass': 'True',
'include_srt': 'True',
'hi_fallback': 'False',
'mergerfs_mode': 'False'
'mergerfs_mode': 'False',
'timeout': '600',
},
'subsync': {
'use_subsync': 'False',

View File

@ -225,6 +225,7 @@ def get_providers_auth():
'cache_dir': os.path.join(args.config_dir, "cache"),
'ffprobe_path': _FFPROBE_BINARY,
'ffmpeg_path': _FFMPEG_BINARY,
'timeout': settings.embeddedsubtitles.timeout,
}
}

View File

@ -67,6 +67,7 @@ export const ProviderList: Readonly<ProviderInfo[]> = [
include_ass: true,
hi_fallback: false,
mergerfs_mode: false,
timeout: 600,
},
message:
"Warning for cloud users: this provider needs to read the entire file in order to extract subtitles.",
@ -77,6 +78,7 @@ export const ProviderList: Readonly<ProviderInfo[]> = [
"Use HI subtitles as a fallback (don't enable it if you have a HI language profile)",
mergerfs_mode:
"[EXPERIMENTAL] Ignore cloud video files from rclone/mergerfs",
timeout: "Extraction timeout in seconds",
},
},
{

View File

@ -79,6 +79,7 @@ class EmbeddedSubtitlesProvider(Provider):
ffmpeg_path=None,
hi_fallback=False,
mergerfs_mode=False,
timeout=600,
):
self._include_ass = include_ass
self._include_srt = include_srt
@ -88,6 +89,7 @@ class EmbeddedSubtitlesProvider(Provider):
self._hi_fallback = hi_fallback
self._cached_paths = {}
self._mergerfs_mode = mergerfs_mode
self._timeout = float(timeout)
fese.FFPROBE_PATH = ffprobe_path or fese.FFPROBE_PATH
fese.FFMPEG_PATH = ffmpeg_path or fese.FFMPEG_PATH
@ -185,7 +187,9 @@ class EmbeddedSubtitlesProvider(Provider):
# Extract all subittle streams to avoid reading the entire
# container over and over
streams = filter(_check_allowed_extensions, container.get_subtitles())
extracted = container.extract_subtitles(list(streams), self._cache_dir)
extracted = container.extract_subtitles(
list(streams), self._cache_dir, timeout=self._timeout
)
# Add the extracted paths to the containter path key
self._cached_paths[container.path] = extracted