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

Audio transcoding detection #45

Closed
dag420 opened this issue May 27, 2019 · 6 comments
Closed

Audio transcoding detection #45

dag420 opened this issue May 27, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@dag420
Copy link

dag420 commented May 27, 2019

No sound on some titles, does not detect need to transcode. No option to force audio to a format roku can understand.

@dag420 dag420 added the enhancement New feature or request label May 27, 2019
@fabianvf
Copy link

I saw the no sound issue the other day

@bisby
Copy link
Contributor

bisby commented Aug 19, 2019

We automatically pick the the very first audio codec without further inspection.

https://github.com/jellyfin/jellyfin-roku/blob/master/source/VideoPlayer.brs#L70

And we automatically pick the streaming method (I dont remember if this factors into transcoding).

https://github.com/jellyfin/jellyfin-roku/blob/master/source/VideoPlayer.brs#L28

This was very much a "get things working" implementation that hasn't been revisited yet.

@cghouly
Copy link
Contributor

cghouly commented Aug 25, 2019

I have the same issue so I've been working on this one.
My roku is connected to a stereo TV and I found that any video with non-stereo audio would not play sound. I also found that any avi files would not play. I wrote some code to account for these scenarios (see diff below).

I have been playing with the CanDecodeVideo() and CanDecodeAudio() fuctions, but I cannot figure out a way to utilize the returned compatible formats to modify the stream url. This seems like the best solution.

In the meantime I'll leave this here for anyone that wants to have a quick fix for this issue:

diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs
index 6f81c90..a2c6cfa 100644
--- a/source/VideoPlayer.brs
+++ b/source/VideoPlayer.brs
@@ -21,14 +21,37 @@ function VideoContent(id) as object
   content = createObject("RoSGNode", "ContentNode")
 
   meta = ItemMetaData(id)
-  content.title = meta.Name
+  content.title = meta.title
 
   container = getContainerType(meta)
 
-  content.url = buildURL(Substitute("Videos/{0}/stream", id), {
-    Static: "true",
-    Container: container
-  })
+  audioInfo = getAudioInfo(meta)
+
+  ' Get roku audio output setting
+  devInfo = CreateObject("roDeviceInfo")
+  audioChannels = devInfo.GetAudioOutputChannel()
+
+  if audioChannels = "Stereo" and audioInfo[0].Channels <> 2 or container = "avi"
+    if audioChannels = "Stereo"
+      numAudioChannels=2
+    else
+      numAudioChannels = audioInfo[0].Channels
+    end if
+
+    ' todo - set container correctly without breaking stream
+    container = "(null)"
+
+    content.url = buildURL(Substitute("Videos/{0}/stream", id), {
+      VideoCodec: "h264"
+      AudioCodec: "aac",
+      TranscodingMaxAudioChannels: numAudioChannels
+    })
+  else
+    content.url = buildURL(Substitute("Videos/{0}/stream", id), {
+      Static: "true",
+      Container: container
+    })
+  end if
 
   content = authorize_request(content)

@jcdick1
Copy link

jcdick1 commented Apr 1, 2020

Could this - and video - be done with a comparison between the meta sent from the server and a CanDecodeAudio or CanDecodeVideo from an roDeviceInfo?

@neilsb
Copy link
Member

neilsb commented Oct 11, 2020

I believe this should be resolved completely now. Audio is checked and transcoded if required,

Currently if Audio requires transcoding, it is transcoded to AAC (either 2 or 6 channel based on Roku configuration info). The choice of "best" codec to transcode to should be made based on the response from CanDecodeAudio and potentially overridden by a user preference. The same is true for video. A separate issue will be created for this enhancement.

@neilsb neilsb closed this as completed Oct 11, 2020
@Sawtaytoes
Copy link

Sawtaytoes commented Jan 10, 2023

I can confirm that when my Roku is in Passthrough mode, it incorrectly plays in stereo and does 8 channel audio when it's in Auto mode.

Either way, my height channels don't work in either Dolby Atmos or DTS:X even though this model of Roku supports those formats in passthrough mode. Passthrough is supposed to send the bitstream directly to my receiver.

Is there a separate bug report for incorrectly selecting stereo for passthrough mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants