Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for H264 High 10 Profile on Safari #5901

Merged
merged 6 commits into from
Sep 8, 2024

Conversation

gnattu
Copy link
Member

@gnattu gnattu commented Aug 10, 2024

Both macOS and iOS Safari have enabled H.264 Hi10P decoding support with some restrictions. For our use case, we need to force all H.264 Hi10P video files to trigger remuxing, as this profile is only supported in fMP4 within HLS. Attempts to direct play the original video will fail.

To support this functionality, the server API needs to be modified to accept HLS-specific codec profiles.

This also added a user-configurable option to let the user to opt-in this feature, as the precise feature detection is impossible.

Changes

Issues

Depends on Server change jellyfin/jellyfin#12420

@gnattu gnattu requested a review from a team as a code owner August 10, 2024 09:39
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint doesn't pass. Please fix all ESLint issues.

src/scripts/browserDeviceProfile.js Outdated Show resolved Hide resolved
src/scripts/browserDeviceProfile.js Outdated Show resolved Hide resolved
src/scripts/browserDeviceProfile.js Outdated Show resolved Hide resolved
src/scripts/browserDeviceProfile.js Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@nyanmisaka
Copy link
Member

Apple hardware has always been able to handle High10P, and on older systems you can just use a fake mimetype to trick Safari into playing it in fMP4 as well.

Is there a changelog that mentions this?

@gnattu
Copy link
Member Author

gnattu commented Aug 10, 2024

Apple hardware has always been able to handle High10P, and on older systems you can just use a fake mimetype to trick Safari into playing it in fMP4 as well.

The hi10p hardware decoding support should be present back to at least iOS 12 era so we can assume this will work for all modern iOS devices. What I'm not confident with is the macOS support status. There are still Intel Macs that never has hi10p hardware (probably the model with T2 chip could use the decoder in that chip but I'm not sure), and Apple's release note documented that hardware Hi10P was enabled for videotoolbox on macOS >= 14.6 which makes me not quite confident because I don't know if I would:

  • break Intel Macs
  • break Apple Silicon Macs on old OS

@nyanmisaka
Copy link
Member

Apple hardware has always been able to handle High10P, and on older systems you can just use a fake mimetype to trick Safari into playing it in fMP4 as well.

The hi10p hardware decoding support should be present back to at least iOS 12 era so we can assume this will work for all modern iOS devices. What I'm not confident with is the macOS support status. There are still Intel Macs that never has hi10p hardware (probably the model with T2 chip could use the decoder in that chip but I'm not sure), and Apple's release note documented that hardware Hi10P was enabled for videotoolbox on macOS >= 14.6 which makes me not quite confident because I don't know if I would:

  • break Intel Macs
  • break Apple Silicon Macs on old OS

I'm not encouraging this on older systems xD, especially when they have no software fallbacks.

@gnattu
Copy link
Member Author

gnattu commented Aug 10, 2024

Just tested with macOS 12 + Safari 15 on Apple M1, the player does not fail but the video is just all black. I think the Safari version check is necessary here. Not sure about Intel Macs as I don't have one right now.

@nyanmisaka
Copy link
Member

Just tested with macOS 12 + Safari 15 on Apple M1, the player does not fail but the video is just all black. I think the Safari version check is necessary here. Not sure about Intel Macs as I don't have one right now.

Good to know. Is HEVC Rext (4:4:4 & 4:2:2) content possible in Safari?

@gnattu
Copy link
Member Author

gnattu commented Aug 10, 2024

Is HEVC Rext (4:4:4 & 4:2:2) content possible in Safari?

Yes. Although we have not added support check for that yet. But such videos are still rare.

After playing with it a little bit more I think we probably need to add a switch to the playback options because:

  • There is no easy way to check macOS version. Unlike iOS where we can assume Safari version == iOS version, macOS Safari can be updated as a separate component which means old macOS can still have latest Safari. The macOS version in UA is capped at 10.15.7 because too many websites think macOS major version cannot be larger than 10
  • There is no easy way to check if current Mac is an Intel Mac. UA and navigator will always report Intel because the web assumes non-Intel Macs are old ppc Macs.
  • There is no easy way to check if the platform can really play Hi10P. The capability tests are always passing, but the video could still display all black frames.

@nyanmisaka
Copy link
Member

After playing with it a little bit more I think we probably need to add a switch to the playback options because:

  • There is no easy way to check macOS version. Unlike iOS where we can assume Safari version == iOS version, macOS Safari can be updated as a separate component which means old macOS can still have latest Safari. The macOS version in UA is capped at 10.15.7 because too many websites think macOS major version cannot be larger than 10
  • There is no easy way to check if current Mac is an Intel Mac. UA and navigator will always report Intel because the web assumes non-Intel Macs are old ppc Macs.
  • There is no easy way to check if the platform can really play Hi10P. The capability tests are always passing, but the video could still display all black frames.

So let users opt in on Apple devices to avoid such hassle.

@gnattu
Copy link
Member Author

gnattu commented Aug 10, 2024

So let users opt in on Apple devices to avoid such hassle.

Added a playback setting defaulted to false. This option will only show if the browser is Safari and the user will need to explicitly enable it.

@dmitrylyzo dmitrylyzo added backend Requires work on the server to finish playback This PR or issue mainly concerns playback labels Aug 10, 2024
Copy link

@gnattu
Copy link
Member Author

gnattu commented Aug 25, 2024

Updated to place the hi10p profile before the regular ones to accommodate the changes made in jellyfin/jellyfin#12499

@jellyfin-bot
Copy link
Collaborator

Cloudflare Pages deployment

Latest commit 03eb42a8cfc833b7a0df135c835eab19f0f7a1f3
Status ✅ Deployed!
Preview URL https://f6c69422.jellyfin-web.pages.dev
Type 🔀 Preview

@thornbill thornbill added feature New feature or request release-highlight A major new feature for the next release and removed backend Requires work on the server to finish labels Sep 8, 2024
@thornbill thornbill merged commit c80e0fd into jellyfin:master Sep 8, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request playback This PR or issue mainly concerns playback release-highlight A major new feature for the next release
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants