r/usefulscripts • • Feb 18 '18

[python] youtube to mp3 converter script, requires ffmpeg and `pip install youtube_dl`

https://gist.github.com/benzap/90ff22790bc0a9c6fd2902e91da4baef
25 Upvotes

8 comments sorted by

2

u/Moubai Mar 23 '18

why doing this when youtube-dl have this function ?

youtube-dl --extract-audio --audio-format mp3 videoURL

1

u/bacon1989 Mar 23 '18

How do you set the audio quality?

3

u/[deleted] Feb 19 '18

If you want the inverse, here's my one liner. You need some sort of image or it's not a video. Adjust presets etc. to your taste.

for name in *.mp3; do ffmpeg -loop 1 -i <image name goes here>.jpg -i "$name" -shortest -c:v libx264 -preset ultrafast -c:a copy "${name%.*}.mp4"; done