Skip to content

Commit

Permalink
Use PyAV 13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Oct 6, 2024
1 parent 06724d5 commit 1ab6094
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
9 changes: 2 additions & 7 deletions auto_editor/ffwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions auto_editor/render/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [{ name = "WyattBlue", email = "[email protected]" }]
requires-python = ">=3.10,<3.14"
dependencies = [
"numpy>=1.23.0,<3.0",
"pyav==13.0.*",
"pyav==13.1.*",
"ae-ffmpeg==1.2.*",
]
keywords = [
Expand Down

0 comments on commit 1ab6094

Please sign in to comment.