Asked  7 Months ago    Answers:  5   Viewed   27 times

E.g. I have a link

http://img.youtube.com/vi/aOPGepdbfpo/0.jpg

for a youtube video thumbnail:

enter image description here

And I would like to remove the black top and bottom border so I get a picture like this:

enter image description here

Could it be done using PHP function javascript/jQuery or maybe youtube api itself?

 Answers

98

Use it as a background image, center it and change height.

http://dabblet.com/gist/4012604

.youtubePreview {
    background:url('http://img.youtube.com/vi/aOPGepdbfpo/0.jpg') center no-repeat;
    height:204px;
    width:480px;
}
Wednesday, March 31, 2021
 
letrollpoilu
answered 7 Months ago
68

If you want to go by the color, the wideimage library (GD based) has this implemented already. The method is called autoCrop, an online demonstration exists.

This might already fulfil your needs.

Saturday, May 29, 2021
 
BlueNile
answered 5 Months ago
90

The method YouTube uses for it's provided search results on the home page includes Related Videos which is based on a proprietary algorithm.

Unfortunately, this proprietary method is not yet available in their API (v1 or current v2) which is why you don't have the same results provided.

The YouTube API Page shows how to use the Related Videos API feature, but only for a single video since it's limited to that use.

I've seen various questions/replies that come and go on the forum about this issue, like this ignored one.


Consider using the Related Videos based on a single video, which the API does support.

Example of that usage for YouTube Video Gedz - Gucci Gucci gość. Joda is:

https://gdata.youtube.com/feeds/api/videos/oepPdNKzxk0/related?v=2

You will see 25 results (default quantity when not specified in query) that are similar but not exact as the single video's YouTube page. Different algorithm's are at play here too, but this method is the best that's currently available.


My untested solution for your project goal is as follows:
1. Use current method to acquire video ID feeds.
2. If the results are less than the amount required, use the returned results first Video ID as a reference.
3. The Video ID reference (just a single video) is then used to perform another query for Related Videos. 4. You can then combine both query's to create a final list of Video ID's which to use.

Tuesday, August 10, 2021
 
hakre
answered 3 Months ago
73

There's now support for resumable uploads using CORS in the YouTube Data API v3.

A rough, but working, example at https://youtube-api-samples.googlecode.com/git/yt-upload-javascript/index.html (source files at https://code.google.com/p/youtube-api-samples/source/browse/#git%2Fyt-upload-javascript) that shows the upload flow, using the Google+ sign-in button to handle OAuth 2 (you can use the normal OAuth 2 browser client flow if you'd prefer) and with a progress indicator. It also shows how you could poll for video processing status following an upload and embed the resulting video on a page once it's been processed.

Saturday, August 21, 2021
 
Shawn Allen
answered 2 Months ago
90

Here $videoId contain video id of yuotube url

public function checkVideoExists() {
        $headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $videoId);
        if (!strpos($headers[0], '200')) {
            echo "The YouTube video you entered does not exist";
            return false;
        }
    }
Tuesday, October 5, 2021
 
Pawan Pillai
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :