From 1ab6094322c8ba79e91fb26eab818e84522e72fb Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sun, 6 Oct 2024 00:32:07 -0400 Subject: [PATCH] Use PyAV 13.1 --- auto_editor/ffwrapper.py | 9 ++------- auto_editor/render/audio.py | 3 +-- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/auto_editor/ffwrapper.py b/auto_editor/ffwrapper.py index 8197fb562..f57eaabf9 100644 --- a/auto_editor/ffwrapper.py +++ b/auto_editor/ffwrapper.py @@ -95,17 +95,12 @@ def Popen( return Popen([self.path] + cmd, stdin=stdin, stdout=stdout, stderr=stderr) -def mux(input: Path, output: Path, stream: int, codec: str | None = None) -> None: +def mux(input: Path, output: Path, stream: int) -> None: input_container = av.open(input, "r") output_container = av.open(output, "w") input_audio_stream = input_container.streams.audio[stream] - - if codec is None: - codec = "pcm_s16le" - - output_audio_stream = output_container.add_stream(codec) - assert isinstance(output_audio_stream, av.audio.AudioStream) + output_audio_stream = output_container.add_stream("pcm_s16le") for frame in input_container.decode(input_audio_stream): packet = output_audio_stream.encode(frame) diff --git a/auto_editor/render/audio.py b/auto_editor/render/audio.py index f7ad84c39..9de89dff0 100644 --- a/auto_editor/render/audio.py +++ b/auto_editor/render/audio.py @@ -180,7 +180,6 @@ def process_audio_clip( output_bytes = io.BytesIO() output_file = av.open(output_bytes, mode="w", format="wav") output_stream = output_file.add_stream("pcm_s16le", rate=sr) - assert isinstance(output_stream, av.audio.AudioStream) graph = av.filter.Graph() args = [graph.add_abuffer(template=input_stream)] @@ -212,7 +211,7 @@ def process_audio_clip( while True: try: aframe = graph.pull() - assert isinstance(aframe, av.audio.AudioFrame) + assert isinstance(aframe, av.AudioFrame) for packet in output_stream.encode(aframe): output_file.mux(packet) except (av.BlockingIOError, av.EOFError): diff --git a/pyproject.toml b/pyproject.toml index ef8b0185e..3e4b826ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ authors = [{ name = "WyattBlue", email = "wyattblue@auto-editor.com" }] requires-python = ">=3.10,<3.14" dependencies = [ "numpy>=1.23.0,<3.0", - "pyav==13.0.*", + "pyav==13.1.*", "ae-ffmpeg==1.2.*", ] keywords = [