jellyfin / jellyfin-androidtv

Android TV Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.86k stars 488 forks source link

JF reset audio/subtitle track on seek #1403

Closed DemirG closed 2 years ago

DemirG commented 2 years ago

Describe the bug

When playing a video file with subtitles and multiple audio tracks, for example anime. I choose at the start of the video japanese as audio and English as subtitles.

Default for the video file is no subtitles and English as audio.

Changeing works fine. But when I use the seek bar and go forward 30, 60, 180seconds or whatever, JF will reset to default audio. It will even show that it has gone back to default audio. Subtitles will not show but will still be set at English.

Logs

No response

FFmpeg logs

No response

Media info of the file

No response

Application version

0.13.0-beta1

Device information

Sony Android TV

Android version

Android 10

Jellyfin server version

10.7.7

mueslimak3r commented 2 years ago

Do you have "preferred video player" set to auto, libVLC, or exoplayer?

And can you check each and see which it happens with?

DemirG commented 2 years ago

Do you have "preferred video player" set to auto, libVLC, or exoplayer?

And can you check each and see which it happens with?

I have it set to auto.

The same thing happens with libvlc.

With Exoplayer it starts with default values. Player crashes if I change audio/subtitle. Player also crashes if I try to seek forward. Or more correctly it doesn't crash but hangs for 30-60 seconds and then starts playing with default values.

I have had som crashes with libvlc though. All crashes have been sent to developers. Maybe 20 of them so far.

The file is a 720p, x265 with aac audio.

DemirG commented 2 years ago

Also the crashes with auto/libvlc seems to be when I go forward in the video without changing audio, just leave it at default. If I change it to secondary audio then JF doesn't crash. But this is maybe a separate bug?

mueslimak3r commented 2 years ago

Also the crashes with auto/libvlc seems to be when I go forward in the video without changing audio, just leave it at default. If I change it to secondary audio then JF doesn't crash. But this is maybe a separate bug?

I noticed the crashes too with libVLC after messing around with switching audio tracks and then seeking and/or backing out of the video and resuming it. I'm working on the audio tracks first.

was there a prior version of the app when it didn't crash and/or reset?

DemirG commented 2 years ago

Also the crashes with auto/libvlc seems to be when I go forward in the video without changing audio, just leave it at default. If I change it to secondary audio then JF doesn't crash. But this is maybe a separate bug?

I noticed the crashes too with libVLC after messing around with switching audio tracks and then seeking and/or backing out of the video and resuming it. I'm working on the audio tracks first.

was there a prior version of the app when it didn't crash and/or reset?

Thanks, please say if more information is needed and I will provide.

The last full release v0.12.3 worked fine and dandy with these files.

mueslimak3r commented 2 years ago

Thanks, please say if more information is needed and I will provide.

Can you provide the media info from something that causes exoplayer to crash when you switch audio tracks? The full info from the details page in jellyfin.

If you can, install the latest debug build and collect logs with adb logcat. For now just record logs of changing tracks in exoplayer. The debug build in the releases page won't work. Use this patched version - it's in the build-artifacts file: https://github.com/jellyfin/jellyfin-androidtv/actions/runs/1769203392

I think I've fixed the tracks resetting to default in libVLC.

mueslimak3r commented 2 years ago

Can you give this debug build a try instead and see if it fixes the audio track related issues. It doesn't have anything for subtitles: https://github.com/jellyfin/jellyfin-androidtv/actions/runs/1781539958

It's from the draft PR above. If you go there I listed some steps for testing too. If there are any additional steps/things that resulted in crashes/errors for you I'll add those.

DemirG commented 2 years ago

e

Hi, I don't know how to use logcat. I'm guessing I have to sideload the debug version? Can try it later during the day. Did not see instructions in the link..?

Do I need to remove my current JF setup?

DemirG commented 2 years ago

Can you give this debug build a try instead and see if it fixes the audio track related issues. It doesn't have anything for subtitles: https://github.com/jellyfin/jellyfin-androidtv/actions/runs/1781539958

It's from the draft PR above. If you go there I listed some steps for testing too. If there are any additional steps/things that resulted in crashes/errors for you I'll add those.

OK, so I installed the debug apk and tried the following:

1a. Exoplayer -> change to second audio -> Server (harddrives) starts working like crazy. JF stops responding (player error encountered, will retry). Player reverts to default audio. 2a. Exoplayer -> change of subtitle -> Server (harddrives) starts working like crazy. JF stops responding (player error encountered, will retry). Player reverts to default subtitle, in this case no subtitle at all. 3a. Exoplayer -> use default audio and default (no) subtitle -> seek works normally. Harddrives are quiet. 4.a Exoplayer -> if I start a file and move forward as soon as I can JF will a) crash in the first file and b) work fine for the second file below. 5a. Exoplayer -> Seems to be transcoding(?) at least the second file. Everything slows down to 10fps. First file plays fine as per #3a.

1b. libVLC -> change to second audio -> Audio stays and works as intended. 2b. libVLC -> change of subtitle -> subtitle works fine at start. If I move forward in the episode the subtitle will still be checked in the CC settings but the player will revert to default (no) subtitles. 3b. libVLC -> use default audio and default (no) subtitle -> seek works normally. Harddrives are quiet. 4b. libVLC -> if I start a file and move forward as soon as I can JF will a) crash in the first file and b) work fine for the second file below.

I have max bitrate set to auto, and tried these scenarios with both direct audio and downmix to stereo. Same result.

File 1 image

File 2 image

mueslimak3r commented 2 years ago

Thanks for your detailed explanation. That helps a lot. It looks like the audio switching in libVLC is working now.

Using this build, is anything new broken compared to 0.13-beta?

You could try going into your server's dashboard, to playback settings, and uncheck "allow encoding in HEVC", and see if that improves the bad fps and server being loud. If that does improve things, it may be best to store your media in h264.

Can you provide:

DemirG commented 2 years ago

Thanks for your detailed explanation. That helps a lot. It looks like the audio switching in libVLC is working now.

Using this build, is anything new broken compared to 0.13-beta?

You could try going into your server's dashboard, to playback settings, and uncheck "allow encoding in HEVC", and see if that improves the bad fps and server being loud. If that does improve things, it may be best to store your media in h264.

Can you provide:

  • Your server's CPU, GPU
  • A screenshot of the "playback" settings in your server dashboard, just the section at the top with all the stuff about decoding and encoding
  • ffmpeg logs
  • server logs would be nice too, but make sure you scrub any personal info first

Sure, no problem.

I have not noticed other problems then those mentioned. I tried to uncheck the "allow encoding in HEVC" option, but it didn't affect the performance at all. I also tried this morning to activate Intel Quicksyns but I didn't notice a difference. Don't know if it's supported though.

Server is a Synology DS220+, with expanded memory (2GB+4GB).

image

JF log: https://pastebin.com/7EdrfVEe Transcode log: https://pastebin.com/J7GN8iw8

Not quite sure which server logs you are referring to? Do you mean the docker containers log?

Edit; I think I had Intel Quicksyns activated in those logs, here are new ones:

Transcode log: https://pastebin.com/p1zVdrt2 JF log: https://pastebin.com/pRZDR0rz

mueslimak3r commented 2 years ago

both ffmpeg logs indicate the server trying to use QSV and failing. This might explain some of the exoplayer issues, assuming you send the correct logs. This is the error from ffmpeg: Error creating a QSV device qsv hwaccel requested for input stream #0:0, but cannot be initialized. [hevc_qsv @ 0x56269ffcf040] Error initializing the MFX video decoder: invalid handle (-6) Error while decoding stream #0:0: Invalid argument

I do see there is a playback session that doesn't use QSV though. Here's the timestamp: [2022-02-03 09:00:36.832 +00:00] Can you find the ffmpeg logs for this one?

mueslimak3r commented 2 years ago

can you try this build?

https://github.com/jellyfin/jellyfin-androidtv/actions/runs/1804190319

DemirG commented 2 years ago

both ffmpeg logs indicate the server trying to use QSV and failing. This might explain some of the exoplayer issues, assuming you send the correct logs. This is the error from ffmpeg: Error creating a QSV device qsv hwaccel requested for input stream #0:0, but cannot be initialized. [hevc_qsv @ 0x56269ffcf040] Error initializing the MFX video decoder: invalid handle (-6) Error while decoding stream #0:0: Invalid argument

I do see there is a playback session that doesn't use QSV though. Here's the timestamp: [2022-02-03 09:00:36.832 +00:00] Can you find the ffmpeg logs for this one?

I don't have any logs from the 3rd of february left. Sorry didn't have time to check. Here is a new from yesterday.

JF 6/2 log: https://pastebin.com/0bm7vSZF

1a. Exoplayer -> change to second audio -> works OK 2a. Exoplayer -> change of subtitle -> works OK 3a. Exoplayer -> use default audio and default (no) subtitle -> seek works normally. Harddrives are quiet. 4.a Exoplayer -> if I start a file and move forward as soon as I can JF works fine except (see 5a below). 5a. Exoplayer -> Seems to be transcoding(?) at least the second file. Everything slows down to 10fps. First file plays fine.

1b. libVLC -> change to second audio -> Audio stays and works as intended. 2b. libVLC -> change of subtitle -> subtitle works fine at start. If I move forward in the episode the subtitle will still be checked in the CC settings but the player will revert to default (no) subtitles. 3b. libVLC -> use default audio and default (no) subtitle -> seek works normally. Harddrives are quiet. 4b. libVLC -> if I start a file and move forward as soon as I can JF works OK7

Here are some of the logs from todays testing with new build:

JF 7/2 log: https://pastebin.com/RaL5FAyj

transcode logs: https://pastebin.com/h2PcntHj https://pastebin.com/pnxZDsXP https://pastebin.com/C55h2drF https://pastebin.com/cUBsh33C https://pastebin.com/8YBXbmAk https://pastebin.com/STihc5xQ https://pastebin.com/MP5xv3Rz

TL;DR works much better. I also tried setting it to auto choose player, downmix to stereo and max bitrate. JF chose the best player so that the file plays as intended.

mueslimak3r commented 2 years ago

2b. libVLC -> change of subtitle -> subtitle works fine at start. If I move forward in the episode the subtitle will still be checked in the CC settings but the player will revert to default (no) subtitles.

It sounds like 2b is the only remaining problem that's relevant to this issue

To have a different issue addressed, like 5a, please open a new issue and fill out the template

5a. Exoplayer -> Seems to be transcoding(?) at least the second file. Everything slows down to 10fps. First file plays fine.

DemirG commented 2 years ago

2b. libVLC -> change of subtitle -> subtitle works fine at start. If I move forward in the episode the subtitle will still be checked in the CC settings but the player will revert to default (no) subtitles.

It sounds like 2b is the only remaining problem that's relevant to this issue

To have a different issue addressed, like 5a, please open a new issue and fill out the template

5a. Exoplayer -> Seems to be transcoding(?) at least the second file. Everything slows down to 10fps. First file plays fine.

Sure! I'll do that later this week. I saw that the fixes are implemented into the beta, nice! Then I can stop using the debug version 😂 Thank you for the great work!

mueslimak3r commented 2 years ago

I think your issue 2b is fixed by PR #1465

2b. libVLC -> change of subtitle -> subtitle works fine at start. If I move forward in the episode the subtitle will still be checked in the CC settings but the player will revert to default (no) subtitles.

DemirG commented 2 years ago

I think your issue 2b is fixed by PR #1465

2b. libVLC -> change of subtitle -> subtitle works fine at start. If I move forward in the episode the subtitle will still be checked in the CC settings but the player will revert to default (no) subtitles.

Subtitles work great now with libvlc. They don't reset. This issue can be closed. When I have time I will check 5a more in depth and open new issue.

Thank you!