Merge pull request #1702 from chrisforte/preferred-audio-codec

Add a new option to select preferred audio codec for transcodes
This commit is contained in:
1hitsong 2024-03-17 11:55:53 -04:00 committed by GitHub
commit 5f18ac9d58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 69 deletions

View File

@ -1113,20 +1113,20 @@
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<source>Choose your preferred audio codec when transcoding multichannel audio.</source>
<translation>Choose your preferred audio codec when transcoding multichannel audio.</translation>
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<source>Force all transcodes to use DTS instead of the default EAC3. The device must support DTS for this setting to have an effect.</source>
<translation>Force all transcodes to use DTS instead of the default EAC3. The device must support DTS for this setting to have an effect.</translation>
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<source>Audio Codec Support</source>
<translation>Audio Codec Support</translation>
<source>Preferred Audio Codec</source>
<translation>Preferred Audio Codec</translation>
<extracomment>Settings Menu - Title of option</extracomment>
</message>
<message>
<source>Use the selected audio codec for transcodes. If the device or stream does not support it, a fallback codec will be used.</source>
<translation>Use the selected audio codec for transcodes. If the device or stream does not support it, a fallback codec will be used.</translation>
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<source>Use system settings</source>
<translation>Use system settings</translation>
<extracomment>User Setting - Option title</extracomment>
</message>
<message>
<source>Direct playing</source>
<translation>Direct playing</translation>

View File

@ -16,19 +16,6 @@
"title": "Playback",
"description": "Settings relating to playback and supported codec and media types.",
"children": [
{
"title": "Audio Codec Support",
"description": "Choose your preferred audio codec when transcoding multichannel audio.",
"children": [
{
"title": "DTS",
"description": "Force all transcodes to use DTS instead of the default EAC3. The device must support DTS for this setting to have an effect.",
"settingName": "playback.forceDTS",
"type": "bool",
"default": "false"
}
]
},
{
"title": "Bitrate Limit",
"description": "Configure the maximum playback bitrate.",
@ -187,6 +174,35 @@
"type": "integer",
"default": "30"
},
{
"title": "Preferred Audio Codec",
"description": "Use the selected audio codec for transcodes. If the device or stream does not support it, a fallback codec will be used.",
"settingName": "playback.preferredAudioCodec",
"type": "radio",
"default": "auto",
"options": [
{
"title": "Use system settings",
"id": "auto"
},
{
"title": "AAC",
"id": "aac"
},
{
"title": "DD (AC3)",
"id": "ac3"
},
{
"title": "DD+ (EAC3)",
"id": "eac3"
},
{
"title": "DTS",
"id": "dts"
}
]
},
{
"title": "Text Subtitles Only",
"description": "Only display text subtitles to minimize transcoding.",

View File

@ -195,21 +195,13 @@ function getTranscodingProfiles() as object
' does the users setup support surround sound?
maxAudioChannels = "2" ' jellyfin expects this as a string
' in order of preference from left to right
audioCodecs = ["mp3", "vorbis", "opus", "flac", "alac", "ac4", "pcm", "wma", "wmapro"]
surroundSoundCodecs = ["eac3", "ac3", "dts"]
if globalUserSettings["playback.forceDTS"] = true
surroundSoundCodecs = ["dts", "eac3", "ac3"]
end if
audioCodecs = ["eac3", "ac3", "dts", "mp3", "vorbis", "opus", "flac", "alac", "ac4", "pcm", "wma", "wmapro"]
surroundSoundCodec = invalid
if di.GetAudioOutputChannel() = "5.1 surround"
maxAudioChannels = "6"
for each codec in surroundSoundCodecs
if di.CanDecodeAudio({ Codec: codec, ChCnt: 6 }).Result
surroundSoundCodec = codec
if di.CanDecodeAudio({ Codec: codec, ChCnt: 8 }).Result
maxAudioChannels = "8"
end if
for each codec in audioCodecs
if di.CanDecodeAudio({ Codec: codec, ChCnt: 8 }).Result
maxAudioChannels = "8"
exit for
end if
end for
@ -403,38 +395,10 @@ function getTranscodingProfiles() as object
mp4Array.Conditions = [getMaxHeightArray(), getMaxWidthArray()]
end if
' surround sound
if surroundSoundCodec <> invalid
' add preferred surround sound codec to TranscodingProfile
transcodingProfiles.push({
"Container": surroundSoundCodec,
"Type": "Audio",
"AudioCodec": surroundSoundCodec,
"Context": "Streaming",
"Protocol": "http",
"MaxAudioChannels": maxAudioChannels
})
transcodingProfiles.push({
"Container": surroundSoundCodec,
"Type": "Audio",
"AudioCodec": surroundSoundCodec,
"Context": "Static",
"Protocol": "http",
"MaxAudioChannels": maxAudioChannels
})
' put codec in front of AudioCodec string
if tsArray.AudioCodec = ""
tsArray.AudioCodec = surroundSoundCodec
else
tsArray.AudioCodec = surroundSoundCodec + "," + tsArray.AudioCodec
end if
if mp4Array.AudioCodec = ""
mp4Array.AudioCodec = surroundSoundCodec
else
mp4Array.AudioCodec = surroundSoundCodec + "," + mp4Array.AudioCodec
end if
' add user-selected preferred codec to the front of the list
if globalUserSettings["playback.preferredAudioCodec"] <> "auto"
tsArray.AudioCodec = globalUserSettings["playback.preferredAudioCodec"] + "," + tsArray.AudioCodec
mp4Array.AudioCodec = globalUserSettings["playback.preferredAudioCodec"] + "," + mp4Array.AudioCodec
end if
transcodingProfiles.push(tsArray)