video.js icon indicating copy to clipboard operation
video.js copied to clipboard

Incorrect zoom for VideoJS on Chrome seems to be an issue with object-fit

Open swaraasolutions opened this issue 8 years ago • 30 comments

Description

The player has been generated using videojs-contrib-hls plugin however when viewing on chrome the player seems to be zoomed and the portion on right is not visible. But with the same code it is visible with IE Edge, Firefox and Safari correctly

Sources

Not Sure

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Create a basic videojs player and check the view in chrome, firefox and Safari. Chrome will display it differently. chrome firefox ie

Results

Expected

It should show the full video instead of zoomed version firefox

Error output

No Errors available

Additional Information

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with? "videojs-contrib-hls": "^5.14.1",

videojs version

what version of videojs does this occur with? "video.js": "7.2.0",

Browsers

what browsers are affected? please include browser and version for each Chrome

Platforms

what platforms are affected? please include operating system and version or device and version for each Desktop + Mobile Windows 10

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below. "videojs-contrib-ads": "^6.4.3", "videojs-ima": "^1.5.1"

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below. jQuery

swaraasolutions avatar Aug 09 '18 17:08 swaraasolutions

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

welcome[bot] avatar Aug 09 '18 17:08 welcome[bot]

Can you please create and share a reduced test case using this template? I am not seeing the same behavior with v7.2.0 out of the box. Providing a test page that you have verified reproduces the problem will help us better assist you.

alex-barstow avatar Aug 09 '18 18:08 alex-barstow

Hi Alex,

Thanks for your quick response

Following are the versions that I have created

V6 = http://jsbin.com/lirogavoni/edit?html,output

V7 = http://jsbin.com/qihojaluho/edit?html,output

If you are unable to play the video please visit the below link as it manages session cookies for authentication

https://bit.ly/2vUIdjJ

The first in the list is the video that I am trying to play in VideoJS.

Let me know if you need any further details from my end.

Thanks

Varun V.

From: Alex Barstow [email protected] Sent: 10 August 2018 00:07 To: videojs/video.js [email protected] Cc: swaraasolutions [email protected]; Author [email protected] Subject: Re: [videojs/video.js] Incorrect zoom for VideoJS on Chrome seems to be an issue with object-fit (#5366)

Can you please create and share a reduced test case using this template http://jsbin.com/axedog/edit?html,output ? I am not seeing the same behavior with v7.2.0 out of the box. Providing a test page that you have verified reproduces the problem will help us better assist you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/videojs/video.js/issues/5366#issuecomment-411855260 , or mute the thread https://github.com/notifications/unsubscribe-auth/ALjg8KkXLFi8s-1oKQ_4vSUmugMF1YMjks5uPIFXgaJpZM4V2JbC . https://github.com/notifications/beacon/ALjg8B47iWubME4B292xZyCkG4D56SdJks5uPIFXgaJpZM4V2JbC.gif

swaraasolutions avatar Aug 09 '18 19:08 swaraasolutions

Thank you. I was able to reproduce the issue. At first glance, it looks like the player's padding-top is being set differently in Chrome than other browsers when the fluid option is true. I'll look into it.

alex-barstow avatar Aug 09 '18 21:08 alex-barstow

Thanks Alex

Much appreciated. Any time frame when we can expect a resolution or maybe a patch that we can apply.

Thanks

Varun V>

From: Alex Barstow [email protected] Sent: 10 August 2018 03:03 To: videojs/video.js [email protected] Cc: swaraasolutions [email protected]; Author [email protected] Subject: Re: [videojs/video.js] Incorrect zoom for VideoJS on Chrome seems to be an issue with object-fit (#5366)

Thank you. I was able to reproduce the issue. At first glance, it looks like the player's padding-top is being set differently in Chrome than other browsers when the fluid option is true. I'll look into it

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/videojs/video.js/issues/5366#issuecomment-411904565 , or mute the thread https://github.com/notifications/unsubscribe-auth/ALjg8Cli-JTBchIBlHVDCX69v_vySmzCks5uPKqggaJpZM4V2JbC . https://github.com/notifications/beacon/ALjg8I1rr9lP_O40eYvnsMOLPlB6oezIks5uPKqggaJpZM4V2JbC.gif

swaraasolutions avatar Aug 10 '18 08:08 swaraasolutions

I don't expect it will take long to find the root cause of this, but I don't have an exact time frame. As a short (or long) term fix you can add the vjs-16-9 class to the player which will force the 16x9 aspect ratio across every browser. I've confirmed that this works on my end.

alex-barstow avatar Aug 10 '18 14:08 alex-barstow

Hi Alex,

Thanks for the response.

Is there any possibility I can add vjs-4-3 and will it be able to resolve the issue?

Thanks

Varun V.

From: Alex Barstow [email protected] Sent: 10 August 2018 20:20 To: videojs/video.js [email protected] Cc: swaraasolutions [email protected]; Author [email protected] Subject: Re: [videojs/video.js] Incorrect zoom for VideoJS on Chrome seems to be an issue with object-fit (#5366)

I don't expect it will take long to find the root cause of this, but I don't have an exact time frame. As a short (or long) term fix you can add the vjs-16-9 class to the player which will force the 16x9 aspect ratio across every browser. I've confirmed that this works on my end.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/videojs/video.js/issues/5366#issuecomment-412105207 , or mute the thread https://github.com/notifications/unsubscribe-auth/ALjg8CkSM-fzOl_zlSvA4WDr0GpsFjtYks5uPZ1-gaJpZM4V2JbC . https://github.com/notifications/beacon/ALjg8B8bITDDh0BRbWpWMROHT3SKrLs0ks5uPZ1-gaJpZM4V2JbC.gif

swaraasolutions avatar Aug 10 '18 14:08 swaraasolutions

Yes, both vjs-4-3 and vjs-16-9 should ensure a consistent aspect ratio is used across browsers.

alex-barstow avatar Aug 10 '18 14:08 alex-barstow

You can also pass in aspectRatio option with a value like '16:9' to get any aspect ratio. vjs-4-3 and vjs-16-9 are just so common that we provide the classes for them by default.

gkatsev avatar Aug 10 '18 15:08 gkatsev

@alex-barstow I tried the solutions that you provided however when i try it on the vjs-7 jsbin that i shared it doesn't reflect the changes

http://jsbin.com/renogawodi/edit?html,output @gkatsev i tried using your solutions too but that too didn't workout on the vjs7.

Your help is much appreciated.

Thanks Varun

swaraasolutions avatar Aug 10 '18 16:08 swaraasolutions

Interesting, it works for me on that page. The aspect ratio changes accordingly when adding/removing vjs-4-3 and vjs-16-9, and when setting the aspectRatio option.

alex-barstow avatar Aug 10 '18 17:08 alex-barstow

I have only tested with Chrome and Safari so I can only speak to the disparity there, but it looks like the root cause in that case is that the aspect ratio is falling back to the default 16:9 in Safari (instead of the correct 4:3) because the video's width and height are still 0 at the time the loadedmetadata event occurs (which is when the player attempts to calculate the video's dimensions). The player uses native HLS in Safari and MSE in Chrome, so that likely explains the different behavior. @gkatsev Do you know if HLS content's width and height are supposed to be available on 'loadedmetadata' in Safari?

alex-barstow avatar Aug 10 '18 19:08 alex-barstow

Yeah, they should but I guess as always the answer is "it depends". It should have it but it's possible that there's a bug or something that's preventing it from working properly.

gkatsev avatar Aug 10 '18 19:08 gkatsev

Ah OK, after looking at the spec, it is pretty explicit about the media's dimensions being available on 'loadedmetadata'. I've tested various HLS content in Safari, and in all cases the dimensions are 0 on loadedmetadata, so this does appear to be a Safari bug.

alex-barstow avatar Aug 10 '18 20:08 alex-barstow

@alex-barstow Is this all with Video.js have you tried a plain video element?

gkatsev avatar Aug 10 '18 20:08 gkatsev

Sorry, should have been more specific. I was testing in Safari with just the video element.

alex-barstow avatar Aug 10 '18 20:08 alex-barstow

Interesting, do you get the info later on like on a playing event?

gkatsev avatar Aug 10 '18 20:08 gkatsev

Yes, the dimensions are available on 'loadeddata'

alex-barstow avatar Aug 10 '18 20:08 alex-barstow

We could make the case that if there's no dimensions in loadedmetadata we can wait till loadeddata, but we probably should also open an issue against safari for this as well.

Also, is this with m3u8 or also mp4?

gkatsev avatar Aug 10 '18 20:08 gkatsev

It's only an issue with HLS. I'll look into the feasibility of that workaround.

alex-barstow avatar Aug 10 '18 21:08 alex-barstow