1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #2026 from nyanmisaka/adjust-hls-codec

Adjust the default audio codec to AAC for HLS streaming
This commit is contained in:
Bill Thornton 2020-11-16 17:43:58 -05:00 committed by GitHub
commit f6b9a3d8cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -338,54 +338,48 @@ define(['browser'], function (browser) {
} }
const canPlayAacVideoAudio = videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.40.2"').replace(/no/, ''); const canPlayAacVideoAudio = videoTestElement.canPlayType('video/mp4; codecs="avc1.640029, mp4a.40.2"').replace(/no/, '');
const canPlayAc3VideoAudio = supportsAc3(videoTestElement);
const canPlayEac3VideoAudio = supportsEac3(videoTestElement);
const canPlayAc3VideoAudioInHls = supportsAc3InHls(videoTestElement);
// Only put mp3 first if mkv support is there if (canPlayAc3VideoAudio) {
// Otherwise with HLS and mp3 audio we're seeing some browsers
// safari is lying
if (supportsAc3(videoTestElement)) {
videoAudioCodecs.push('ac3'); videoAudioCodecs.push('ac3');
if (canPlayEac3VideoAudio) {
const eAc3 = supportsEac3(videoTestElement);
if (eAc3) {
videoAudioCodecs.push('eac3'); videoAudioCodecs.push('eac3');
} }
// This works in edge desktop, but not mobile // This works in edge desktop, but not mobile
// TODO: Retest this on mobile // TODO: Retest this on mobile
if (supportsAc3InHls(videoTestElement)) { // Transcoding codec is the first in hlsVideoAudioCodecs
// Put ac3/eac3 first only when the audio channels > 2 and need transcoding
if (canPlayAc3VideoAudioInHls && physicalAudioChannels > 2) {
hlsVideoAudioCodecs.push('ac3'); hlsVideoAudioCodecs.push('ac3');
if (eAc3) { if (canPlayEac3VideoAudio) {
hlsVideoAudioCodecs.push('eac3'); hlsVideoAudioCodecs.push('eac3');
} }
} }
} }
if (canPlayAacVideoAudio) {
videoAudioCodecs.push('aac');
hlsVideoAudioCodecs.push('aac');
}
if (supportsMp3VideoAudio) { if (supportsMp3VideoAudio) {
videoAudioCodecs.push('mp3'); videoAudioCodecs.push('mp3');
// 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 hlsVideoAudioCodecs.push('mp3');
// Also apply it for chromecast because it no longer supports AAC 5.1
if (physicalAudioChannels <= 2) {
hlsVideoAudioCodecs.push('mp3');
}
} }
} }
if (canPlayAacVideoAudio) { // For ac3/eac3 directstream
if (videoAudioCodecs.indexOf('aac') === -1) { if (canPlayAc3VideoAudio) {
videoAudioCodecs.push('aac'); if (canPlayAc3VideoAudioInHls && hlsVideoAudioCodecs.indexOf('ac3') === -1) {
} hlsVideoAudioCodecs.push('ac3');
if (canPlayEac3VideoAudio && hlsVideoAudioCodecs.indexOf('eac3') === -1) {
hlsVideoAudioCodecs.push('aac'); hlsVideoAudioCodecs.push('eac3');
}
if (supportsMp3VideoAudio) {
// PS4 fails to load HLS with mp3 audio
if (!browser.ps4) {
if (hlsVideoAudioCodecs.indexOf('mp3') === -1) {
hlsVideoAudioCodecs.push('mp3');
} }
} }
} }
@ -524,21 +518,14 @@ 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') { profile.DirectPlayProfiles.push({
Container: audioFormat,
Type: 'Audio'
});
if (audioFormat === 'webma') {
profile.DirectPlayProfiles.push({ profile.DirectPlayProfiles.push({
Container: 'mp2,mp3', Container: 'webm',
Type: 'Audio',
AudioCodec: audioFormat
});
} else if (audioFormat === 'mp3') {
profile.DirectPlayProfiles.push({
Container: audioFormat,
Type: 'Audio',
AudioCodec: audioFormat
});
} else {
profile.DirectPlayProfiles.push({
Container: audioFormat === 'webma' ? 'webma,webm' : audioFormat,
Type: 'Audio' Type: 'Audio'
}); });
} }
@ -547,7 +534,6 @@ define(['browser'], function (browser) {
if (audioFormat === 'aac' || audioFormat === 'alac') { if (audioFormat === 'aac' || audioFormat === 'alac') {
profile.DirectPlayProfiles.push({ profile.DirectPlayProfiles.push({
Container: 'm4a,m4b', Container: 'm4a,m4b',
AudioCodec: audioFormat,
Type: 'Audio' Type: 'Audio'
}); });
} }