Downloading Videos As Audio Using YT-DLP

As you will more than likely be wanting the best quality audio the format (-f) selector will be for best audio (ba).

yt-dlp -f ‘ba’ -o ‘%(id)s.%(ext)s’

To save as the video title change %(id)s.%(ext)s to '%(title)s.%(ext)s' to save. For a custom filename songname.%(ext)s.

With YouTubes VP9 codec this file will most likely be .webm or .opus extension.

Saving video as an MP3 file

To save the highest quality audio as an mp3 file you need to define --audio-format mp3 with -x which is extract audio

$ yt-dlp -f 'ba' -x --audio-format mp3  -o '%(id)s.%(ext)s'