Bigger video size (width/height) for YouTube Embeds - youtube

Is there a way to show a YouTube video with a custom width/height?

From this link on YouTube's site:
You can resize the player by editing the object width="425" and height="350" fields at both the beginning and end of the embedded player code. Make sure that the sizes you choose have the same ratio as the default numbers, so that the video doesn't get stretched—just multiply the width by 0.8235 to get the height.
In short, just edit the parameters used for the dimensions in the embed code, making sure you preserve the original aspect ratio.
Hope that helps!

Related

Export portrait video to square but with scaleAspectFit ratio

In my app I allow users to record videos in portrait mode. I use that within the app and that is fine. However, I'm implementing a feature to share the videos on Instagram, where videos must be square.
Cropping the video to square, lets say the center part, is an option, however as the user doesn't consider this when taking the video, it usually turns out bad.
Therefore, I'd like to export the video square, but with an aspect fit ratio and with two bars left and right. Optimally, is there any way to define the colors of the background (either by code or by UIImage).
The closest thing I was able to find is this, however I can't make much use of it as I'm unclear on how to set up the transformation.
Example (red box just to mark the image bounds):
Beside trying to add black bars and re-render the video you can use the cameraOverlayView property of UIImagePickerController.
So you can create a view that has 2 black bars in OR you can create a view that has a square frame over the camera view so they know to frame it in there because it will share to instagram.

YTPlayerView thumbnail custom size

I am using YTPlayerView library from Google. I want to get the customised size thumbnail of a youtube video for my iOS app.
Can anybody help me how I can achieve this? Current it is giving me the same size thumbnail for a video regardless of the size of my YTPlayerView.
YTPlayerView.load automatically loads its own thumbnail. However, a workaround could be you place a UIImageView on top of the YTPlayerview. And load the customized thumbnail into that UIImageview. You can start playing the video when the UIImageview is clicked using YTplayerview.play. And then hide the thumbnail. In essence, it would give the effect the video is being played upon clicking your customised thumbnail image. You may have to fine-tune some things to make this solution work elegantly.
To retrieve the image for the customised thumbnail, you can use any of 4 generated images of youtube. They are predictably formatted as follows:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
https://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
I hope this helps to answer your question.

embedding youtube videos - aspect ratio

I'm looking to embed some youtube videos in my web page and from looking at the videos on youtube they all seem to be displayed with an aspect ration of 16:9 or 640px:340px.
Trouble is I only have 600px max space to put them in, would I just work out the appropriate height i.e. 640/16*9 = 333px and display them in that and would that take care of everything ,or is there any other size allocated for the progress bar at bottom.
E.g. if you look at this video you can see the progress bar throughout.
http://www.youtube.com/user/southerncomfort?v=ygeWsoYYMuQ
Thanks,
You can use any youtube embed code generator to achieve your goal with ease.
Go to Advanced Youtube Embed Code Generator.
Enter the video ID and input either height or width in the
respective column and hit generate button(the empty field will be
automatically calculated with 16:9 ratio)
Copy the code and use it.
You can choose either 16:9 or 4:3, the later being 480px X 385px (+25px to height for controls).
OR, if you want 16:9, you can choose the size to be 560x315.
Check out the style guide: https://web.archive.org/web/20130415231312/http://support.google.com/youtube/bin/answer.py?hl=en&answer=178264
For anyone still on this,
https://www.w3schools.com/howto/howto_css_aspect_ratio.asp.
Ensure to use ALL CSS PROPERTIES AND STYLING enlisted else it won't render correctly on responsive sites and apps.

How to crop a video in iOS

I was having a look at the RosyWriter Sample Code provided by Apple as a starting point and I'd like to find a way how to crop a video.
So i have the full resolution video from the iPhones Camera, but I just want to use a cropped part of it (and also rotate this subpart).
I figured that in captureOutput:didOutputSampleBuffer: fromConnection: i can modify each frame by modifying the CMSampleBufferRef that i get passed in.
So my questions now are:
Is this the right place to crop my video?
Where do I specify that the final video (that get's saved to disc) has a smaller resolution than the full video captured by AVCaptureSession? Setting the AVVideoWidthKey and AVVideoHeightKey has no effect.
How can I crop the video and still have good performance?
Any help is appreciated!
Thanks a lot!
EDIT:
Maybe I just need to know how I can make a video that was shot in portrait a landscape one by turning the images of the video by 90 degrees and then zoom in to fit the width again...?!?
In AVVideoSetttings.h there is the AVVideoScalingModeKey. This key combined with the defined values control how the video is scaled/cropped when encoding the images to the video container. For example if you specified a value of AVVideoScalingModeFit then cropping is used. Check out the header for how other values effect the video images.

YouTube thumbnail link doesn't work in all cases

An application I'm working on needs to get HQ YouTube thumbnails given a URL. Using this answer, I tried using the maxresdefault.jpg to get the maximum resolution of the thumbnail but on some videos (seemingly random), the request 404's.
Here are some examples:
http://img.youtube.com/vi/zIez5QVE3NI/maxresdefault.jpg works
http://img.youtube.com/vi/DaAfe5xTm8w/maxresdefault.jpg doesn't work
Using the same URL's, other requests using the same video keys do work:
http://img.youtube.com/vi/zIez5QVE3NI/default.jpg works
http://img.youtube.com/vi/DaAfe5xTm8w/default.jpg works
Why doesn't maxresdefault.jpg reliably return the image? Both of those videos are public and can be embedded.
I'd use 0.jpg but it has black bars on the top and bottom of the image.
As I understand it, YouTube only generates high-res stills for high-res videos. The first one you link was uploaded at a resolution of at least 1080p, while the second was less than 720p.
Looks like the only thing you can do is pull the video feed, check that to see if a high-res still has been generated and up-scale the smaller one yourself if not.
All¹ YouTube stills are presented in the 4:3 aspect ratio, so will always have black bars at the top and bottom if the video is 16:9. In HTML/CSS, this is easily combated by setting the image as the background of a div and sizing the div to the correct aspect.
¹ Except the mqdefault.jpg stills, which are all in 16:9 aspect (320x180)
Update 2015 :
None of your 'maxresdefault' link seems to be working
Try these:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
Update 2019 ::
https://i.ytimg.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
Seems to return highest possible image....
1.jpg, 2.jpg, 3.jpg return previews through the length of the clip which are handy also ;)

Resources