Files
removeads/src/tscut/models.py
T

62 lines
1.4 KiB
Python

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2026 Frédéric Tronel
from dataclasses import dataclass
from datetime import timedelta
from enum import IntEnum, unique
from pathlib import Path
from typing import IO, BinaryIO
from tscut.h264.avc import AVCDecoderConfiguration
@unique
class SupportedFormat(IntEnum):
TS = 1
MP4 = 2
MATROSKA = 3
def __str__(self):
match self:
case SupportedFormat.TS:
return 'mpegts'
case SupportedFormat.MP4:
return 'mov,mp4,m4a,3gp,3g2,mj2'
case SupportedFormat.MATROSKA:
return 'matroska,webm'
case _:
return 'Unsupported format'
@dataclass
class ProcessingOptions:
input_file: Path
output_file: Path
parts: list[tuple[timedelta, timedelta]]
tools_paths: dict[str, str]
all_optional_tools: bool
framerate: int|None = None
threshold: int = 0
coarse: bool = False
subtitles_ocr: bool = True
verbose: bool = False
dump_memory: bool = False
keep_temporaries: bool = False
@dataclass
class PreparedMedia:
basename: str
movie: BinaryIO
duration: timedelta
framerate: float
streams: list
width: int
height: int
avc_config: AVCDecoderConfiguration
@dataclass
class CutResult:
filename: str
movie: IO[bytes]
check_positions: list[timedelta]