Skip to content

Commit

Permalink
Merge pull request #1964 from cewert/maxvideodecoderesolution
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Oct 4, 2024
2 parents 8942292 + 42bb0eb commit d17a8d9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
15 changes: 15 additions & 0 deletions components/ItemGrid/LoadVideoContentTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
end if

session.video.Update(meta)

if isValid(meta.json.MediaSources[0].RunTimeTicks)
if meta.json.MediaSources[0].RunTimeTicks = 0
video.length = 0
else
video.length = meta.json.MediaSources[0].RunTimeTicks / 10000000
end if
end if
video.MaxVideoDecodeResolution = [meta.json.MediaSources[0].MediaStreams[0].Width, meta.json.MediaSources[0].MediaStreams[0].Height]

subtitle_idx = m.top.selectedSubtitleIndex
videotype = LCase(meta.type)

Expand Down Expand Up @@ -183,6 +193,11 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
end if

video.container = getContainerType(meta)
if video.container = "mp4"
video.content.StreamFormat = "mp4"
else if video.container = "mkv"
video.content.StreamFormat = "mkv"
end if

if not isValid(m.playbackInfo.MediaSources[0])
m.playbackInfo = meta.json
Expand Down
37 changes: 20 additions & 17 deletions source/api/Items.bs
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,31 @@ function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioT
end if

if audioTrackIndex > -1
params.AudioStreamIndex = audioTrackIndex

' force the server to transcode AAC profiles we don't support to MP3 instead of the usual AAC
' TODO: Remove this after server adds support for transcoding AAC from one profile to another
selectedAudioStream = m.global.session.video.json.MediaStreams[audioTrackIndex]

if LCase(selectedAudioStream.Codec) = "aac"
if LCase(selectedAudioStream.Profile) = "main" or LCase(selectedAudioStream.Profile) = "he-aac"
for each rule in deviceProfile.TranscodingProfiles
if rule.Container = "ts" or rule.Container = "mp4"
if rule.AudioCodec = "aac"
rule.AudioCodec = "mp3"
else if rule.AudioCodec.Left(4) = "aac,"
rule.AudioCodec = mid(rule.AudioCodec, 5)

if rule.AudioCodec.Left(3) <> "mp3"
rule.AudioCodec = "mp3," + rule.AudioCodec
if selectedAudioStream <> invalid
params.AudioStreamIndex = audioTrackIndex

' force the server to transcode AAC profiles we don't support to MP3 instead of the usual AAC
' TODO: Remove this after server adds support for transcoding AAC from one profile to another
if LCase(selectedAudioStream.Codec) = "aac"
if LCase(selectedAudioStream.Profile) = "main" or LCase(selectedAudioStream.Profile) = "he-aac"
for each rule in deviceProfile.TranscodingProfiles
if rule.Container = "ts" or rule.Container = "mp4"
if rule.AudioCodec = "aac"
rule.AudioCodec = "mp3"
else if rule.AudioCodec.Left(4) = "aac,"
rule.AudioCodec = mid(rule.AudioCodec, 5)

if rule.AudioCodec.Left(3) <> "mp3"
rule.AudioCodec = "mp3," + rule.AudioCodec
end if
end if
end if
end if
end for
end for
end if
end if

end if
end if

Expand Down

0 comments on commit d17a8d9

Please sign in to comment.