mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Better codec profile for Safari with 10.10 features
This uses the new VP9 remuxing and audio remuxing features to reduce transcoding on Safari, also removed some problematic direct play profiles. - Add opus profile for Safari - Add VP9 remuxing profile for Safari - Remove Vorbis profile on non-webm container for Safari - Remove direct VP9 playback in mp4 container for iOS Safari
This commit is contained in:
parent
d770e40130
commit
a386512def
3 changed files with 39 additions and 4 deletions
|
@ -28,6 +28,16 @@ function canPlayNativeHls() {
|
|||
|| media.canPlayType('application/vnd.apple.mpegURL').replace(/no/, ''));
|
||||
}
|
||||
|
||||
export function enableHlsJsPlayerForCodecs(mediaSource, mediaType) {
|
||||
// Workaround for VP9 HLS support on desktop Safari
|
||||
// Force using HLS.js because desktop Safari's native HLS player does not play VP9 over HLS
|
||||
// browser.osx will return true on iPad, cannot use
|
||||
if (!browser.iOS && browser.safari && mediaSource.MediaStreams.some(x => x.Codec === 'vp9')) {
|
||||
return true
|
||||
}
|
||||
return enableHlsJsPlayer(mediaSource.RunTimeTicks, mediaType)
|
||||
}
|
||||
|
||||
export function enableHlsJsPlayer(runTimeTicks, mediaType) {
|
||||
if (window.MediaSource == null) {
|
||||
return false;
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
destroyCastPlayer,
|
||||
getCrossOriginValue,
|
||||
enableHlsJsPlayer,
|
||||
enableHlsJsPlayerForCodecs,
|
||||
applySrc,
|
||||
resetSrc,
|
||||
playWithPromise,
|
||||
|
@ -515,7 +516,7 @@ export class HtmlVideoPlayer {
|
|||
elem.crossOrigin = crossOrigin;
|
||||
}
|
||||
|
||||
if (enableHlsJsPlayer(options.mediaSource.RunTimeTicks, 'Video') && isHls(options.mediaSource)) {
|
||||
if (enableHlsJsPlayerForCodecs(options.mediaSource, 'Video') && isHls(options.mediaSource)) {
|
||||
return this.setSrcWithHlsJs(elem, options, val);
|
||||
} else if (options.playMethod !== 'Transcode' && options.mediaSource.Container?.toUpperCase() === 'FLV') {
|
||||
return this.setSrcWithFlvJs(elem, options, val);
|
||||
|
|
|
@ -451,6 +451,7 @@ export default function (options) {
|
|||
|
||||
const canPlayVp8 = videoTestElement.canPlayType('video/webm; codecs="vp8"').replace(/no/, '');
|
||||
const canPlayVp9 = videoTestElement.canPlayType('video/webm; codecs="vp9"').replace(/no/, '');
|
||||
const safariSupportsOpus = browser.safari && !!document.createElement('audio').canPlayType('audio/x-caf; codecs="opus"').replace(/no/, '');
|
||||
const webmAudioCodecs = ['vorbis'];
|
||||
|
||||
const canPlayMkv = testCanPlayMkv(videoTestElement);
|
||||
|
@ -580,7 +581,13 @@ export default function (options) {
|
|||
if (browser.tizen) {
|
||||
hlsInTsVideoAudioCodecs.push('opus');
|
||||
}
|
||||
if (!browser.safari) {
|
||||
hlsInFmp4VideoAudioCodecs.push('opus');
|
||||
}
|
||||
|
||||
if (browser.safari) {
|
||||
if (safariSupportsOpus) {
|
||||
videoAudioCodecs.push('opus');
|
||||
webmAudioCodecs.push('opus');
|
||||
hlsInFmp4VideoAudioCodecs.push('opus');
|
||||
}
|
||||
}
|
||||
|
@ -655,7 +662,16 @@ export default function (options) {
|
|||
}
|
||||
|
||||
if (canPlayVp9) {
|
||||
if (!browser.iOS) {
|
||||
// iOS safari may fail to direct play vp9 in mp4 container
|
||||
mp4VideoCodecs.push('vp9');
|
||||
}
|
||||
// Only iOS Safari's native HLS player understands vp9 in fmp4
|
||||
// This should be used in conjunction with forcing
|
||||
// using HLS.js for VP9 remuxing on desktop Safari.
|
||||
if (browser.safari) {
|
||||
hlsInFmp4VideoCodecs.push('vp9');
|
||||
}
|
||||
// webm support is unreliable on safari 17
|
||||
if (!browser.safari
|
||||
|| (browser.safari && browser.versionMajor >= 15 && browser.versionMajor < 17)) {
|
||||
|
@ -672,7 +688,7 @@ export default function (options) {
|
|||
}
|
||||
}
|
||||
|
||||
if (canPlayVp8 || browser.tizen) {
|
||||
if ((!browser.safari && canPlayVp8) || browser.tizen) {
|
||||
videoAudioCodecs.push('vorbis');
|
||||
}
|
||||
|
||||
|
@ -744,6 +760,14 @@ export default function (options) {
|
|||
}
|
||||
});
|
||||
|
||||
if (safariSupportsOpus) {
|
||||
profile.DirectPlayProfiles.push({
|
||||
Container: 'mp4',
|
||||
AudioCodec: 'opus',
|
||||
Type: 'Audio'
|
||||
});
|
||||
}
|
||||
|
||||
profile.TranscodingProfiles = [];
|
||||
|
||||
const hlsBreakOnNonKeyFrames = browser.iOS || browser.osx || browser.edge || !canPlayNativeHls();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue