OpenTranscode/opentranscode/__init__.py

70 lines
2.7 KiB
Python

"""opentranscode — open-source batch video transcoder (av1an + ffmpeg).
A PySide6 GUI application that orchestrates av1an + ffmpeg for batch video
transcoding. Distro-aware, config-driven (codec / audio / container /
resolution / license profiles), with a QThread-based encoder worker, a
from-git source builder for resolving VapourSynth / av1an ABI mismatches,
and a retro-futuristic media-console UI.
This package is the production code path. The single-file
``open-transcode.py`` script is preserved alongside it for backwards
compatibility and as the test target for the mocked test suite.
Run as a module:
python -m opentranscode # launch the GUI
python -m opentranscode --version # print version and exit
python -m opentranscode --dry-run # probe env + smoke test, no GUI
python -m opentranscode --verify-only /path/to/output.mkv
Or import in code:
import opentranscode
print(opentranscode.__version__)
"""
from __future__ import annotations
__version__ = "4.0.0"
__author__ = "Jeremy Anderson - dcos.net"
__license__ = "AGPL-3.0"
__all__ = [
"__version__",
"__author__",
"__license__",
"build_parser",
"main",
"launch_gui",
]
# Lightweight re-exports for convenience. Heavy modules (env_probe,
# encoder_worker, ui_window) are NOT imported here so that
# ``import opentranscode`` works without PySide6 being available — this
# keeps ``opentranscode.__version__`` cheap and side-effect-free for
# ``--version`` and for tooling that just wants the metadata.
from .cli import build_parser, main
def launch_gui(argv: list[str] | None = None, force: bool = False,
chunk_method: str | None = None) -> int:
"""Launch the OpenTranscode GUI.
Thin wrapper around ``opentranscode.ui_window.launch_gui``; imported
lazily so that ``import opentranscode`` does not pull in PySide6.
Args:
argv: Optional argv list for QApplication. Defaults to sys.argv.
force: Pre-check the "Force (skip validation)" checkbox — skips
ffprobe pre-validation and attempts encode even for files
ffprobe cannot read. WARNING: invalid files will waste the
full per-file timeout before failing.
chunk_method: Override av1an's chunk-method selection (v4.0.0).
When not None, the value is written to
``env.av1an_flags["chunk_method_override"]`` after the
environment probe runs, so every EncoderWorker picks it up.
Useful for forcing ``select`` to avoid the Hybrid chunk
method's failure on phone-recorded MP4s with sparse
keyframes. ``"auto"`` clears any override the probe set.
"""
from .ui_window import launch_gui as _launch
return _launch(argv, force=force, chunk_method=chunk_method)