Source of YouTube video can't be find on HTML - html

I just wondering how youtube displays the Video on their web app without the tag?
I also want to implement that kind of technique from my other future web apps.

TL;DR
It's because the video is streamed asynchronously, and not loaded at once. In HTML you will only find a player-container, which is a placeholder for the frames to be fed into it.
A bit more
When you click on a video, the metadata of the video loads first (title, description, etc.), then the stream flows through a socket, depending on the settings you have.
If there were a a fixed source in the HTML for which the video is loaded, changing the settings (playback speed, resolution, etc.) would have resulted in a page refresh!
In addition, YouTube prevents un-permissioned video downloads for a while now, another reason why not to provide a direct source to the video blob.

Related

What happens to webRTC/getUserMedia if hidden?

I'm building a website where you can open a modal view with a video-tag for the users web cam video.
Now I'm wondering what happens to my video stream/the content of the video-tag when the user closes the modal view (the view is hidden via display: none).
Is webRTC still running? Are the resources still reserved?
Thanks
Yes, even if you don't attach the received stream to any media element, the stream is still being played. This is valid for remote and local streams. Of course, if it has audio, you will only hear it when it is attached to a media tag (audio or video).
You can even remove media elements from the page. When they get back on dom, if you attach the stream, they will continue to play.

Load only audio from youtube in as3

Is it possible to load only the audio from YouTube into my AS3 flash custom player through youtube AS3 api?
I want to load it into a sound object and then assign it to a sound channel.
I would like to know if there is an "official" way to do this, I'd like to avoid improvising (like loading the whole stream and then use only the audio).
Thank you.
I suggest you read the YouTube terms of service carefully:
https://developers.google.com/youtube/terms
In particular, you may not "promote separately the audio or video components of any YouTube audiovisual content made available through the YouTube API".
Doing so in any way (such as moving the video off stage) is likely to have your site blocked for playbacks by YouTube for breach of terms of service.
NB: YouTube manages to provide the service it does through advertising on top of video content. Separating the content like this prevents YouTube from making any money from the service it is providing.
If you use it for private usage, its okay I guess.
After some research work with different APIs and libraries and researching source code, I just tried it by myself and wolla.
Just saying, audio only links are in the page source of each video.
You just have to know what you are looking for ;)
Open a youtube video, view page source and search for "mime%3Daudio". There should be 5 matches, full url for example:
"https%3A%2F%2Fr2---sn-35cxanpbo5a-8pxl.googlevideo.com%2Fvideoplayback%3Fsource%3Dyoutube%26signature%3D30EC556F55533FBFD9003767730D10556681F33A.B12E021CA54CCB9E225F58A4430E9BB528081FB5%26requiressl%3Dyes%26expire%3D1527306011%26clen%3D3064602%26initcwndbps%3D1152500%26ipbits%3D0%26mime%3Daudio%252Fmp4%26dur%3D192.911%26fvip%3D5%26lmt%3D1524946334873350%26key%3Dyt6%26sparams%3Dclen%252Cdur%252Cei%252Cgir%252Cid%252Cinitcwndbps%252Cip%252Cipbits%252Citag%252Ckeepalive%252Clmt%252Cmime%252Cmm%252Cmn%252Cms%252Cmv%252Cpl%252Crequiressl%252Csource%252Cexpire%26itag%3D140%26gir%3Dyes%26ip%3D81.217.53.239%26id%3Do-ALNxMeQYw4LLc1FAjxt4h795wKTdqJnzc_SBgzEJVBxR%26c%3DWEB%26keepalive%3Dyes%26mm%3D31%252C29%26mn%3Dsn-35cxanpbo5a-8pxl%252Csn-2gb7sn7r%26ei%3Du4IIW7DfC46rgAfrrpnICw%26ms%3Dau%252Crdu%26mt%3D1527284230%26pl%3D16%26mv%3Dm"
Just decode URL and you got what you want.

Youtube Video In HTML5 <video>

I have made a windows store app using the Youtube Iframe API. I can handle events and play video fine but there is a major problem as it doesnt support full screen mode (amongst some other minor niggles).
I have been looking in the app store and I see that the majority of youtube player apps do not use the iframe API, they grab the video direct and put it into the standard HTML5 video player.
I have done a lot of searching and the only way I can see people are doing this is by parsing the youtube page to find the video file the Youtube player is going to play and loading this directly into the media player.
I have a few problems with this method.
I am not sure if this is legal as it may break youtubes terms and conditions
If page at youtube changes it can break app.
Neither of these situations are acceptable.
Is there any way to get full screen to work inside app or get a direct video stream legitimately?
Not sure about the copyright and youtube terms stuff but here is how you do it apparently:
Show Youtube video source into HTML5 video tag?
Looks like it's browser specific and youtube generates different html for different browsers.
I would make an ajax request to the youtube url appending html5-true then use jQuery to scrape the source for the video tag, add your attributes and then append to your page.
Now you have the tag that youtube uses so I'm assuming what works on their webpage will work o yours.
Probably violates all terms and conditions...

Playing Uploaded Videos or embed youtube videos

I'm creating a Content Management System that allows the content manager to upload videos to the server. There will be a list of pages and each one will have a video on it. Each video should then be able to be played by the content observer.
Problem: I can get some videos to play, but I cannot get all of them to play and I don't know why. How do I force the content manager to upload only videos that work or convert videos that do not work? I've used embed, object, iframes, and videos tags, but I can't to get any of them to work all the time. This link is what I have tried. http://ww.w3schools.com/html/html_videos.asp
Alternative Solution: Just make the content manager upload videos to youtube, then put the embed code in the database and call for it when you need it. This works but the code does not validate when you do this which is bad for SEO. Also, if the content manager does not do it correctly he could be advertising for the competition because the video can show links to other videos when it is done.
It is hard. In our CMS you need verify the content, probably in a async procedure, and reject the video if there is something wrong. The most important is choose a good set of formats and codecs (and other characteristics like Frames Per Second, Audio Bitrate, etc) and make this "contract" something very explicit. ffmpeg with -i option can identify the video, extension, codec, length, aspect-ratio, etc.
You also try to convert from any format to one good format like mp4 h264 with 360p.

should embedding video in home page slow down the page?

If I embed a video demonstrating my application in my home page, will it slow down the page to a considerable amount?
I tried, and checked that it takes almost 1 sec, to load the preview of the video.
And as the video stream will not be downloaded until, the video is clicked, the total video do not have to get downloaded.
Is it recommended to embed a video in the home page? Or should I just keep it in a different page and put a link in the home page.
If you are embedding a flash flv video then yes, it could slow the page load down. This is because the page will need to load the flash plugin in order to get the content size, etc and render the initial frame etc.
Doesn't mean it's a bad thing though. It won't be an extreme slowdown (flash is pretty highly optimised nowadays), so instead evaluate on how it looks rather than performance unless you are trying to eke out every dreg of performance on your page load :)
Here one way you can have your cake and eat it too:
Don't put the flash player on the page that you will load by default....
Put in an image that looks like the player instead (it should be much lighter) .
If / when your user clicks on the player image, load in the flash player and play.
Every object you add to a page can slow down the page's loading time. In general don't include anything if the load time isn't worth the added benefit of having that item.
That being said, you can optimize the page by doing some tricks so that the page renders and THEN the flash video loads. You could pre-generate a thumbnail of the flash player/video and put it on the page in the same place as the video, then on page load use javascript (jquery: $(document).ready()) to create the flash object. This may improve the perceived performance. Even better, you could defer loading the video until the user clicks a button or something.
Everything you embed will slow down the page's initial load.
You have several options: (A) embed the video in its native format (mpeg, avi, etc) or (B) convert it into Flash. A good thing about flash is that it's near universal and highly optimized, so loading the flash plugin takes little time.
The whole video needn't load for the page to finish loading (only the player), so if we're just talking about 1 video, it would make sense to embed it in the page so as to provide a better user experience.
Have a look at both of Mr. Shiny and New's points. They're valid as well.