jellyfin / jellyfin-tizen

Jellyfin Samsung TV Client
https://jellyfin.org
914 stars 71 forks source link

No audio for OPUS codec #130

Open avc1657 opened 2 years ago

avc1657 commented 2 years ago

Hi, my Samsung TV (UN43RU7100, it's a 2019 model) is direct playing files containing OPUS audio but there's no sound. It seems that OPUS is not a compatible audio codec in the case of my tv. How do I make so Jelly transcodes audio in this case? Both video codec and sub format are compatible, just the audio that is direct playing but there's no sound. I dont have any problems with codecs like aac, mp3, ac3, e-ac3 though.

Idk the exact version of jellyfin im running on the tv but what i know is that i compiled it from source at the beginning of june-2022.

dmitrylyzo commented 2 years ago

It is supposed to be checked here https://github.com/jellyfin/jellyfin-web/blob/e30ad314b146a1b0f821d9e0245024890e4083d2/src/scripts/browserDeviceProfile.js#L125-L131 However, canPlayType may give false results.

You can add if (browser.tizen) return false; to exclude OPUS, but your TV seems to support it 🤷‍♂️ https://developer.samsung.com/smarttv/develop/specifications/media-specifications/2019-tv-video-specifications.html

Usually, if the audio codec is not supported, the TV refuses to play video at all.

Could you try OPUS video with built-in player (via USB)?

avc1657 commented 2 years ago

I just tried to play the exact same video through USB with the built-in player on the tv. It worked as expected now: OPUS audio is playing normally. Back to Jellyfin tizen app, though, both directly playing the video or choosing an unsupported sub so jellyfin transcodes the video, OPUS codec is not working, the TV plays it but there's no audio, just the video and the subtitles. On my PC i also checked the folder in which jellyfin storages transcoded media and there was audio. OPUS is also working normally through browsers on my pc (edge, brave and chromium).

This is the playback info from the TV:


Playback Info

Player: Html Video Player
Play method: Transcoding
Protocol: http
Stream type: Video

Video Info

Video resolution: 1920x1080
Dropped frames: 0
Corrupted frames: 0

Transcoding Info

Video codec: H264
Audio codec: OPUS (direct)
Audio channels: 2
Bitrate: 7.2 Mbps
Transcoding progress: 13.3%
Transcoding framerate: 291 fps
Reason for transcoding: The subtitle codec is not supported

Original Media Info

Container: mkv
Size: 349.8 MiB
Bitrate: 2.2 Mbps
Video codec: HEVC Main 10
Video bitrate: 2.1 Mbps
Video range: SDR
Audio codec: OPUS
Audio bitrate: 108 kbps
Audio channels: 2
Audio sample rate: 48000 Hz
avc1657 commented 2 years ago

Do i just make the following modification then recompile jellyfin? -> "if (browser.tizen) return false;" I mean, technically my tv supports OPUS, right? Is there another solution?

dmitrylyzo commented 2 years ago

Do i just make the following modification then recompile jellyfin? -> "if (browser.tizen) return false;"

Yes. This way you will force OPUS to be transcoded. But that's the last option I would use.

I mean, technically my tv supports OPUS, right? Is there another solution?

I noticed that it is transcoding (because of the subtitles). Try making it DirectPlay - disable subtitles or don't burn in them.

avc1657 commented 2 years ago

If i choose a subtitle format like srt, which doesnt need transcoding, OPUS audio suddenly starts to work again '-'. But unfortunately that's not a solution for my case. For some reason my TV is messing up with fonts, even though jellyfin properly detects the language of the sub file. I mostly watch anime with japanese subs and for some reason for half of the characters the TV chooses a japanese font and for the rest the tv chooses a chinese font. So the subtitle becomes a mix of chinese and japanese fonts, which is pretty ugly and confuses me. Even the Jellyfin UI is like that, half japanese and half chinese. Inside apps like youtube or netflix, only the japanese font is used, i dont get the problem. Anyways, very unpleasant subtitle bug. Actually i dont even now if that's a TV problem or a jellyfin problem, btw the same mixed chinese and japanese happens with emby and plex. When i set to always burn all subtitles i dont get the mixed sub font problem.

Yesterday i saw in another issue telling that i could create a DLNA profile to tell the TV to transcode OPUS, but cant get it to work. Maybe i did something wrong or maybe that's actually not a solution and i got it wrong. It seems that my last hope is the "if (browser.tizen) return false;"

dmitrylyzo commented 2 years ago

If i choose a subtitle format like srt, which doesnt need transcoding, OPUS audio suddenly starts to work again '-'.

:+1: So problem with OPUS in TS container. What Jellyfin server and FFMPEG versions?

So the subtitle becomes a mix of chinese and japanese fonts, which is pretty ugly and confuses me.

I think there was a fix (https://github.com/jellyfin/jellyfin-web/pull/3642), but it has no effect, since we are using the system fonts in the app.

What subtitles format have you tried before (the ones that require burning-in)? SSA/ASS supports embedded and fallback fonts (https://github.com/jellyfin/jellyfin-web/pull/1636).

It seems that my last hope is the "if (browser.tizen) return false;"

Then it is better to remove this block: https://github.com/jellyfin/jellyfin-web/blob/d73e438ab2cc00d4ec0ab6eef489406f589ed9d8/src/scripts/browserDeviceProfile.js#L483-L485 According to the docs, OPUS in TS is supported, but I haven't tested this.

avc1657 commented 2 years ago

What Jellyfin server and FFMPEG versions?

C:\Program Files\Jellyfin\Server\ffmpeg.exe <- i just use the ffmpeg version jellyfin already came with. On "Devices" it says jellyfin for tizen 0.1.0, i compiled it from source at the beginning of june-2022. As for my browsers on my pc, it says jellyfin web 10.7.6

What subtitles format have you tried before (the ones that require burning-in)? SSA/ASS supports embedded and fallback fonts (jellyfin/jellyfin-web#1636).

Before the ones that require burn-in i tried .SRT subs. But 90% of the time i use SSA/ASS. When i watch on my pc, though, 99,99% of the time i use .srt japanese subs since there's no font problem. But when i found out about this font problem on the tv side, i just wrote a ffmpeg command to convert .ja.srt to .ja.ass and that's it.

So if the fix (https://github.com/jellyfin/jellyfin-web/pull/3642) will not work then i'll not try it.

Then it is better to remove this block: https://github.com/jellyfin/jellyfin-web/blob/d73e438ab2cc00d4ec0ab6eef489406f589ed9d8/src/scripts/browserDeviceProfile.js#L483-L485

Do i just delete the 3 highlighted lines then recompile, deploy on the tv and see if OPUS now works when transcoding? Wouldnt be easier just to change the transcoding container from TS to any other? Is that possible? Maybe that would fix the problem, idk.

dmitrylyzo commented 2 years ago

10.7.6

Currently, I can't say that jf-web master 100% compatible with 10.7.x. There is 10.8.3 with ffmpeg5. So maybe you can make a backup of your current setup and give it a try.

Before the ones that require burn-in i tried .SRT subs. But 90% of the time i use SSA/ASS. When i watch on my pc, though, 99,99% of the time i use .srt japanese subs since there's no font problem. But when i found out about this font problem on the tv side, i just wrote a ffmpeg command to convert .ja.srt to .ja.ass and that's it.

So SSA/ASS have the mentioned charset bug, right? Then maybe fallback fonts could help.

So if the fix (jellyfin/jellyfin-web#3642) will not work then i'll not try it.

It should be in your build - it was back-merged in May. It has no effect on SSA/ASS though.

Do i just delete the 3 highlighted lines then recompile, deploy on the tv and see if OPUS now works when transcoding?

Yes. By removing those lines you make the TV not support OPUS in TS.

Wouldnt be easier just to change the transcoding container from TS to any other? Is that possible? Maybe that would fix the problem, idk.

The server chooses the Streaming transcoding profile that better matches the input codecs. They take precedence in order (at least, they should). 10.8 does it better/correct, but MKV stopped playing in browsers (Chrome can play most MKV because it is ~WebM, but technically it only supports WebM).

For example, here is the generated test for Tizen 4: https://github.com/jellyfin/jellyfin/blob/63d943aab92a4b5f69e625a269eb830bcbfb4d22/tests/Jellyfin.Model.Tests/Test%20Data/DeviceProfile-Tizen4-4K-5.1.json#L334-L387 There are also Static profiles, but the app (web) doesn't use them, iirc.

Changing the priority (order) is probably a good idea - need to do it in jf-web. Not only containers but also audio/video codecs. Or even fully customizable profile: enabling/disabling/reordering containers/codecs - an idea that comes up from time to time. Currently, only fMP4 can be turned on/off (with current player, it didn't work on Tizen 4, iirc).

avc1657 commented 2 years ago

Do i just delete the 3 highlighted lines then recompile, deploy on the tv and see if OPUS now works when transcoding?

Yes. By removing those lines you make the TV not support OPUS in TS.

I did that, but now Jellyfin wont play any videos. It gets stuck on loading. I mean ALL videos, even if the audio codec is not OPUS.

EDIT: nevermind, fixed. Btw the tv now is transcoding OPUS, so it's working now. Thanks

avc1657 commented 2 years ago

So SSA/ASS have the mentioned charset bug, right? Then maybe fallback fonts could help.

No, it's for srt subs, not ssa/ass. It also happens when playing media from my USB drive. The tv cant handle japanese subtitles properly so it mixes chinese font with japanese font.

oysstu commented 1 year ago

I've also observed this on a 2017 model. OPUS audio works fine when direct playing, but does not work when turning on transcoding (due to ASS subtitles not working).

kirill9617 commented 1 year ago

Have similar problem on 2022 TV. When playing file with OPUS audio from USB is OK. But when playing from Jellyfin (Direct Play) audio is crackling or missing at all.

m00nwtchr commented 1 year ago

Having the same problem as @kirill9617 , audio cutting out with Direct Play

EDIT: Huh, oddly enough, the same thing happens when playing from USB, I guess OPUS support is just broken on this tv. (Unless it has something to do with the av1 video codec, but I don't see how)

An option to force transcoding would be nice

neon-dev commented 11 months ago

It also happens when playing media from my USB drive.

I can confirm this is also happening on my 2021 TV (mkv container, with and without subtitles). Direct play or USB both produce either no sound or sometimes very faint sound, turning into crackling few seconds in. You need to turn up the volume to notice this, otherwise it can be misinterpreted as no sound. The only thing I did not test was if webm containers behave differently.

I also tried Jellyfin on my Fire TV Stick 4k and it would play the media just fine, but checking the server dashboard revealed that audio was being transcoded (not sure why though, since it supports Opus).

So it looks like Samsung is at fault here and the only known solution at the moment is to force audio transcoding. Not sure if anyone has reported this issue to Samsung yet.

An option to force transcoding would be nice

I'd be happy with any solution that does not require users to custom compile the app. If we can confirm that there's a general problem with Opus on <=2022 models, I'd suggest removing Opus support by default for affected model years.

neon-dev commented 11 months ago

It also happens when playing media from my USB drive.

I can confirm this is also happening on my 2021 TV (mkv container, with and without subtitles).

I retested the same media in WebM and MP4 containers instead of MKV and both played without issues.

Can the server remux MKV to MP4 on-the-fly for Tizen based devices if an Opus stream is selected? This would be the best solution yet.