YouTube API: Get the quality of a video via the API? - youtube

Is there any way to tell when a video has been fully encoded at its highest definition via the API?
As far as I can tell, the YouTube API provides the 'state' of a video (processing, restricted, deleted, rejected and failed). However, I can't tell if the API also provides the encoding qualities of the video (240p, 360p, 720i, etc...).
Does anyone know how to get this information?

Taken directly from the docs:
player.getPlaybackQuality():String
This function retrieves the actual video quality of the current video. It returns undefined if there is no current video. Possible return values are highres, hd1080, hd720, large, medium and small.

Related

Are all the youtube videos encoded to pal or ntsc?

I'm handling time format conversion operations and i need to turn Secs into Timecode format: Hours:Minutes:Seconds:Frames.
To calculate the frames I need to know the video standard (PAL or NTSC), hence my question:
Are all the youtube videos encoded to pal or ntsc? or they keep the original uploaded video standard? And, if they keep the original standard, how can I retrieve this data?
There is no mention of that whether it's PAL or NTSC in the docs.
However, I found this google forum that says
YouTube will accept both NTSC and PAL format, and on the internet, it
makes no difference at all. Use whichever format your original
material is in.
Youtube video metadata are returned after successful method calls to the Youtube API.

Pulling percentage video viewed youtube api

I'm going to create the automate API for youtube report. Is there a way to pull the number of users of each percentage (25%,50%) or second of video viewed via youtube analytics API? I use python language from link as shown below:
https://developers.google.com/youtube/analytics/v1/data_model
I found a metric name "audienceWatchRatio", but I'm not sure that's what I want or not? I tried to run the script including this metric with and without "elapsedVideoTimeRatio" dimension, and it always shows "The query is not supported."
Well, I found here in the Analytics and Reporting APIs on how to get the percentage viewed in the video. By using the averageViewPercentage you will get the average percentage of a video watched during a video playback. The only problem here is this parameter get the total percentage of the channel, not the specific or individual video.
Check this link if you want to check on how to use this parameter.
I also found a related question about your issue, but this question uses Javascript. So just check if it can help and give idea to you.
Calculate percentage of youtube video viewed with API

PHP get screenshot from YouTube video

I have a website that has a variety of embedded YouTube videos. When a user pauses a given video I want a screenshot to be taken of the playing video. Now, I've taken many approaches in tackling this problem such as copying the video frame to canvas (this doesn't work because the videos are external to my site), and also through the use of FFMpeg, and FFMpeg-PHP. The latter two- although very powerful- also do not work as the given piece of media has to be hosted on my server.
I'm at my wits end about what to do as I've spent countless hours trying to do this, and I'm ready to accept defeat.
Any ideas?
Regards,
Andre.
There's no supported method in the YouTube Player or Data API to take a screenshot of an arbitrary frame of a video.
I used the img.youtube.com/vi path to get the image. The function getScreen basically parses the youtube url and grabs the &v= argument to get the video id.
Since I use youtube.com/embed/ url format, then I had to rework the function a little to get the video id.
http://mistonline.in/wp/get-youtube-video-screenshot-using-simple-php-and-javascript/#

Youtube get camera type

Consider these videos:
http://www.youtube.com/watch?v=U_kZ5Lj-59E
http://www.youtube.com/watch?v=f0pdwd0miqs
The first is probably filmed with a mobile phone's camera, the second with a professional one. I would like to determine this difference.
Q: Is anybody aware of a way of retrieving information about the camera type that was used for a video on Youtube?
Q: Or, is there a more generic way for videos to determine video recording quality?
There is no way to get the camera metadata from a video on YouTube at this point. Theoretically YouTube could capture this information for some videos (and make it available in the future), but not every video file has camera metadata on it. In fact, a lot of videos use more than one camera.
Technically there are other methods of determining "recording quality", but they won't be perfect. For example, you could use the assumption that if a video is available in 1080p it might be better quality than one only available in 480p. However, there can still be a big difference in two videos both available in 1080p.
You can't rely on bitrate either, because YouTube could change the bitrate on you depending on your internet speed.
You can determine a video is available in HD, for example if you execute this query (API V3): https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?id=L8oEtD_CEs0&part=contentDetails&_h=1&, you'll notice I've recorded it in HD ("definition": "hd"), though I did use my shaky hand and phone camera :)
For API V2 we have element described here: http://apiblog.youtube.com/2011/10/more-ways-to-find-what-youre-looking.html.

Detecting Available Qualities of YouTube Videos

I'm writing a Boxee app that makes use of YouTube videos and I want to be able to display the highest quality version available. I was looking through the YouTube API, but I can't seem to find a way to detect if 720p and/or 1080p versions of the video are available.
Does anyone know how to do this? I'm already using their Data API to collection information about the video, but there doesn't seem to be anything in the payload about different qualities consumable on the web: http://gdata.youtube.com/feeds/api/videos/NWHfY_lvKIQ
I could just hard code fmt=22 and let it default to a lesser quality version, but then I miss out on 1080p (fmt=387).
The information isn't available through the API, but can be queried and changed via JavaScript after the page has loaded (if you embed a video for example).
http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/da4344cc66959ecc

Resources