Skip to content

Commit

Permalink
Remove --show-ffmpeg-commands --show-ffmpeg-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Oct 24, 2024
1 parent b8ed49e commit 841f56a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 38 deletions.
2 changes: 1 addition & 1 deletion auto_editor/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "26.0.0"
__version__ = "26.0.1"
14 changes: 1 addition & 13 deletions auto_editor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ def main_options(parser: ArgumentParser) -> ArgumentParser:
help="Set what type of progress bar to use",
)
parser.add_argument("--debug", flag=True, help="Show debugging messages and values")
parser.add_argument(
"--show-ffmpeg-commands", flag=True, help="Show ffmpeg commands"
)
parser.add_argument(
"--show-ffmpeg-output", flag=True, help="Show ffmpeg stdout and stderr"
)
parser.add_argument("--quiet", "-q", flag=True, help="Display less output")
parser.add_argument(
"--preview",
Expand Down Expand Up @@ -363,13 +357,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,
args.show_ffmpeg_commands,
args.show_ffmpeg_output,
)
ffmpeg = initFFmpeg(log, args.ffmpeg_location, args.my_ffmpeg)
paths = []
for my_input in args.input:
if my_input.startswith("http://") or my_input.startswith("https://"):
Expand Down
23 changes: 5 additions & 18 deletions auto_editor/ffwrapper.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
from __future__ import annotations

import sys
from dataclasses import dataclass
from fractions import Fraction
from pathlib import Path
from shutil import which
from subprocess import PIPE, Popen, run
from typing import Any

import av

from auto_editor.utils.log import Log


def initFFmpeg(
log: Log, ff_location: str | None, my_ffmpeg: bool, show_cmd: bool, debug: bool
) -> FFmpeg:
def initFFmpeg(log: Log, ff_location: str | None, my_ffmpeg: bool) -> FFmpeg:
if ff_location is not None:
program = ff_location
elif my_ffmpeg:
Expand All @@ -32,30 +28,21 @@ def initFFmpeg(
if path is None:
log.error("Did not find ffmpeg on PATH.")

return FFmpeg(log, path, show_cmd, debug)
return FFmpeg(log, path)


@dataclass(slots=True)
class FFmpeg:
log: Log
path: str
show_cmd: bool
debug: bool

def run(self, cmd: list[str]) -> None:
cmd = [self.path, "-hide_banner", "-y"] + cmd
if not self.debug:
cmd.extend(["-nostats", "-loglevel", "error"])
if self.show_cmd:
sys.stderr.write(f"{' '.join(cmd)}\n\n")
cmd.extend(["-nostats", "-loglevel", "error"])
run(cmd)

def Popen(
self, cmd: list[str], stdin: Any = None, stdout: Any = PIPE, stderr: Any = None
) -> Popen:
if self.show_cmd:
sys.stderr.write(f"{self.path} {' '.join(cmd)}\n\n")
return Popen([self.path] + cmd, stdin=stdin, stdout=stdout, stderr=stderr)
def Popen(self, cmd: list[str]) -> Popen:
return Popen([self.path] + cmd, stdout=PIPE, stderr=PIPE)


def mux(input: Path, output: Path, stream: int) -> None:
Expand Down
4 changes: 1 addition & 3 deletions auto_editor/render/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io
from pathlib import Path
from platform import system
from subprocess import PIPE

import av
import numpy as np
Expand Down Expand Up @@ -122,8 +121,7 @@ def apply_audio_normalization(
"null",
file_null,
]
process = ffmpeg.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
stderr = process.communicate()[1]
stderr = ffmpeg.Popen(cmd).communicate()[1]
name, filter_args = parse_ebu_bytes(norm, stderr, log)
else:
assert "t" in norm
Expand Down
2 changes: 1 addition & 1 deletion auto_editor/utils/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def merge(start_list: np.ndarray, end_list: np.ndarray) -> BoolList:
def get_stdout(cmd: list[str]) -> str:
from subprocess import DEVNULL, PIPE, Popen

stdout, _ = Popen(cmd, stdin=DEVNULL, stdout=PIPE, stderr=PIPE).communicate()
stdout = Popen(cmd, stdin=DEVNULL, stdout=PIPE, stderr=PIPE).communicate()[0]
return stdout.decode("utf-8", "replace")


Expand Down
2 changes: 0 additions & 2 deletions auto_editor/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ class Args:
version: bool = False
debug: bool = False
config: bool = False
show_ffmpeg_commands: bool = False
show_ffmpeg_output: bool = False
quiet: bool = False
preview: bool = False
no_cache: bool = False
Expand Down
6 changes: 6 additions & 0 deletions changelogs/2024.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 26.0.1 (Unreleased)

## Fixes
- Catch exception when parsing invalid bitrate.
- Remove `--show-ffmpeg-commands` `--show-ffmpeg-debug` options.

# 26.0.0

## Major
Expand Down

0 comments on commit 841f56a

Please sign in to comment.