Misc Opts

This commit is contained in:
Javanaut
2026-04-11 16:52:58 +02:00
parent 609f93b783
commit 9611930949
16 changed files with 516 additions and 178 deletions

View File

@@ -4,6 +4,7 @@ import json
import logging
from pathlib import Path
import sys
from types import SimpleNamespace
import unittest
from unittest.mock import patch
@@ -106,6 +107,69 @@ class FilePropertiesProbeTests(unittest.TestCase):
+ ["/tmp/example_s01e01.mkv"]
)
def test_cropdetect_uses_configured_window_and_caches_results(self):
file_properties_module = self.import_module()
file_properties_module.FileProperties._clear_cropdetect_cache()
cropdetect_stderr = "\n".join(
[
"[Parsed_cropdetect_0] crop=1440:1080:240:0",
"[Parsed_cropdetect_0] crop=1440:1080:240:0",
"[Parsed_cropdetect_0] crop=1438:1080:242:0",
]
)
context = self.make_context()
context["cropdetect"] = {"seek_seconds": 15, "duration_seconds": 45}
with (
patch.object(
file_properties_module.os,
"stat",
return_value=SimpleNamespace(st_mtime_ns=1234, st_size=5678),
),
patch.object(file_properties_module, "PatternController", DummyPatternController),
patch.object(
file_properties_module,
"executeProcess",
return_value=("", cropdetect_stderr, 0),
) as mocked_execute,
):
file_properties = file_properties_module.FileProperties(
context,
"/tmp/example_s01e01.mkv",
)
first = file_properties.findCropArguments()
second = file_properties.findCropArguments()
self.assertEqual(first, second)
self.assertEqual(
{
"output_width": "1440",
"output_height": "1080",
"x_offset": "240",
"y_offset": "0",
},
first,
)
mocked_execute.assert_called_once_with(
list(file_properties_module.FFMPEG_COMMAND_TOKENS)
+ [
"-ss",
"15",
"-i",
"/tmp/example_s01e01.mkv",
"-t",
"45",
"-vf",
"cropdetect",
]
+ list(file_properties_module.FFMPEG_NULL_OUTPUT_TOKENS),
context=context,
)
file_properties_module.FileProperties._clear_cropdetect_cache()
if __name__ == "__main__":
unittest.main()