NOTE TO ALL READERS:
CYB3RBYTE wrote: ↑
Wed Jan 30, 2019 3:16 pm
So, I installed the entire script and everything ran as it should, including the animation at the end.
HOWEVER, when I go to terminal and type in mpv followed by that web address, it will either tell me the stream is not availible (which is correct at the time of posting), or it will tell me that I need to include the full youtube.dl header or something.
This person is trying to use my GPU-accelerated software suite to watch live video streams from the Monterey Bay Aquarium
in California. These live streams are simply embedded YouTube videos. I decided to write an in-depth exploration of this topic because youtube-dl is such a fundamental tool in my offering.
Since you saw the "animation" at the very end of my script's execution – the NASA video of colliding neutron stars – that means everything in my script worked perfectly!
I obviously have no clue what URL you entered immediately after "mpv" in the command line – or how you obtained it – since you didn't disclose any of that information. It's also hard to make much of an "or something" when an error message is being described!
But none of that really matters, since my software suite merely USES
youtube-dl – the most robust video downloader on the planet. It's important to realize, however, that my script does not modify youtube-dl or its behavior in any manner whatsoever. As you probably saw, it merely downloads and installs the latest version at the very end of my script. In other words, youtube-dl is the one program that is NOT
"built" by my script.
So if you're getting an error related to youtube-dl, there are at least 9 possibilities – all of which have absolutely NOTHING
to do with my script or the software it builds on your system! Here they are, in no particular order:
The video / live stream is simply down, deleted or has been privatized – either temporarily or permanently.
The URL has changed or expired. The most common scenario is that the URL has simply expired. Most "live streams" come to an end after x hours. At that point, if a new live stream is started on the same topic – even if it has the exact same title as the previous live stream – YouTube will assign it a completely NEW
and different URL!
You accidentally entered a wrong URL or made a typo.
Youtube-dl might need an update (although in this case, since you just ran my script a day ago, that's unlikely to be the issue – but it's still theoretically possible, since updates are issued all the time). Websites and video servers constantly change the way they handle video, so the developers of youtube-dl must continuously update their software to keep up with all the changes. In fact, my copy of youtube-dl, which was only 4 weeks old, recently stopped working for ALL
YouTube videos. Sure enough, upon updating youtube-dl to the latest version, everything worked perfectly again! To update youtube-dl, simply run the following command line in Terminal. All of this, by the way, is discussed in my extremely thorough Appendix 2
sudo pip install --upgrade youtube_dl
There'something wrong with the latest version of youtube-dl (a possibility I just ruled out through testing).
There's something wrong with your "Internet connection". This doesn't necessarily mean there's anything wrong with "your" connection, because I'm using the term in the most sweeping (and meaningful) sense. I'm referring to the entire "connection chain" – from your current location all the way to the very last physical connection to the server. A chain is only as strong as its weakest link – wherever that weak link may be. All of that is completely beyond the control of youtube-dl, but a connection problem will still generate a youtube-dl "error" – even though it has absolutely nothing to do with youtube-dl! It's youtube-dl's way of saying "hey, I can't do this – I'm encountering a connection error!" So just because youtube-dl is throwing an error message does not necessarily mean there's anything wrong with youtube-dl.
There's something wrong with the server that hosts the video.
There's something wrong or "unorthodox" about the web page or other code on the server.
The server's copy of the video file, or its metadata, is damaged.
On top of all that, I just visited the Monterey Bay Aquarium's website
and some of their live streams are TOTALLY DOWN
at the moment. And by "totally down", I don't just mean there isn't any daylight in California right now – and therefore the camera's been temporarily turned off for the night. I mean that some of them are DOWN – as in "totally down for maintenance". That could last 2 hours, 2 days, or 2 weeks. Who knows! This might change at any moment – but just to prove my point, here's a screenshot from their webcam page. It was working the other day, but it's definitely offline as I write these words:
In general, before you question any streaming-related software, your best bet is to simply pop the YouTube URL directly into a web browser to see if the video even appears. If it doesn't appear, you can rule out any problem that's specific to the streaming software.
Also, a best practice when attempting to acquire the "real URL" for embedded YouTube videos on a 3rd-party website is to actually click the video in your browser like a normal user would and let it start playing for a few seconds. Then, do this:
Mouse over the video and click the right-pointing "share arrow" in the upper-right corner to get the YouTube video's direct link. But the fun doesn't stop there, because that's not really a truly direct link (it's more the product of a "URL shortener" – a kind of alias).
When the "share URL" appears in the middle of the video, you need to right-click it and then click "Copy link address". That will put something like this in your clipboard:
If you then pop that URL into a standard web browser, you'll see it's automatically transformed into something like this (note that the core video "ID" – the 11-character string that says "DruzdeTAPvQ" – never changes in these steps – even though the rest of the URL changes a bit):
But the truly "direct" and "totally pure" link is actually this – the same as above, but stripped of the "&feature=youtu.be" at the end:
That said, youtube-dl does an outstanding job of "parsing" and making sense of YouTube links in ANY
form. Nonetheless, I still wanted to point out how to get the "purest" YouTube URL. At a minimum, it makes youtube-dl's parsing a bit quicker as it prepares the video stream to be handed off to mpv. Although by "quicker", I'm only talking about a second or two.
Keep in mind, however, that you can't just submit a random web page to youtube-dl that happens to contain an embedded video and expect youtube-dl – or mpv, which simply uses youtube-dl – to automatically capture the "hidden" video URL with 100% certainty. That's because website designers sometimes use "unorthodox" code that accidentally or deliberately obfuscates the video URL. Youtube-dl does an outstanding job of automatically parsing a large majority of sites – but if you're having problems, there's nothing like obtaining the "real", direct URL to the video. In the case of deliberate obfuscation, of course, that may not be possible. I explore many of these topics in Appendix 4
Separately, if you already know the exact title of a video you like – and you know it's on YouTube anyway – you might as well just search for the video directly on YouTube.com and grab the "pure" URL directly from there instead of fiddling with some 3rd-party website – whether it's the Monterey Bay Aquarium or any other site.
My final observation is this: What johndavies mentioned is certainly true. YouTube URLs for "live streams" can change. I pointed this out in item #2 at the top of this post. Here's proof of that. Let's do a search for this exact title (in quotes) – directly on YouTube itself:
"Live Monterey Bay Cam"
You can check it out for yourself right now by clicking this link:
Sure enough, if you scroll through the search results, you'll see there are SEVERAL
videos with the EXACT SAME TITLE
Live Monterey Bay Cam - Monterey Bay Aquarium
But only the top result is actually live – it's explicitly marked by a "LIVE NOW" icon. The other ones are older recordings – and even though they have the exact same title, they also have totally different URLs. So in just a day or two – or even a minute or two – the "live" URL may no longer be the "live" URL! There are tons of reasons why this might happen, but one of the most common would be that the Aquarium is simply taking the camera offline for brief periods of maintenance. Then, when they resume the broadcast, YouTube treats it as a brand-new video and therefore assigns it a new URL.
In my experience, the only time this does NOT
happen is when you're dealing with a major broadcaster, like France 24, that has a truly uninterrupted, highly reliable, 24/7/365 broadcast. They may also have a special relationship with YouTube at the corporate level to assure that the video's URL does not change. But even with a live stream like France 24, there's certainly no guarantee that it will remain that way forever. At a minimum, the eventual heat death or total collapse of the entire universe will probably have a little something to say about the stability of the URL!