Skip to content

Commit

Permalink
Merge pull request jellyfin#2056 from jellyfin/2.2.z
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert authored Nov 20, 2024
2 parents 700dcc2 + b92ac00 commit e9deedf
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# If you want to get_images, you'll also need convert from ImageMagick
##########################################################################

VERSION := 2.2.4
VERSION := 2.2.5

## usage

Expand Down
5 changes: 3 additions & 2 deletions components/ItemGrid/LoadVideoContentTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ sub loadItems()
forceTranscoding = false

m.top.content = [LoadItems_VideoPlayer(id, mediaSourceId, audio_stream_idx, forceTranscoding)]
m.top.forceMp3 = false
end sub

function LoadItems_VideoPlayer(id as string, mediaSourceId = invalid as dynamic, audio_stream_idx = 1 as integer, forceTranscoding = false as boolean) as dynamic
Expand Down Expand Up @@ -172,7 +173,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
if not isValid(mediaSourceId) then mediaSourceId = video.id
if meta.live then mediaSourceId = ""

m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition)
m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition, m.top.forceMp3)
if not isValid(m.playbackInfo)
video.errorMsg = "Error loading playback info"
video.content = invalid
Expand All @@ -189,7 +190,7 @@ sub LoadItems_AddVideoContent(video as object, mediaSourceId as dynamic, audio_s
video.SelectedSubtitle = defaultSubtitleIndex
subtitle_idx = defaultSubtitleIndex

m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition)
m.playbackInfo = ItemPostPlaybackInfo(video.id, mediaSourceId, audio_stream_idx, subtitle_idx, playbackPosition, m.top.forceMp3)
if not isValid(m.playbackInfo)
video.errorMsg = "Error loading playback info"
video.content = invalid
Expand Down
1 change: 1 addition & 0 deletions components/ItemGrid/LoadVideoContentTask.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<field id="studioIds" type="string" value="" />
<field id="genreIds" type="string" value="" />
<field id="view" type="string" value="" />
<field id="forceMp3" type="boolean" value="false" />
<!-- Total records available from server-->
<field id="totalRecordCount" type="int" value="-1" />
<field id="content" type="array" />
Expand Down
14 changes: 13 additions & 1 deletion components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ sub init()

m.playbackTimer = m.top.findNode("playbackTimer")
m.bufferCheckTimer = m.top.findNode("bufferCheckTimer")
m.top.observeField("state", "onState")
m.top.observeField("content", "onContentChange")
m.top.observeField("selectedSubtitle", "onSubtitleChange")
m.top.observeField("audioIndex", "onAudioIndexChange")
Expand Down Expand Up @@ -397,6 +396,8 @@ sub onVideoContentLoaded()
return
end if

m.top.observeField("state", "onState")

m.top.content = videoContent[0].content
m.top.PlaySessionId = videoContent[0].PlaySessionId
m.top.videoId = videoContent[0].id
Expand Down Expand Up @@ -639,6 +640,17 @@ sub onState(msg)

if not m.playReported and m.top.transcodeAvailable
m.top.retryWithTranscoding = true ' If playback was not reported, retry with transcoding
else if m.top.errorStr = "decoder:pump:Unsupported AAC stream."
m.log.info("retrying video with mp3 audio stream", m.currentItem.id, m.top.SelectedSubtitle, m.top.audioIndex)

m.top.unobserveField("state")
m.LoadMetaDataTask.forceMp3 = true
m.LoadMetaDataTask.selectedSubtitleIndex = m.top.SelectedSubtitle
m.LoadMetaDataTask.selectedAudioStreamIndex = m.top.audioIndex
m.LoadMetaDataTask.itemId = m.currentItem.id
m.LoadMetaDataTask.observeField("content", "onVideoContentLoaded")

m.LoadMetaDataTask.control = "RUN"
else
' If an error was encountered, Display dialog
showPlaybackErrorDialog(tr("Error During Playback"))
Expand Down
1 change: 1 addition & 0 deletions components/video/VideoPlayerView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<field id="retryWithTranscoding" type="boolean" value="false" />
<field id="isTranscoded" type="boolean" />
<field id="transcodeReasons" type="array" />
<field id="forceMp3" type="boolean" value="false" />

<field id="videoId" type="string" />
<field id="mediaSourceId" type="string" />
Expand Down
2 changes: 1 addition & 1 deletion manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title=Jellyfin
major_version=2
minor_version=2
build_version=4
build_version=5

### Main Menu Icons / Channel Poster Artwork

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jellyfin-roku",
"type": "module",
"version": "2.2.4",
"version": "2.2.5",
"description": "Roku app for Jellyfin media server",
"dependencies": {
"@rokucommunity/bslib": "0.1.1",
Expand Down
35 changes: 21 additions & 14 deletions source/api/Items.bs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ItemGetPlaybackInfo(id as string, startTimeTicks = 0 as longinteger)
return getJson(resp)
end function

function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioTrackIndex = -1 as integer, subtitleTrackIndex = -1 as integer, startTimeTicks = 0 as longinteger)
function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioTrackIndex = -1 as integer, subtitleTrackIndex = -1 as integer, startTimeTicks = 0 as longinteger, forceMp3 = false as boolean)
params = {
"UserId": m.global.session.user.id,
"StartTimeTicks": startTimeTicks,
Expand Down Expand Up @@ -49,24 +49,14 @@ function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioT
' TODO: Remove this after server adds support for transcoding AAC from one profile to another
if selectedAudioStream.Codec <> invalid and LCase(selectedAudioStream.Codec) = "aac"
if selectedAudioStream.Profile <> invalid and 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 for
forceMp3 = true
end if
end if
end if
end if

if forceMp3 then forceMp3Audio(deviceProfile)

req = APIRequest(Substitute("Items/{0}/PlaybackInfo", id), params)
req.SetRequest("POST")
return postJson(req, FormatJson({ "DeviceProfile": deviceProfile }))
Expand Down Expand Up @@ -538,3 +528,20 @@ function TVEpisodeShuffleList(show_id as string)

return data
end function

' updates the device profile we send the server to force mp3 audio transcoding instead of the default aac
sub forceMp3Audio(deviceProfile as object)
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 for
end sub

0 comments on commit e9deedf

Please sign in to comment.