Disallow setting unsupported vcodec.
This commit is contained in:
parent
215a023da8
commit
314752a644
4 changed files with 13 additions and 11 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -34,6 +34,7 @@
|
|||
"Cfmrc",
|
||||
"choco",
|
||||
"cifs",
|
||||
"connectionpool",
|
||||
"consoletitle",
|
||||
"continuedl",
|
||||
"cookiesfrombrowser",
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import sys
|
|||
from pathlib import Path
|
||||
from typing import Any, Protocol
|
||||
|
||||
SUPPORTED_CODECS: tuple[str] = ("h264_qsv", "h264_nvenc", "h264_amf", "h264_videotoolbox", "h264_vaapi", "libx264")
|
||||
"Supported encoder names in order of preference."
|
||||
|
||||
|
||||
def has_dri_devices() -> bool:
|
||||
"""
|
||||
|
|
@ -40,6 +37,7 @@ def ffmpeg_encoders() -> set[str]:
|
|||
set[str]: A set of available ffmpeg encoder names.
|
||||
|
||||
"""
|
||||
from .config import SUPPORTED_CODECS
|
||||
try:
|
||||
result: subprocess.CompletedProcess[str] = subprocess.run(
|
||||
["ffmpeg", "-hide_banner", "-loglevel", "error", "-encoders"], # noqa: S607
|
||||
|
|
@ -75,6 +73,7 @@ def select_encoder(configured: str) -> str:
|
|||
str: The selected concrete encoder name.
|
||||
|
||||
"""
|
||||
from .config import SUPPORTED_CODECS
|
||||
configured = (configured or "").strip()
|
||||
|
||||
avail: set[str] = ffmpeg_encoders()
|
||||
|
|
|
|||
|
|
@ -10,15 +10,9 @@ from typing import TYPE_CHECKING, Any, ClassVar
|
|||
|
||||
from aiohttp import web
|
||||
|
||||
from .config import Config
|
||||
from .config import SUPPORTED_CODECS, Config
|
||||
from .ffprobe import ffprobe
|
||||
from .SegmentEncoders import (
|
||||
SUPPORTED_CODECS,
|
||||
encoder_fallback_chain,
|
||||
get_builder_for_codec,
|
||||
has_dri_devices,
|
||||
select_encoder,
|
||||
)
|
||||
from .SegmentEncoders import encoder_fallback_chain, get_builder_for_codec, has_dri_devices, select_encoder
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from asyncio.subprocess import Process
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ from .version import APP_BRANCH, APP_BUILD_DATE, APP_COMMIT_SHA, APP_VERSION
|
|||
if TYPE_CHECKING:
|
||||
from subprocess import CompletedProcess
|
||||
|
||||
SUPPORTED_CODECS: tuple[str] = ("h264_qsv", "h264_nvenc", "h264_amf", "h264_videotoolbox", "h264_vaapi", "libx264")
|
||||
"Supported encoder names in order of preference."
|
||||
|
||||
|
||||
class Config(metaclass=Singleton):
|
||||
app_env: str = "production"
|
||||
|
|
@ -417,6 +420,11 @@ class Config(metaclass=Singleton):
|
|||
msg: str = f"Invalid app environment '{self.app_env}' specified. Must be 'production' or 'development'."
|
||||
raise ValueError(msg)
|
||||
|
||||
if self.streamer_vcodec and self.streamer_vcodec not in SUPPORTED_CODECS:
|
||||
supported = ", ".join(SUPPORTED_CODECS)
|
||||
msg: str = f"Invalid video codec '{self.streamer_vcodec}' specified. Supported: '{supported}'."
|
||||
raise ValueError(msg)
|
||||
|
||||
if "dev-master" == self.app_version:
|
||||
self._version_via_git()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue