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 setting to prioritise what audio codec to transcode to #5434

Merged
merged 12 commits into from
May 18, 2024
15 changes: 15 additions & 0 deletions src/components/apphost.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ function getDeviceProfile(item) {
});
}

const preferredTranscodeVideoAudioCodec = appSettings.preferredTranscodeVideoAudioCodec();
if (preferredTranscodeVideoAudioCodec) {
profile.TranscodingProfiles.forEach((transcodingProfile) => {
if (transcodingProfile.Type === 'Video') {
const audioCodecs = transcodingProfile.AudioCodec.split(',');
const index = audioCodecs.indexOf(preferredTranscodeVideoAudioCodec);
if (index !== -1) {
audioCodecs.splice(index, 1);
audioCodecs.unshift(preferredTranscodeVideoAudioCodec);
transcodingProfile.AudioCodec = audioCodecs.join(',');
}
}
});
}

resolve(profile);
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/playbackSettings/playbackSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function loadForm(context, user, userSettings, systemInfo, apiClient) {
context.querySelector('.chkRememberSubtitleSelections').checked = user.Configuration.RememberSubtitleSelections || false;
context.querySelector('.chkExternalVideoPlayer').checked = appSettings.enableSystemExternalPlayers();
context.querySelector('.chkLimitSupportedVideoResolution').checked = appSettings.limitSupportedVideoResolution();
context.querySelector('#selectPreferredTranscodeVideoAudioCodec').value = appSettings.preferredTranscodeVideoAudioCodec();

setMaxBitrateIntoField(context.querySelector('.selectVideoInNetworkQuality'), true, 'Video');
setMaxBitrateIntoField(context.querySelector('.selectVideoInternetQuality'), false, 'Video');
Expand Down Expand Up @@ -217,6 +218,7 @@ function saveUser(context, user, userSettingsInstance, apiClient) {
appSettings.maxChromecastBitrate(context.querySelector('.selectChromecastVideoQuality').value);
appSettings.maxVideoWidth(context.querySelector('.selectMaxVideoWidth').value);
appSettings.limitSupportedVideoResolution(context.querySelector('.chkLimitSupportedVideoResolution').checked);
appSettings.preferredTranscodeVideoAudioCodec(context.querySelector('#selectPreferredTranscodeVideoAudioCodec').value);

appSettings.enableDts(context.querySelector('.chkEnableDts').checked);
appSettings.enableTrueHd(context.querySelector('.chkEnableTrueHd').checked);
Expand Down
13 changes: 13 additions & 0 deletions src/components/playbackSettings/playbackSettings.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ <h2 class="sectionTitle">
</label>
<div class="fieldDescription checkboxFieldDescription">${EnableTrueHdHelp}</div>
</div>

<div class="selectContainer">
scampower3 marked this conversation as resolved.
Show resolved Hide resolved
<select is="emby-select" id="selectPreferredTranscodeVideoAudioCodec" label="${LabelSelectPreferredTranscodeVideoAudioCodec}">
<option value="">${Auto}</option>
<option value="aac">AAC</option>
<option value="ac3">AC3</option>
<option value="alac">ALAC</option>
<option value="dts">DTS</option>
<option value="flac">FLAC</option>
<option value="opus">Opus</option>
scampower3 marked this conversation as resolved.
Show resolved Hide resolved
</select>
<div class="fieldDescription">${SelectPreferredTranscodeVideoAudioCodecHelp}</div>
</div>
</div>

<button is="emby-button" type="submit" class="raised button-submit block btnSave hide">
Expand Down
12 changes: 12 additions & 0 deletions src/scripts/settings/appSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ class AppSettings {
return toBoolean(this.get('limitSupportedVideoResolution'), false);
}

/**
* Get or set preferred transcode audio codec in video playback.
* @param {string|undefined} val - Preferred transcode audio codec or undefined.
* @return {string} Preferred transcode audio codec.
*/
preferredTranscodeVideoAudioCodec(val) {
if (val !== undefined) {
return this.set('preferredTranscodeVideoAudioCodec', val);
}
return this.get('preferredTranscodeVideoAudioCodec') || '';
}

/**
* Get or set 'Enable DTS' state.
* @param {boolean|undefined} val - Flag to enable 'Enable DTS' or undefined.
Expand Down
2 changes: 2 additions & 0 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@
"LabelAudioCodec": "Audio codec",
"LabelAudioLanguagePreference": "Preferred audio language",
"LabelSelectAudioNormalization": "Audio Normalization",
"LabelSelectPreferredTranscodeVideoAudioCodec": "Preferred transcode audio codec in video playback",
"LabelAudioSampleRate": "Audio sample rate",
"LabelAuthProvider": "Authentication Provider",
"LabelAutomaticallyAddToCollection": "Automatically add to collection",
Expand Down Expand Up @@ -1379,6 +1380,7 @@
"Season": "Season",
"SecondarySubtitles": "Secondary Subtitles",
"SelectAdminUsername": "Please select a username for the admin account.",
"SelectPreferredTranscodeVideoAudioCodecHelp": "Select the preferred audio codec to transcode to for video content. If the preferred codec is not supported, the server will use the next best available codec.",
"SelectServer": "Select Server",
"SendMessage": "Send message",
"Series": "Series",
Expand Down
Loading