First of all a big thank you for writing and maintaining this module!
While playing around with YouTube videos, I noticed that the markup generated by video_filter resulted in unexpected sizes of videos, this again resulted in black bars on the sides (left, right and more often top,bottom) of the videos.
The problem is that video_filter calculates with an aspect ratio of 425 / 355 for YouTube videos and uses this ratio to calculate the size of the object element. This is wrong in two ways:
When resizing a video one has to take into account that the control bar of the embedded video has a fix size and cant be scaled. The control bar is that thing were you typically find the play button, among others. So, when resizing a video one has two know at least two things: the aspect ratio of the video, typically 4/3 or 16/9, and the size of the control bar.
YouTube changed the aspect ratio of their videos in 2008. It is now 16/9 with the control bar having fix height of 25px. The 425 / 355 in the video_filter algorithm stems from the old size where you would typically have a width of 425px and a height of 320px, with the control bar having a height of 25px. Notice that 425 / 330 is equal to 4/3 (almost) and 330 + 25 is equal to 355.
When you have a look at YouTube you will see that the offer embed code for the following sizes: 480x295, 560x340, 640x385, 853x505. If you subtract from the height part, you will always get ratios equal to 16/9.
Then again I noticed something else I found hard to understand, the option "DEFAULT PRIORITY SETTING". Usually when you specify a width and height the videos should have, you mean that the videos should be sized in a manner that they fit in a bounding box. You don't care how much the video needs to be scaled up or down, you just want it to fit in box with a maximum width and height and the aspect ratio to be preserved. When scaling a video in this manner, you don't need that setting.
Please find attached a patch that addresses these three issues. I hope you agree with my explanation.
Greetings from Switzerland!
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | video_filter-644130.patch | 8.96 KB | Pisco |
| video_filter.patch | 7.96 KB | Pisco |
Comments
Comment #1
Pisco commentedI just noticed that flickr videos are available in different aspect ratios. Maybe it would make sense to provide an option like this
to customize it. As far as I see, there is no simple way to find out the aspect ratio of a linked video.
Comment #2
blackdog commentedFirst, thanks for your work!
I see your points, and I like the ideas. I see though that you have more code in this patch than the issue is about, please make that (new codec) a separate issue.
I also see that not all codecs have a new ratio, why is that? Also, how will this change behave on sites that are using the module now, with different settings for width, height etc?
Comment #3
blackdog commentedComment #4
Pisco commentedHello blackdog
I attached a new patch containing support for overriding the default aspect ratio and the height of the control bar, the later is not too important I guess.
I also removed the new codec as this is a non issue, I was just playing around.
As for your questions:
I think the option to override the ratio and the height of the toolbar is really convenient and could be useful in many edge cases.
Comment #5
Pisco commentedComment #6
blackdog commentedI've committed this with a few code style fixes. I didn't see any issues popup in my testing environment, so I'll let it live in CVS for a while to see if any issues come up. Great work Pisco!
Comment #7
Pisco commentedCool! Thank you!
Comment #9
escoles commentedVerified that dev version scales YouTube videos to 16:9.
Comment #10
OliverColeman commentedThanks for awesome patch. Worked perfectly for me scaling a 4/3 aspect ratio video from vimeo (default for vimeo is 16:9).