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

Prevent crash and Update video player meta data #1964

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading