Hello! I want to get opus packet (60ms, 16000, mono) stream from any url source, trying to do something like this ```python import av SAMPLE_RATE = 16000 CHUNK_DURATION = 0.06 CHUNK_SIZE = int(CHUNK_DURATION * SAMPLE_RATE) resampler = av.AudioResampler('s16', 'mono', SAMPLE_RATE) container = av.open('file.avi') stream = container.streams.audio[0] audio_buffer = [] for packet in container.demux(stream): for frame in packet.decode(): for f in resampler.resample(frame): ``` here I want accumulate samples in audio_buffer, but don't understand how to do it properly first version is to use f.to_ndarray() second version is use bytes() ```python for p in f.planes: audio_buffer.extend(bytes(p)) ``` maybe you can help me to choose? In result I want get AudioFrame('s16', 'mono', SAMPLE_RATE) with duration 60ms and make encode to opus format I am planning do it with something like ```python audio_encoder = av.AudioEncoder('opus') ``` and I need this encoded data without container and in bytes format Can you get me direction? thanks!
Activity
vinnitu commentedon Jul 20, 2023
Ok, I am able to do half of work ))
The question is how to encode frame to opus codec and get result bytes?