I'm trying to read a complete audio stream from a video file into a numpy array:
container = av.open(videoFile)
audioStream = container.streams.audio[audioIndex]
audio = []
for frame in container.decode(audioStream):
audio.append(frame.to_ndarray())
audio = np.hstack(audio)
Is this the correct way, or is it possible to do it in a more efficient way?
I thought about preallocating the numpy array, but audioStream.frames is 0 and audioStream.frames is None.