-
Notifications
You must be signed in to change notification settings - Fork 420
Closed
Description
Hello!
I want to get opus packet (60ms, 16000, mono) stream from any url source, trying to do something like this
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()
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
audio_encoder = av.AudioEncoder('opus')and I need this encoded data without container and in bytes format
Can you get me direction?
thanks!
Metadata
Metadata
Assignees
Labels
No labels