Enhance Avisynth video workflow and metadata tools

This commit is contained in:
ajp_anton
2026-07-30 03:20:19 +00:00
parent d60ce51b14
commit 100cad1cb5
26 changed files with 2350 additions and 1161 deletions
+23 -7
View File
@@ -15,6 +15,10 @@ class FrameIdentity:
source_frame: int | None
drop_frame: bool = False
matrix: int | None = None
primaries: int | None = None
transfer: int | None = None
color_range: int | None = None
absolute_timestretch: float | None = None
@dataclass(frozen=True)
@@ -112,23 +116,26 @@ def read_frame_identity_csv(path: Path) -> list[FrameIdentity]:
with path.open(newline="", encoding="utf-8") as handle:
reader = csv.reader(handle)
for line_number, row in enumerate(reader, start=1):
if line_number == 1 and row in (
["output_frame", "source_id", "source_frame", "drop_frame"],
["output_frame", "source_id", "source_frame", "drop_frame", "matrix"],
):
if line_number == 1 and row[0:4] == [
"output_frame", "source_id", "source_frame", "drop_frame"
]:
continue
if not row or all(not value.strip() for value in row):
continue
if len(row) not in {4, 5}:
if len(row) not in {4, 5, 6, 9}:
raise RuntimeError(
f"{path}:{line_number}: expected 4 or 5 CSV columns, got {len(row)}"
f"{path}:{line_number}: expected 4, 5, 6, or 9 CSV columns, got {len(row)}"
)
try:
output_frame = int(row[0])
source_id = _optional_int(row[1])
source_frame = _optional_int(row[2])
drop_frame = bool(int(row[3] or "0"))
matrix = _optional_int(row[4]) if len(row) == 5 else None
matrix = _optional_int(row[4]) if len(row) >= 5 else None
primaries = _optional_int(row[5]) if len(row) == 9 else None
transfer = _optional_int(row[6]) if len(row) == 9 else None
color_range = _optional_int(row[7]) if len(row) == 9 else None
absolute_timestretch = _optional_float(row[-1]) if len(row) >= 6 else None
except ValueError as exc:
raise RuntimeError(
f"{path}:{line_number}: invalid frame identity row: {row}"
@@ -140,6 +147,10 @@ def read_frame_identity_csv(path: Path) -> list[FrameIdentity]:
source_frame=source_frame,
drop_frame=drop_frame,
matrix=matrix,
primaries=primaries,
transfer=transfer,
color_range=color_range,
absolute_timestretch=absolute_timestretch,
)
)
return frames
@@ -150,6 +161,11 @@ def _optional_int(value: str) -> int | None:
return int(value) if value else None
def _optional_float(value: str) -> float | None:
value = value.strip()
return float(value) if value else None
def _format_int_list(values: list[int]) -> str:
if len(values) <= 10:
return ", ".join(str(value) for value in values)