Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ae-ffmpeg and --my-ffmpeg #580

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions auto_editor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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://"):
Expand Down
36 changes: 17 additions & 19 deletions auto_editor/ffwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion auto_editor/render/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion auto_editor/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion changelogs/2024.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down