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

TrueHD support #59

Closed
CloudStu opened this issue Sep 24, 2021 · 4 comments · Fixed by #79 or jellyfin/jellyfin#9121
Closed

TrueHD support #59

CloudStu opened this issue Sep 24, 2021 · 4 comments · Fixed by #79 or jellyfin/jellyfin#9121

Comments

@CloudStu
Copy link

I have several files that contain Dolby TrueHD audio streams. Whilst I can't find an authoritative source, it seems that my LG B9 cannot play TrueHD on any internal apps like Jellyfin, nor will it send it out via eARC.

However, what the TV can play or passthrough is the fallback track (Dolby Digital AC-3) that is very often embedded with TrueHD streams.

Unfortunately, Jellyfin-server is refusing to send the TrueHD stream. I see the error Jellyfin.Api.Helpers.MediaInfoHelper: Container: "mkv,webm", Video: "hevc", Audio: "truehd" cannot be direct played by profile: "unknown profile" for path: [REDACTED]

I've attached the few lines before this message, including GetPostedPlaybackInfo

Instead, it tries to transcode to AAC. In the case of my HEVC files, it is also trying to transcode that part too, even though the TV supports this. So I see the following ffmpeg failure:

Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_qsv))
  Stream #0:1 -> #0:1 (truehd (native) -> aac (native))
Press [q] to stop, [?] for help
[Parsed_tonemap_vaapi_0 @ 0x565211d538c0] Failed to query HDR caps context: 32 (the requested filter is not supported).
[Parsed_tonemap_vaapi_0 @ 0x565211d538c0] Failed to configure output pad on Parsed_tonemap_vaapi_0
Error reinitializing filters!
Failed to inject frame into filter network: Input/output error
Error while processing the decoded data for stream #0:0
[aac @ 0x565211ca0fc0] Qavg: 65536.000
[aac @ 0x565211ca0fc0] 2 frames left in the queue on closing
Conversion failed!

Now this seems to be an issue transcoding the HEVC and not the audio, but the end result is the same, I can't play the file - particularly frustrating though because I know my TV supports HEVC.

Not wanting to admit defeat, after some poking around I made the following change to add supportsTrueHd: true in org.jellyfin.webos/js/webOS.js :

             getDeviceProfile: function (profileBuilder) {
                 postMessage('AppHost.getDeviceProfile');
-                return profileBuilder({ enableMkvProgressive: false, enableSsaRender: true });
+                return profileBuilder({ enableMkvProgressive: false, enableSsaRender: true, supportsTrueHd: true });
             },

And now my TrueHD files make no attempt to transcode, instead playing with directplay. Even better, I can hear sound! Whilst the Jellyfin player is reporting TRUEHD, I believe what I am actually hearing is the fallback embedded in the TrueHD stream (but I'm really not an expert, entirely self-taught in the past 24 hours).

I however believe this for two reasons. The first is this file is described as TrueHD Atmos, but neither my soundbar over eARC, nor the TV when the internal speaker is enabled, are displaying the ATMOS sign that they normally do (such as for other DD+ Atmos files that I have).

The other more obvious reason is that if I play a file that only contains a TrueHD audio stream, I get no sound with my patch above applied (as there's nothing to fall back to). For example, the Amaze (Lossless-Atmos) file listed here https://thedigitaltheater.com/dolby-trailers/ . However, this file does play sound without my patch, as Jellyfin successfully transcodes to AAC (and doesn't attempt transcoding the video like my example above, allowing direct streaming).

That said, I suspect that TrueHD streams that do contain a fallback are far more common in the wild than this Dolby trailer, given TrueHD is an optional Blu Ray format and so any TrueHD Blu Rays must also contain a DD fallback track.

At this point, I don't know what to do. On the one hand, setting supportsTrueHd: true is the only way I currently have to play some of my files. That said, it seems to be an issue with Jellyfin wanting to transcode both the TrueHD audio and HEVC video, even though the HEVC video is capable of being played on my TV.

On the other hand, I don't know if the DD AC-3 fallback is actually preferable to TrueHD->AAC transcoding. A quick google suggests AAC is the better format, but not needing to transcode at all might be preferable.

So to summarise:

  • Why was HEVC being transcoded when TrueHD needed to be transcoded, and why does HEVC not need to be transcoded when TrueHD is not transcoded (due to my patch)?
  • Is Jellyfin-WebOS doing the optimal thing by wanting to transcode TrueHD->AAC, or should it send the TrueHD audio to the TV for the TV to handle the fallback to DD AC-3 (per my patch).
  • Is there any way I can change my profile to force directplay of TrueHD without resorting to code changes like my patch above? I looked at the DLNA Profiles but didn't understand them, plus their name suggests they only apply to DLNA and I'm using the app.
@Mchar7
Copy link

Mchar7 commented Oct 19, 2021

Can confirm that TrueHD has never worked on my CX either in the webOS app, but the behaviour is somewhat different for me.

For me, Jellyfin makes no attempt to transcode and says that the video is playing fine with direct play.

If there is an embedded DD+ track, the player UI shows that the TrueHD track is playing, but it plays the DD+ one instead. If I manually choose to play the DD+ track, Jellyfin seems to try to play the next audio track (if there's a commentary or another language, that plays) while saying it is playing the DD+ track. If the DD+ track is selected and there is no other track after it, nothing plays at all.

I tried the lossless Dolby Amaze track that @CloudStu suggested that only has TrueHD (no embedded DD+ track) and that was silent (while still showing up as direct playing in the Jellyfin dashboard).

Casting videos from Windows to my TV makes them play just fine.

@anthonylavado
Copy link
Member

Why was HEVC being transcoded when TrueHD needed to be transcoded, and why does HEVC not need to be transcoded when TrueHD is not transcoded (due to my patch)?

I have recently learned that the server takes an "all or nothing" approach with Direct Play profiles. There's a PR in place that we hope to add for 10.8 that will make this more flexible:
jellyfin/jellyfin#6454

Is Jellyfin-WebOS doing the optimal thing by wanting to transcode TrueHD->AAC, or should it send the TrueHD audio to the TV for the TV to handle the fallback to DD AC-3 (per my patch).

I would assume that if the model TV supports it, we should send the correct audio stream through. We recently had to add DTS transcoding support (since the decoder is removed in 2020+ models), and that's one of the few cases where I can think of it being desirable. Otherwise, we want to avoid transcoding as much as possible, which makes it easier for lower power devices to be servers.

If it's not already set, we might need to add the TrueHD flag not just here, but in the web app as well. Perhaps that's why it was just sending out the fallback stream.

Is there any way I can change my profile to force directplay of TrueHD without resorting to code changes like my patch above? I looked at the DLNA Profiles but didn't understand them, plus their name suggests they only apply to DLNA and I'm using the app.

It's likely the web settings, like what we had to change for DTS.

@anthonylavado
Copy link
Member

@vamsikrishna71
Copy link

How to build IPK? after this code edit in webos IDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants