Skip to content

Commit

Permalink
Add opts for setting video format and bitdepth
Browse files Browse the repository at this point in the history
This changes the profile format
  • Loading branch information
JuniorIsAJitterbug committed Apr 25, 2024
1 parent b0f8a5f commit 40b14d2
Show file tree
Hide file tree
Showing 27 changed files with 1,199 additions and 734 deletions.
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ keywords = ["vhs-decode", "ld-decode", "cvbs-decode", "tbc", "rf capture"]
[tool.poetry.dependencies]
python = ">=3.10,<3.13"
pywin32 = [{ version = "^306", platform = "win32", source = "pypi" }]
typing-extensions = "^4.10.0"

[tool.poetry.scripts]
tbc-video-export = "tbc_video_export.__main__:main"
Expand Down
68 changes: 61 additions & 7 deletions src/tbc_video_export/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,66 @@ def __str__(self) -> str:
return self.name.upper()


class ProfileType(Enum):
"""Profile types for FFmpeg."""
class VideoBitDepthType(Enum):
"""Video bitdepth types for profiles."""

BIT8 = "8bit"
BIT10 = "10bit"
BIT16 = "16bit"


class ProfileVideoType(Enum):
"""Video types for profiles."""

LOSSLESS = "lossless"


class VideoFormatType(Enum):
"""Video format types for profiles."""

GRAY = {
8: "gray8",
10: "gray16le",
16: "gray16le",
}
YUV420 = {
8: "yuv420p",
10: "yuv420p10le",
16: "yuv420p16le",
}
YUV422 = {
8: "yuv422p",
10: "yuv422p10le",
16: "yuv422p16le",
}
YUV444 = {
8: "yuv444p",
10: "yuv444p10le",
16: "yuv444p16le",
}

DEFAULT = TBCType.CHROMA | TBCType.COMBINED
LUMA = TBCType.LUMA
@classmethod
def get_new_format(cls, current_format: str, new_bitdepth: int) -> str | None:
"""Return new format from current format and new bitdepth."""
return next(
(
member.value.get(new_bitdepth)
for member in cls
for _, v in member.value.items()
if current_format == v
),
None,
)

def __str__(self) -> str:
"""Return formatted enum name as string."""
return self.name.upper()
@classmethod
def get_bitdepth(cls, current_format: str) -> int | None:
"""Return bitdepth of current format."""
return next(
(
k
for member in cls
for k, v in member.value.items()
if current_format == v
),
None,
)
2 changes: 1 addition & 1 deletion src/tbc_video_export/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class InvalidProfileError(Exception):

def __init__(self, message: str, config_path: Path | None = None) -> None:
super().__init__(message)
self.config_path = config_path
self.config_path = config_path if config_path is not None else "[internal]"


class InvalidFilterProfileError(Exception):
Expand Down
7 changes: 4 additions & 3 deletions src/tbc_video_export/common/file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tbc_video_export.common.enums import FlagHelper, ProcessName, TBCType
from tbc_video_export.common.tbc_json_helper import TBCJsonHelper
from tbc_video_export.common.utils import files
from tbc_video_export.config.config import GetProfileFilter

if TYPE_CHECKING:
from tbc_video_export.config.config import Config
Expand All @@ -25,8 +26,8 @@ def __init__(self, opts: Opts, config: Config) -> None:
self._opts = opts
self._config = config

self._profile = self._config.get_profile(self._opts.profile)
self._profile_luma = self._config.get_profile(self._opts.profile_luma)
self._profile = self._config.get_profile(GetProfileFilter(self._opts.profile))
self._video_subtype = self._opts.video_profile

# initially set both input and output files to the input file
# file without file extension
Expand Down Expand Up @@ -154,7 +155,7 @@ def output_video_file_luma(self) -> Path:
This is used when two-step is enabled when merging.
"""
return self.get_output_file_from_ext(
f"{consts.TWO_STEP_OUT_FILE_LUMA_SUFFIX}.{self._profile_luma.video_profile.container}"
f"{consts.TWO_STEP_OUT_FILE_LUMA_SUFFIX}.{self.output_container}"
)

def get_log_file(self, process_name: ProcessName, tbc_type: TBCType):
Expand Down
Loading

0 comments on commit 40b14d2

Please sign in to comment.