jellyfin / jellyfin-web

Web Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.31k stars 1.23k forks source link

[10.7] Videos with odd number of audio channels not playing on browsers and other devices #2249

Closed TheNamelessWonderer closed 3 years ago

TheNamelessWonderer commented 3 years ago

Describe The Bug Certain files will not play in Firefox.

Steps To Reproduce

  1. Update to 10.7 unstable
  2. Click on the movie to play it
  3. Open browser console
  4. See error

Expected Behavior

The file should play without any errors. Logs The error is: HLS Error: Type: mediaError Details: bufferAppendingError Fatal: false followed by Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable

Screenshots

image

System (please complete the following information):

Additional Context

The file does transcode in FFMPEG correctly but the browser won't load the file. It also plays in macOS Safari but at a very slow speed and with lots of stuttering. Other files play without any errors at all on both Firefox and macOS Safari.

TheNamelessWonderer commented 3 years ago

The file also won't play on iPadOS Safari or on iOS 14.3 in both Safari and the Jellyfin Mobile app but seeing as they have no console I can't see the error message.

Artiume commented 3 years ago

Does ffmpeg transcode it to 8bit or does it maintain 10bit depth?

TheNamelessWonderer commented 3 years ago

This is what it is using:

-map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 libx264 -pix_fmt yuv420p -preset veryfast -crf 23 -maxrate 8755223 -bufsize 17510446 -profile:v:0 high -level 41 -x264opts:0 subme=0:me_r
ange=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none  -force_key_frames:0 "expr:gte(t,0+n_forced*3)" -vf "scale=trunc(min(max(iw\,ih*dar)\,min(1920\,1080*dar))/2)*2:trunc(min(max(iw/dar\,ih)\,min(1920/dar\,1080))/2)*2" -sta
rt_at_zero -vsync -1 -codec:a:0 aac -ac 3 -ab 384000 -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 0 -hls_segment_filename "/Users/user/.loca
l/share/jellyfin/transcodes/f076e7946c5d27f17638e7f7bfe5c904%d.ts" -hls_playlist_type vod -hls_list_size 0 -y "/Users/user/.local/share/jellyfin/transcodes/f076e7946c5d27f17638e7f7bfe5c904.m3u8"
nyanmisaka commented 3 years ago

Can you set the max audio channels to stereo in playback settings and try again?

TheNamelessWonderer commented 3 years ago

Yep that fixes it on firefox!

nyanmisaka commented 3 years ago

Seems that Apple doesn't like odd number of channels.

TheNamelessWonderer commented 3 years ago

I'm using firefox on Linux which also has the issue. However setting it to stereo has also fixed it on iPadOS and iOS running 14.3!

nyanmisaka commented 3 years ago

We may need to avoid transcoding audio to odd number of channels.

BTW can you try to enable the fMP4-HLS option on the iPad so that FLAC 3ch can be remuxed?

nyanmisaka commented 3 years ago

At the bottom of the audio channel page. Prefer fMP4-HLS Media Container

I know that FLAC 2ch and 5.1ch can work normally on iPad.

TheNamelessWonderer commented 3 years ago

Setting audio channels back to auto and enabling fMP4-HLS video doesn't play. Setting it to Stereo and fMP4-HLS video does play correctly although it says the audio codec is AAC not FLAC.

nyanmisaka commented 3 years ago

Can you set a bitrate limit as large as possible?

And refresh the metadata of this media to get the bitrate info of audio track?

TheNamelessWonderer commented 3 years ago

At max bitrate and stereo it is still transcoded to AAC on the iPad.

nyanmisaka commented 3 years ago

The lack of bitrate information for this FLAC audio track led to audio transcoding.

TheNamelessWonderer commented 3 years ago

Unfortunately every episode is missing bitrate information it seems.

nyanmisaka commented 3 years ago

Search for missing metadata can be helpful here. I have added better bitrate probing for FLAC in 10.7.

TheNamelessWonderer commented 3 years ago

I have tried that but it is still missing.

TheNamelessWonderer commented 3 years ago

Scrap that it has found the bitrate!

nyanmisaka commented 3 years ago

So is remux FLAC 3ch feasible?

TheNamelessWonderer commented 3 years ago

Yes it is. On stereo it still transcodes to AAC but if you set it back to auto it directly plays FLAC.

TheNamelessWonderer commented 3 years ago

However it doesn't solve the Firefox issue on Linux. It still requires Stereo.

Artiume commented 3 years ago

when you direct play the flac, is the video broken?

TheNamelessWonderer commented 3 years ago

On the iPad the video works fine. On Firefox the video doesn’t play with the error above.

nyanmisaka commented 3 years ago

Firefox with hls.js doesn't support FLAC.

We should disable transcoding to AAC 3ch.

TheNamelessWonderer commented 3 years ago

Does FLAC music not play using hls.js?

nyanmisaka commented 3 years ago

Nope. Remuxing FLAC only works in fMP4-HLS on Safari.

TheNamelessWonderer commented 3 years ago

Another observation is that if fMP4-HLS is off and audio is set to auto then it fails to play on Safari. As this is off by default for most users will encounter this issue.

TheNamelessWonderer commented 3 years ago

Also fMP4-HLS causes it to transcode the video to HEVC with FLAC audio. Transcoding to HEVC from H264 uses far more processing power than FLAC to AAC. Can it not direct play the video is H264 with FLAC? Both work natively in Safari.

nyanmisaka commented 3 years ago

You can disable HEVC encoding in dashboard.

nyanmisaka commented 3 years ago

H264 High10 profile is not supported by iOS/iPadOS devices. Not sure if it's supported on MacOS.

TheNamelessWonderer commented 3 years ago

Oh yes thank you! Ah I forgot it was High 10. Is fMP4-HLS required to play FLAC with 3 channels?

nyanmisaka commented 3 years ago

Not sure but I think transcoding to odd number of channels will cause this issue.

TheNamelessWonderer commented 3 years ago

Indeed. It seems to affect Safari and Firefox but I haven't tested Chrome as I don't have it installed.

TheNamelessWonderer commented 3 years ago

Also I'd like to mention that at least Firefox doesn't have this issue on 10.6.4. Safari on iPhone won't play it but iPad do play it on 10.6.4.

Artiume commented 3 years ago

as in firefox successfully played 3ch audio or the transcoding wasn't messed up?

TheNamelessWonderer commented 3 years ago

Well not sure but it is transcoded to MP3 but the number of channels aren't listed. It seems 10.7 transcodes to AAC now instead of MP3.

Artiume commented 3 years ago

yeah, that was a bug we finally fixed :P, and it's uncovered new bugs haha

TheNamelessWonderer commented 3 years ago

That's fine! Hopefully it isn't too challenging to fix!

Artiume commented 3 years ago

normal mp3's max channels is 2ch so it was never a concern. I just think we need to add to the browser profiles that they support only 2ch

TheNamelessWonderer commented 3 years ago

I see profiles are changed in Jellyfin not Jellyfin-web so feel free to move this if it is in the wrong location!

TheNamelessWonderer commented 3 years ago

The fix seems to have created another bug. I can open a new issue if you want. It is not allowing FLAC 3 channel to be played if the video is transcoded it seems FAAF15B1-6D26-4703-891A-50E009D1D163