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!

CommentFileSizeAuthor
#4 video_filter-644130.patch8.96 KBPisco
video_filter.patch7.96 KBPisco

Comments

Pisco’s picture

I just noticed that flickr videos are available in different aspect ratios. Maybe it would make sense to provide an option like this

[...  ratio:16/9 ...]

to customize it. As far as I see, there is no simple way to find out the aspect ratio of a linked video.

blackdog’s picture

First, 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?

blackdog’s picture

Status: Needs review » Needs work
Pisco’s picture

StatusFileSize
new8.96 KB

Hello 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.

[ ...  ratio:16/9 ... control_bar_height:20 ... ]

I also removed the new codec as this is a non issue, I was just playing around.

As for your questions:

I also see that not all codecs have a new ratio, why is that?
Either I didn't find better numbers, or I thought the ratio you already had, were a good choice. For Google videos I really couldn't find out which aspect ratio they use, or if they use different aspect ratios
Also, how will this change behave on sites that are using the module now, with different settings for width, height etc?
Especially for YouTube videos you will see a lot less of those black bars and they will be rendered in 16/9 aspect ratio, which is the default for YouTube. The resizing will behave a bit different using the bounding box scale, but I guess this is more like what people would expect. Last but not least aspect ratios are preserved even it a video is scaled up or down a lot.

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.

Pisco’s picture

Status: Needs work » Needs review
blackdog’s picture

Status: Needs review » Fixed

I'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!

Pisco’s picture

Cool! Thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

escoles’s picture

Verified that dev version scales YouTube videos to 16:9.

OliverColeman’s picture

Thanks for awesome patch. Worked perfectly for me scaling a 4/3 aspect ratio video from vimeo (default for vimeo is 16:9).