Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing black borders 4:3 on youtube thumbnails

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?

like image 531
Derfder Avatar asked Nov 04 '12 16:11

Derfder


People also ask

How do I get rid of the black lines on my YouTube thumbnail?

Crop out the video YouTube's way of fixing the black bar problem is surprisingly simple. Just drop in additional tags in the tags section while you edit the metadata of your video. If you have a 4:3 video letterboxed within the YouTube video player, you have an easy option to crop your video.

Why does my YouTube thumbnail have black border?

Black bars are added to videos when there is a difference between the aspect ratio of the videos and the playback device, for example, watching a film shot in 16:9 on a 4:3 television. The same is true on the web.


3 Answers

YouTube offers images that don't have the 4:3 ratio black strips. To get a 16:9 video thumbnail with no black strips, try one of these:

http://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg

The first one mqdefault comes as a 320x180 pixel image.

The second one maxresdefault comes as a 1500x900 pixel image, so it would need resizing to use as a thumbnail. This is a nice image but it isn't always available. If the video is of a low quality (less than 720p I'd imagine, not exactly sure) then this 'maxresdefault' becomes unavailable. So never rely on it.

like image 123
TheCarver Avatar answered Oct 21 '22 14:10

TheCarver


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;
}
like image 43
Rich Bradshaw Avatar answered Oct 21 '22 15:10

Rich Bradshaw


If you want it with a flexible width, use this:

HTML

<div class="thumb">
    <img src="...">
</div>

CSS

.thumb {
    overflow: hidden;
}
.thumb img {
    margin: -10% 0;
    width: 100%;
}
like image 20
Sergi Ramón Avatar answered Oct 21 '22 15:10

Sergi Ramón