Why is it so complicated to extract audio from a YouTube video
Because YouTube actively attempts to block the practice. A few things are happening here to thwart you:
- If you're specifically looking for an MP3, most videos don't have their audio track encoded in that format so it'll be a transcode rather than a direct extraction.
- Youtube makes its money via inline advertising, and people who download the video or audio could then replay it without the advertising, or even republish it on their own channel to monetize it. So YouTube tries to block downloading.
- Youtube is beholden to movie and record companies, and must actively police their platform for infringement, preventing downloads is one aspect of that defense.
There are lots of web sites which will do the trick for you. But keep in mind that anything you see which circumvents the blockers is going to be made by people who are OK with circumventing protections. I'm not saying that all things which circumvent protections are made by amoral people, I'm saying be careful of which ones you use. For instance there are a lot of web sites which advertise being able to do this task for you, and some of them might deliver malware too. Just be careful. Mark's suggestion of a particular Firefox plugin is probably fine. There are also Chrome plugin alternatives.
My most recent solution is to use the command line program "
YouTube-Dl". It's open source and it comes with the added benefit of being able to extract audio and video from places other than just YouTube. I've been using it for years and it's been safe; I haven't seen it deliver any malware yet. It integrates well with another command line program, ffmpeg, to do things like post-download transcoding, aspect ratio changes, trimming, that sort of thing. Perhaps the most useful part is that it's constantly being updated with new code to keep up with the "arms race" of web sites which are constantly updating their blocker schemes. However, to use the software, you have to learn its complicated command line parameters and understand the available audio and video formats of the thing you're trying to download. The advantage is that it's got a lot of power and configurability, and because it's command-line, it can be scripted.