Batch script to convert, youtube-dl webm file to mp3 with ffmpeg

youtube-dl already contains this functionality - just specify that you want mp3:

youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=BaW_jenozKc

Replace https://www.youtube.com/watch?v=BaW_jenozKc with your actual URL.


You can convert through this script:

for FILE in *.webm; do
    echo -e "Processing video '\e[32m$FILE\e[0m'";
    ffmpeg -i "${FILE}" -vn -ab 128k -ar 44100 -y "${FILE%.webm}.mp3";
done;

Save it into a .sh file and execute it. It will automatically convert all the .webm into .mp3


webm either uses vorbis or opus audio codec, both are far superior to mp3 in quality. aac audio is available on youtube, which is somewhere between opus and vorbis in quality and is heavily supported by media players and gadgets. quality wise, re-encoding lossy audio to another lossy audio is not recommended, especially if one of those autio formats is mp3.

i'd grab that aac if i were you.

as per this answer:

youtube-dl -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata <Video-URL>