Hacker News new | ask | show | jobs
by thot_experiment 765 days ago
for those of us comfy with the console:

    yt-dlp -x [YouTube or other url]
6 comments

I have a command set up that basically does this:

    yt-dlp -i --format "bestaudio" -x --convert-thumbnail jpg --add-metadata --embed-metadata --embed-thumbnail --audio-format "best" -o "%(autonumber)02d %(title)s (%(upload_date>%Y-%m-%d)s) [%(id)s].%(ext)s" "https:// ... youtube URL ..."
This adds some tags and the thumbnail as cover file. It will save to whatever format the video itself has, usually .opus.
I think the "or other url" is important here. I didn't realise for a long time that I could put a reddit, Twitter or other URLs in there to download videos. You can find a complete list of supported sites here:

https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites....

This is incredibly understated, and I’ve used it for various sites, but it should be noted that the alternative sites are some times out of date in yt-dlp.

I was hoping for a working download for NPR Music, but it failed me last week for Kiefer’s set on Tiny Desk. Couldn’t airplay or chromecast it (without doing the whole screen, with all the trade offs that entails), and HDMI did a weird thing on macOS where the playback was sped up in every major browser.

Had a resort to a Firefox extension to download the video and Plex it in order to use the TV. Of course, I didn’t see if they had a Roku or similar app, and was just impatient to wait for the YouTube upload. Sigh.

Oh yes. I know 'the others'. Works well.
Thanks, I didn't know about -x !

My usual is:

    yt-dlp -f 140 [url]
The -f 140 maps to the m4a format.
"-f m4a" also works and it's easier to remember.
Why not Opus.
There are many reasons, and as a user of Opus you are probably aware of the trade offs?
Haven't tracked trade offs recently, but I always use Opus when I save audio from Youtube since it's the best codec option there.
Wait what, what situation is opus worse than m4a? In my ABXing it's never lost to another lossy format.
My personal ecosystem is built around Apple-native formats.
I used to download with yt-dlp -x. But the sound is not good at all. I am not using a re-encoded format, so some yt videos may not have good sound quality.
imo a better alternative (did not test on other sites)

yt-dlp -f bestaudio <url>

it directly downloads the audio from youtube and does not require ffmpeg unlike the -x option. moreover, you can specify format (m4a or default webm) like so - replace "bestaudio" with "bestaudio[ext=<format>]"

this only falls short unless you explicitly need it in mp3 container.

my first reaction as well