-
I'm trying to write a code that reads a video/audio file with multiple audio channels and extracts only one channel and write it to another file. My main problem is when I initialize a new audio frame using: And in the same time, I cannot update the original frame calling Update_buffer method with half of the samples since I will get something like "ValueError: got 2048 bytes; need 4096 bytes". And of course, also I cannot delete panels !!! I was searching in the API documentation for anything that may help but I couldn't. Can you give me an advice about this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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() |
Beta Was this translation helpful? Give feedback.
Here's an example: