Skip to content

conversion from stereo stream to mono stream #938

Closed Answered by WyattBlue
marnaoty asked this question in 1. Help
Discussion options

You must be logged in to vote

Here's an example:

import av

input_file = av.open("input_stereo.wav")
audio_stream = input_file.streams.audio[0]

output = av.open("output_mono.wav", mode="w")
out_stream = output.add_stream("pcm_s16le", layout="mono", rate=audio_stream.rate)

for frame in input_file.decode(audio_stream):
    packet = out_stream.encode(frame)
    output.mux(packet)

input_file.close()
output.close()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by WyattBlue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #276 on March 26, 2022 11:21.