from pytube import YouTube
from moviepy.editor import *
with open('test.txt') as f:
lines = f.readlines()
for x in lines:
yt = YouTube(x)
yt.streams.filter(file_extension='mp4').first().download()
mp4_file = f"{yt.title}.mp4"
mp3_file = f"{yt.title}.mp4"
videoclip = VideoFileClip(mp4_file)
audioclip = videoclip.audio
audioclip.write_audiofile(mp3_file)
audioclip.close()
videoclip.close()
title = f"{yt.author} {yt.title}"
print(title)
Trying to convert downloaded mp4 from Youtube videos to mp3 using pytube and moviepy. Downloading the mp4's works fine however I run into this error when the conversion part happens: https://i.stack.imgur.com/loxHh.png
Tried updating ffmpeg, but it didn't help.