From cbe5a24eda331be430808646d801bcf25165285b Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Thu, 31 Oct 2024 02:30:50 -0400 Subject: [PATCH] Remove `ae-ffmpeg` and `--my-ffmpeg` --- auto_editor/__main__.py | 11 +++-------- auto_editor/ffwrapper.py | 36 +++++++++++++++++------------------- auto_editor/render/audio.py | 2 +- auto_editor/utils/types.py | 1 - changelogs/2024.md | 5 ++++- pyproject.toml | 1 - 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/auto_editor/__main__.py b/auto_editor/__main__.py index 73887ccbb..9ecc8cde2 100755 --- a/auto_editor/__main__.py +++ b/auto_editor/__main__.py @@ -8,7 +8,7 @@ import auto_editor from auto_editor.edit import edit_media -from auto_editor.ffwrapper import FFmpeg, initFFmpeg +from auto_editor.ffwrapper import FFmpeg from auto_editor.utils.func import get_stdout from auto_editor.utils.log import Log from auto_editor.utils.types import ( @@ -166,11 +166,6 @@ def main_options(parser: ArgumentParser) -> ArgumentParser: metavar="PATH", help="Set a custom path to the ffmpeg location", ) - parser.add_argument( - "--my-ffmpeg", - flag=True, - help="Use the ffmpeg on your PATH instead of the one packaged", - ) parser.add_text("Display Options:") parser.add_argument( "--progress", @@ -279,7 +274,7 @@ def get_domain(url: str) -> str: yt_dlp_path = args.yt_dlp_location - cmd = ["--ffmpeg-location", ffmpeg.path] + cmd = ["--ffmpeg-location", ffmpeg.get_path("yt-dlp", log)] if download_format is not None: cmd.extend(["-f", download_format]) @@ -357,7 +352,7 @@ def main() -> None: is_machine = args.progress == "machine" log = Log(args.debug, args.quiet, args.temp_dir, is_machine, no_color) - ffmpeg = initFFmpeg(log, args.ffmpeg_location, args.my_ffmpeg) + ffmpeg = FFmpeg(args.ffmpeg_location) paths = [] for my_input in args.input: if my_input.startswith("http://") or my_input.startswith("https://"): diff --git a/auto_editor/ffwrapper.py b/auto_editor/ffwrapper.py index 280231b70..9a162367e 100644 --- a/auto_editor/ffwrapper.py +++ b/auto_editor/ffwrapper.py @@ -11,31 +11,29 @@ from auto_editor.utils.log import Log -def initFFmpeg(log: Log, ff_location: str | None, my_ffmpeg: bool) -> FFmpeg: - if ff_location is not None: - program = ff_location - elif my_ffmpeg: - program = "ffmpeg" - else: - try: - import ae_ffmpeg +def _get_ffmpeg(reason: str, ffloc: str | None, log: Log) -> str: + program = "ffmpeg" if ffloc is None else ffloc + if (path := which(program)) is None: + log.error(f"{reason} needs ffmpeg cli but couldn't find ffmpeg on PATH.") + return path - program = ae_ffmpeg.get_path() - except ImportError: - program = "ffmpeg" - path: str | None = which(program) - if path is None: - log.error("Did not find ffmpeg on PATH.") +@dataclass(slots=True) +class FFmpeg: + ffmpeg_location: str | None + path: str | None = None - return FFmpeg(path) + def get_path(self, reason: str, log: Log) -> str: + if self.path is not None: + return self.path + self.path = _get_ffmpeg(reason, self.ffmpeg_location, log) + return self.path -@dataclass(slots=True) -class FFmpeg: - path: str + def Popen(self, reason: str, cmd: list[str], log: Log) -> Popen: + if self.path is None: + self.path = _get_ffmpeg(reason, self.ffmpeg_location, log) - def Popen(self, cmd: list[str]) -> Popen: return Popen([self.path] + cmd, stdout=PIPE, stderr=PIPE) diff --git a/auto_editor/render/audio.py b/auto_editor/render/audio.py index cb5045489..be04b7357 100644 --- a/auto_editor/render/audio.py +++ b/auto_editor/render/audio.py @@ -122,7 +122,7 @@ def apply_audio_normalization( "null", file_null, ] - stderr = ffmpeg.Popen(cmd).communicate()[1] + stderr = ffmpeg.Popen("EBU", cmd, log).communicate()[1] name, filter_args = parse_ebu_bytes(norm, stderr, log) else: assert "t" in norm diff --git a/auto_editor/utils/types.py b/auto_editor/utils/types.py index 8d6787dc1..35fc15667 100644 --- a/auto_editor/utils/types.py +++ b/auto_editor/utils/types.py @@ -218,7 +218,6 @@ class Args: no_open: bool = False temp_dir: str | None = None ffmpeg_location: str | None = None - my_ffmpeg: bool = False progress: str = "modern" version: bool = False debug: bool = False diff --git a/changelogs/2024.md b/changelogs/2024.md index c24140720..956170ed9 100644 --- a/changelogs/2024.md +++ b/changelogs/2024.md @@ -1,8 +1,11 @@ # 26.0.1 (Unreleased) ## Fixes + - Fix `ssa` not being a known format. - Catch exception when parsing invalid bitrate. - - Remove `--show-ffmpeg-commands` `--show-ffmpeg-debug` options. + - Remove the `--my-ffmpeg` `--show-ffmpeg-commands` `--show-ffmpeg-debug` cli options. + - Remove the `ae-ffmpeg` package dependency. + - Remove unused args, functions. # 26.0.0 diff --git a/pyproject.toml b/pyproject.toml index 3e4b826ad..1f66d3a5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ requires-python = ">=3.10,<3.14" dependencies = [ "numpy>=1.23.0,<3.0", "pyav==13.1.*", - "ae-ffmpeg==1.2.*", ] keywords = [ "video", "audio", "media", "editor", "editing",