mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
possible fix for ogg playback with chrome
This commit is contained in:
parent
f805b45229
commit
503dbb5767
1 changed files with 29 additions and 61 deletions
|
@ -6,15 +6,12 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function canPlayH265(videoTestElement, options) {
|
function canPlayH265(videoTestElement, options) {
|
||||||
|
|
||||||
if (browser.tizen || browser.orsay || browser.xboxOne || browser.web0s || options.supportsHevc) {
|
if (browser.tizen || browser.orsay || browser.xboxOne || browser.web0s || options.supportsHevc) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var userAgent = navigator.userAgent.toLowerCase();
|
var userAgent = navigator.userAgent.toLowerCase();
|
||||||
|
|
||||||
if (browser.chromecast) {
|
if (browser.chromecast) {
|
||||||
|
|
||||||
var isChromecastUltra = userAgent.indexOf('aarch64') !== -1;
|
var isChromecastUltra = userAgent.indexOf('aarch64') !== -1;
|
||||||
if (isChromecastUltra) {
|
if (isChromecastUltra) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -31,7 +28,6 @@ define(['browser'], function (browser) {
|
||||||
|
|
||||||
var _supportsTextTracks;
|
var _supportsTextTracks;
|
||||||
function supportsTextTracks() {
|
function supportsTextTracks() {
|
||||||
|
|
||||||
if (browser.tizen || browser.orsay) {
|
if (browser.tizen || browser.orsay) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,15 +42,14 @@ define(['browser'], function (browser) {
|
||||||
|
|
||||||
var _canPlayHls;
|
var _canPlayHls;
|
||||||
function canPlayHls(src) {
|
function canPlayHls(src) {
|
||||||
|
|
||||||
if (_canPlayHls == null) {
|
if (_canPlayHls == null) {
|
||||||
_canPlayHls = canPlayNativeHls() || canPlayHlsWithMSE();
|
_canPlayHls = canPlayNativeHls() || canPlayHlsWithMSE();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _canPlayHls;
|
return _canPlayHls;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canPlayNativeHls() {
|
function canPlayNativeHls() {
|
||||||
|
|
||||||
if (browser.tizen || browser.orsay) {
|
if (browser.tizen || browser.orsay) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -77,8 +72,27 @@ define(['browser'], function (browser) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canPlayAudioFormat(format) {
|
function supportsAc3(videoTestElement) {
|
||||||
|
if (browser.edgeUwp || browser.tizen || browser.orsay || browser.web0s) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser.osx || browser.iOS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return videoTestElement.canPlayType('audio/mp4; codecs="ac-3"').replace(/no/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function supportsEac3(videoTestElement) {
|
||||||
|
if (browser.tizen || browser.orsay || browser.web0s) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return videoTestElement.canPlayType('audio/mp4; codecs="ec-3"').replace(/no/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function canPlayAudioFormat(format) {
|
||||||
var typeString;
|
var typeString;
|
||||||
|
|
||||||
if (format === 'flac') {
|
if (format === 'flac') {
|
||||||
|
@ -97,14 +111,12 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
} else if (format === 'opus') {
|
} else if (format === 'opus') {
|
||||||
typeString = 'audio/ogg; codecs="opus"';
|
typeString = 'audio/ogg; codecs="opus"';
|
||||||
|
|
||||||
if (document.createElement('audio').canPlayType(typeString).replace(/no/, '')) {
|
if (document.createElement('audio').canPlayType(typeString).replace(/no/, '')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if (format === 'mp2') {
|
} else if (format === 'mp2') {
|
||||||
|
|
||||||
// For now
|
// For now
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -113,14 +125,6 @@ define(['browser'], function (browser) {
|
||||||
typeString = 'audio/webm';
|
typeString = 'audio/webm';
|
||||||
} else if (format === 'mp2') {
|
} else if (format === 'mp2') {
|
||||||
typeString = 'audio/mpeg';
|
typeString = 'audio/mpeg';
|
||||||
} else if (format === 'ogg' || format === 'oga') {
|
|
||||||
|
|
||||||
// chrome says probably, but seeing failures
|
|
||||||
if (browser.chrome) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
typeString = 'audio/' + format;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
typeString = 'audio/' + format;
|
typeString = 'audio/' + format;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +137,6 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCanPlayMkv(videoTestElement) {
|
function testCanPlayMkv(videoTestElement) {
|
||||||
|
|
||||||
if (browser.tizen || browser.orsay || browser.web0s) {
|
if (browser.tizen || browser.orsay || browser.web0s) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +150,6 @@ define(['browser'], function (browser) {
|
||||||
|
|
||||||
// Unfortunately there's no real way to detect mkv support
|
// Unfortunately there's no real way to detect mkv support
|
||||||
if (browser.chrome) {
|
if (browser.chrome) {
|
||||||
|
|
||||||
// Not supported on opera tv
|
// Not supported on opera tv
|
||||||
if (browser.operaTv) {
|
if (browser.operaTv) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -162,7 +164,6 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser.edgeUwp) {
|
if (browser.edgeUwp) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,17 +175,15 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsMpeg2Video() {
|
function supportsMpeg2Video() {
|
||||||
return browser.orsay || browser.tizen || browser.edgeUwp || browser.web0s;
|
return browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsVc1() {
|
function supportsVc1() {
|
||||||
return browser.orsay || browser.tizen || browser.edgeUwp || browser.web0s;
|
return browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFlvMseDirectPlayProfile() {
|
function getFlvMseDirectPlayProfile() {
|
||||||
|
|
||||||
var videoAudioCodecs = ['aac'];
|
var videoAudioCodecs = ['aac'];
|
||||||
|
|
||||||
if (!browser.edge && !browser.msie) {
|
if (!browser.edge && !browser.msie) {
|
||||||
videoAudioCodecs.push('mp3');
|
videoAudioCodecs.push('mp3');
|
||||||
}
|
}
|
||||||
|
@ -198,13 +197,11 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDirectPlayProfileForVideoContainer(container, videoAudioCodecs, videoTestElement, options) {
|
function getDirectPlayProfileForVideoContainer(container, videoAudioCodecs, videoTestElement, options) {
|
||||||
|
|
||||||
var supported = false;
|
var supported = false;
|
||||||
var profileContainer = container;
|
var profileContainer = container;
|
||||||
var videoCodecs = [];
|
var videoCodecs = [];
|
||||||
|
|
||||||
switch (container) {
|
switch (container) {
|
||||||
|
|
||||||
case 'asf':
|
case 'asf':
|
||||||
supported = browser.tizen || browser.orsay || browser.edgeUwp;
|
supported = browser.tizen || browser.orsay || browser.edgeUwp;
|
||||||
videoAudioCodecs = [];
|
videoAudioCodecs = [];
|
||||||
|
@ -279,16 +276,12 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMaxBitrate() {
|
function getMaxBitrate() {
|
||||||
|
|
||||||
return 120000000;
|
return 120000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGlobalMaxVideoBitrate() {
|
function getGlobalMaxVideoBitrate() {
|
||||||
|
|
||||||
var userAgent = navigator.userAgent.toLowerCase();
|
var userAgent = navigator.userAgent.toLowerCase();
|
||||||
|
|
||||||
if (browser.chromecast) {
|
if (browser.chromecast) {
|
||||||
|
|
||||||
var isChromecastUltra = userAgent.indexOf('aarch64') !== -1;
|
var isChromecastUltra = userAgent.indexOf('aarch64') !== -1;
|
||||||
if (isChromecastUltra) {
|
if (isChromecastUltra) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -319,27 +312,9 @@ define(['browser'], function (browser) {
|
||||||
(browser.tizen && isTizenFhd ? 20000000 : null)));
|
(browser.tizen && isTizenFhd ? 20000000 : null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsAc3(videoTestElement) {
|
|
||||||
|
|
||||||
if (browser.edgeUwp || browser.tizen || browser.orsay || browser.web0s) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (videoTestElement.canPlayType('audio/mp4; codecs="ac-3"').replace(/no/, '') && !browser.osx && !browser.iOS);
|
|
||||||
}
|
|
||||||
|
|
||||||
function supportsEac3(videoTestElement) {
|
|
||||||
|
|
||||||
if (browser.tizen || browser.orsay || browser.web0s) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return videoTestElement.canPlayType('audio/mp4; codecs="ec-3"').replace(/no/, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (options) {
|
return function (options) {
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var physicalAudioChannels = options.audioChannels || (browser.tv || browser.ps4 || browser.xboxOne ? 6 : 2);
|
var physicalAudioChannels = options.audioChannels || (browser.tv || browser.ps4 || browser.xboxOne ? 6 : 2);
|
||||||
|
|
||||||
var bitrateSetting = getMaxBitrate();
|
var bitrateSetting = getMaxBitrate();
|
||||||
|
@ -417,7 +392,6 @@ define(['browser'], function (browser) {
|
||||||
|
|
||||||
// PS4 fails to load HLS with mp3 audio
|
// PS4 fails to load HLS with mp3 audio
|
||||||
if (!browser.ps4) {
|
if (!browser.ps4) {
|
||||||
|
|
||||||
// mp3 encoder only supports 2 channels, so only make that preferred if we're only requesting 2 channels
|
// mp3 encoder only supports 2 channels, so only make that preferred if we're only requesting 2 channels
|
||||||
// Also apply it for chromecast because it no longer supports AAC 5.1
|
// Also apply it for chromecast because it no longer supports AAC 5.1
|
||||||
if (physicalAudioChannels <= 2) {
|
if (physicalAudioChannels <= 2) {
|
||||||
|
@ -425,14 +399,15 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (canPlayAacVideoAudio) {
|
|
||||||
|
|
||||||
|
if (canPlayAacVideoAudio) {
|
||||||
if (videoAudioCodecs.indexOf('aac') === -1) {
|
if (videoAudioCodecs.indexOf('aac') === -1) {
|
||||||
videoAudioCodecs.push('aac');
|
videoAudioCodecs.push('aac');
|
||||||
}
|
}
|
||||||
|
|
||||||
hlsVideoAudioCodecs.push('aac');
|
hlsVideoAudioCodecs.push('aac');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportsMp3VideoAudio) {
|
if (supportsMp3VideoAudio) {
|
||||||
// PS4 fails to load HLS with mp3 audio
|
// PS4 fails to load HLS with mp3 audio
|
||||||
if (!browser.ps4) {
|
if (!browser.ps4) {
|
||||||
|
@ -525,6 +500,7 @@ define(['browser'], function (browser) {
|
||||||
if (canPlayVp8) {
|
if (canPlayVp8) {
|
||||||
mp4VideoCodecs.push('vp8');
|
mp4VideoCodecs.push('vp8');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canPlayVp9) {
|
if (canPlayVp9) {
|
||||||
mp4VideoCodecs.push('vp9');
|
mp4VideoCodecs.push('vp9');
|
||||||
}
|
}
|
||||||
|
@ -563,20 +539,17 @@ define(['browser'], function (browser) {
|
||||||
['opus', 'mp3', 'mp2', 'aac', 'flac', 'alac', 'webma', 'wma', 'wav', 'ogg', 'oga'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
['opus', 'mp3', 'mp2', 'aac', 'flac', 'alac', 'webma', 'wma', 'wav', 'ogg', 'oga'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
||||||
|
|
||||||
if (audioFormat === 'mp2') {
|
if (audioFormat === 'mp2') {
|
||||||
|
|
||||||
profile.DirectPlayProfiles.push({
|
profile.DirectPlayProfiles.push({
|
||||||
Container: 'mp2,mp3',
|
Container: 'mp2,mp3',
|
||||||
Type: 'Audio',
|
Type: 'Audio',
|
||||||
AudioCodec: audioFormat
|
AudioCodec: audioFormat
|
||||||
});
|
});
|
||||||
} else if (audioFormat === 'mp3') {
|
} else if (audioFormat === 'mp3') {
|
||||||
|
|
||||||
profile.DirectPlayProfiles.push({
|
profile.DirectPlayProfiles.push({
|
||||||
Container: audioFormat,
|
Container: audioFormat,
|
||||||
Type: 'Audio',
|
Type: 'Audio',
|
||||||
AudioCodec: audioFormat
|
AudioCodec: audioFormat
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
profile.DirectPlayProfiles.push({
|
profile.DirectPlayProfiles.push({
|
||||||
Container: audioFormat === 'webma' ? 'webma,webm' : audioFormat,
|
Container: audioFormat === 'webma' ? 'webma,webm' : audioFormat,
|
||||||
|
@ -586,7 +559,6 @@ define(['browser'], function (browser) {
|
||||||
|
|
||||||
// aac also appears in the m4a container
|
// aac also appears in the m4a container
|
||||||
if (audioFormat === 'aac' || audioFormat === 'alac') {
|
if (audioFormat === 'aac' || audioFormat === 'alac') {
|
||||||
|
|
||||||
profile.DirectPlayProfiles.push({
|
profile.DirectPlayProfiles.push({
|
||||||
Container: 'm4a',
|
Container: 'm4a',
|
||||||
AudioCodec: audioFormat,
|
AudioCodec: audioFormat,
|
||||||
|
@ -619,7 +591,6 @@ define(['browser'], function (browser) {
|
||||||
|
|
||||||
if (canPlayHls() && browser.enableHlsAudio !== false) {
|
if (canPlayHls() && browser.enableHlsAudio !== false) {
|
||||||
profile.TranscodingProfiles.push({
|
profile.TranscodingProfiles.push({
|
||||||
|
|
||||||
// hlsjs, edge, and android all seem to require ts container
|
// hlsjs, edge, and android all seem to require ts container
|
||||||
Container: !canPlayNativeHls() || browser.edge || browser.android ? 'ts' : 'aac',
|
Container: !canPlayNativeHls() || browser.edge || browser.android ? 'ts' : 'aac',
|
||||||
Type: 'Audio',
|
Type: 'Audio',
|
||||||
|
@ -636,7 +607,6 @@ define(['browser'], function (browser) {
|
||||||
// But for static (offline sync), it will be just fine.
|
// But for static (offline sync), it will be just fine.
|
||||||
// Prioritize aac higher because the encoder can accept more channels than mp3
|
// Prioritize aac higher because the encoder can accept more channels than mp3
|
||||||
['aac', 'mp3', 'opus', 'wav'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
['aac', 'mp3', 'opus', 'wav'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
||||||
|
|
||||||
profile.TranscodingProfiles.push({
|
profile.TranscodingProfiles.push({
|
||||||
Container: audioFormat,
|
Container: audioFormat,
|
||||||
Type: 'Audio',
|
Type: 'Audio',
|
||||||
|
@ -648,7 +618,6 @@ define(['browser'], function (browser) {
|
||||||
});
|
});
|
||||||
|
|
||||||
['opus', 'mp3', 'aac', 'wav'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
['opus', 'mp3', 'aac', 'wav'].filter(canPlayAudioFormat).forEach(function (audioFormat) {
|
||||||
|
|
||||||
profile.TranscodingProfiles.push({
|
profile.TranscodingProfiles.push({
|
||||||
Container: audioFormat,
|
Container: audioFormat,
|
||||||
Type: 'Audio',
|
Type: 'Audio',
|
||||||
|
@ -804,7 +773,8 @@ define(['browser'], function (browser) {
|
||||||
Condition: 'LessThanEqual',
|
Condition: 'LessThanEqual',
|
||||||
Property: 'VideoLevel',
|
Property: 'VideoLevel',
|
||||||
Value: maxH264Level.toString()
|
Value: maxH264Level.toString()
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!browser.edgeUwp && !browser.tizen && !browser.orsay && !browser.web0s) {
|
if (!browser.edgeUwp && !browser.tizen && !browser.orsay && !browser.web0s) {
|
||||||
|
@ -888,7 +858,6 @@ define(['browser'], function (browser) {
|
||||||
// External vtt or burn in
|
// External vtt or burn in
|
||||||
profile.SubtitleProfiles = [];
|
profile.SubtitleProfiles = [];
|
||||||
if (supportsTextTracks()) {
|
if (supportsTextTracks()) {
|
||||||
|
|
||||||
profile.SubtitleProfiles.push({
|
profile.SubtitleProfiles.push({
|
||||||
Format: 'vtt',
|
Format: 'vtt',
|
||||||
Method: 'External'
|
Method: 'External'
|
||||||
|
@ -896,7 +865,6 @@ define(['browser'], function (browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.ResponseProfiles = [];
|
profile.ResponseProfiles = [];
|
||||||
|
|
||||||
profile.ResponseProfiles.push({
|
profile.ResponseProfiles.push({
|
||||||
Type: 'Video',
|
Type: 'Video',
|
||||||
Container: 'm4v',
|
Container: 'm4v',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue