I'm trying to extract the audio from a pytube video, then convert it into wav format. For extracting the audio from the video, I tried to use moviepy, but I can't find a way to open a video file from bytes with VideoFileClip. I don't want to keep saving files then reading them.
My attempt:
from pytube import YouTube
import moviepy.editor as mp
yt_video = BytesIO()
yt_audio = BytesIO()
yt = YouTube(text)
videoStream = yt.streams.get_highest_resolution()
videoStream.stream_to_buffer(yt_video) # save video to buffer
my_clip = mp.VideoFileClip(yt_video) # processing video
my_clip.audio.write_audiofile(yt_audio) # extracting audio from video