jellyfin / jellyfin-androidtv

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

Always Transcoding when not needed... #1874

Closed ManuLinares closed 1 year ago

ManuLinares commented 2 years ago

Describe the bug

  1. Play "h264, aac2.0" movie that always worked in direct mode on my firestick.
  2. Check Dashboard, and see that it is transcoding: Reason for transcoding: There was an error starting direct playback

Logs

https://pastebin.com/38Hc29GF

FFmpeg logs

https://pastebin.com/bzUp1ZiV

Media info of the file

ffprobe version 5.0.1 Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12.1.0 (GCC)
  configuration: --prefix=/usr --extra-cflags=-I/opt/cuda/include --extra-ldflags=-L/opt/cuda/lib64 --enable-lto --disable-rpath --enable-gpl --enable-version3 --enable-nonfree --enable-shared --disable-static --disable-stripping --enable-gray --enable-alsa --enable-avisynth --enable-bzlib --enable-chromaprint --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-iconv --enable-ladspa --enable-libaom --enable-libaribb24 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libfdk-aac --enable-libflite --enable-fontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libklvanc --enable-libkvazaar --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libopencv --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --disable-libopenvino --enable-libopus --enable-libplacebo --enable-libpulse --enable-librabbitmq --enable-librav1e --enable-librist --enable-librsvg --enable-librubberband --enable-librtmp --enable-libshine --enable-libsmbclient --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvthevc --enable-libsvtav1 --disable-libtensorflow --enable-libtesseract --enable-libtheora --disable-libtls --enable-libtwolame --enable-libuavs3d --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libsvtvp9 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxavs2 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-lzma --enable-decklink --disable-mbedtls --enable-libmysofa --enable-openal --enable-opencl --enable-opengl --disable-openssl --enable-pocketsphinx --enable-sndio --enable-sdl2 --enable-vapoursynth --enable-vulkan --enable-xlib --enable-zlib --enable-amf --enable-cuda-nvcc --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-libdrm --enable-libmfx --enable-libnpp --enable-nvdec --enable-nvenc --enable-omx --enable-rkmpp --enable-v4l2-m2m --enable-vaapi --enable-vdpau
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, matroska,webm, from 'What.We.Do.In.The.Shadows.S03E03.720p.AMZN.WEBRip.x264-GalaxyTV.mkv':
  Metadata:
    title           : What.We.Do.In.The.Shadows.S03E03.720p.AMZN.WEBRip.x264-GalaxyTV
    COMMENT         : GalaxyTV - small excellence!
    ENCODER         : Lavf58.20.100
  Duration: 00:26:36.84, start: 0.000000, bitrate: 969 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn (default)
    Metadata:
      title           : GalaxyTV - small excellence!
      BPS-eng         : 8941575
      DURATION-eng    : 00:26:36.762000000
      NUMBER_OF_FRAMES-eng: 38284
      NUMBER_OF_BYTES-eng: 1784695975
      _STATISTICS_WRITING_APP-eng: mkvmerge v54.0.0 ('F Maj Pixie') 64-bit
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      ENCODER         : Lavc58.35.100 libx264
      DURATION        : 00:26:36.805000000
  Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : GalaxyTV - small excellence!
      BPS-eng         : 640000
      DURATION-eng    : 00:26:36.800000000
      NUMBER_OF_FRAMES-eng: 49900
      NUMBER_OF_BYTES-eng: 127744000
      _STATISTICS_WRITING_APP-eng: mkvmerge v54.0.0 ('F Maj Pixie') 64-bit
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      ENCODER         : Lavc58.35.100 libfdk_aac
      DURATION        : 00:26:36.843000000
  Stream #0:2(eng): Subtitle: subrip (default)
    Metadata:
      title           : GalaxyTV - small excellence!
      BPS-eng         : 108
      DURATION-eng    : 00:26:25.888000000
      NUMBER_OF_FRAMES-eng: 678
      NUMBER_OF_BYTES-eng: 21557
      _STATISTICS_WRITING_APP-eng: mkvmerge v54.0.0 ('F Maj Pixie') 64-bit
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      ENCODER         : Lavc58.35.100 srt
      DURATION        : 00:26:27.367000000
  Stream #0:3(eng): Subtitle: subrip
    Metadata:
      title           : SDH
      BPS-eng         : 122
      DURATION-eng    : 00:26:25.888000000
      NUMBER_OF_FRAMES-eng: 729
      NUMBER_OF_BYTES-eng: 24316
      _STATISTICS_WRITING_APP-eng: mkvmerge v54.0.0 ('F Maj Pixie') 64-bit
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      ENCODER         : Lavc58.35.100 srt
      DURATION        : 00:26:27.367000000

Application version

Latest dev build

Device information

Firestick v1 AFTM

Android version

Fire OS 5

Jellyfin server version

10.8.1

sourpatched commented 2 years ago

I can see h264_nvenc in the logs. Did you check the Enable hardware decoding for h264 under playback in the dashboard? (/web/index.html#!/encodingsettings.html)

ManuLinares commented 2 years ago

I can see h264_nvenc in the logs. Did you check the Enable hardware decoding for h264 under playback in the dashboard? (/web/index.html#!/encodingsettings.html)

Of course I did.

https://imgur.com/hN6lApW.png hN6lApW

sourpatched commented 2 years ago

I would deselect enable hardware encoding,h264 and mpeg4

ManuLinares commented 2 years ago

I would deselect enable hardware encoding,h264 and mpeg4

I don't think you understand the issue, my firestick supports direct play for h264, so no transcoding is needed, but throws an error or something so asks the server for transcoding.

That the server uses h264 or h264_nvenc (cpu or hardware accelerated) is not the issue... I can enable or disable hardware transcoding and it transcodes the same you see.

sourpatched commented 2 years ago

Errors with Subtitles with the log you posted?

Doesn't firestick use Android? Jellyfin Android TV has a beta for 0.14.0 https://github.com/jellyfin/jellyfin-androidtv/releases/tag/v0.14.0-beta.2

ManuLinares commented 2 years ago

Errors with Subtitles with the log you posted?

No Doesn't firestick use Android? Jellyfin Android TV has a beta for 0.14.0 https://github.com/jellyfin/jellyfin-androidtv/releases/tag/v0.14.0-beta.2

Yes, that's what I'm using, trying latest beta and latest dev build.


I don't mean to be rude but your comments are all irrelevant.

ManuLinares commented 2 years ago

adb logcat: https://pastebin.com/cnKVZiw5

Relevant:

I/PlaybackController(19072): VLC would direct stream
I/PlaybackController(19072): Internal player would transcode
I/PlaybackController(19072): User preferred player is: EXOPLAYER
I/PlaybackController(19072): Will use internal player

Exoplayer should support direct stream for "h264/aac", Why is it detecting the stream as "would transcode"?

sourpatched commented 2 years ago

All device supports h264, My only suggestion would be to check your playback settings in jellyfin.

Andy2244 commented 2 years ago

RemoteClientBitrateLimit: 10 000 000 VideoBitrate=49 360 000

Not sure why the bitrate is set to 10MBit, do you by any chance have bitrate set to "Auto" ? If yes than its this issue: #1851 Just set it to max and retest.

sourpatched commented 2 years ago

@Andy2244 Have you tried the 0.14.0 beta?

ManuLinares commented 2 years ago

RemoteClientBitrateLimit: 10 000 000 VideoBitrate=49 360 000

Not sure why the bitrate is set to 10MBit, do you by any chance have bitrate set to "Auto" ? If yes than its this issue: #1851 Just set it to max and retest.

It's set to 100mbps in the android app, I saw that on the logs.

Andy2244 commented 2 years ago

can we get a streaminfo via: ffprobe -show_streams -i file.mkv

ManuLinares commented 2 years ago

can we get a streaminfo via: ffprobe -show_streams -i file.mkv

It's actually in the bug info at top

Andy2244 commented 2 years ago

It's actually in the bug info at top

not really, it only shows the stream summary not the details. I cant see what h264 profile is actually used?

ManuLinares commented 2 years ago

It's actually in the bug info at top

not really, it only shows the stream summary not the details. I cant see what h264 profile is actually used?

Here you go, https://pastebin.com/QhmaqzvY

I debug it further and found out "direct play" works on Exoplayer only when enabling the audio dolby and the other option in the tv app preferences. I don't know why because media file doesn't have a dolby or the other audio, it's standard aac stereo

Andy2244 commented 2 years ago

yeah i see the issue, its super weird. Specifically for the "AFTM" Gen1 device AC3 bitstreaming is disabled by default.

Than there is this check: if (DeviceUtils.is60() || userPreferences.getValue().get(UserPreferences.Companion.getAc3Enabled())) {

This checks SDK >= 23 or if AC3 is enabled, if this check fails it uses the BaseProfile() instead of the ExoPlayerProfile(), which in return will always transcode everything, since BaseProfile() has no DirectPlay settings. Thats also where the 10Mbit limit comes from via:

open class BaseProfile : DeviceProfile() {
    init {
        name = "AndroidTV"
        maxStreamingBitrate = 20_000_000 // 20 mbps
        maxStaticBitrate = 10_000_0000 // 10 mbps

@nielsvanvelzen i have no clue why this fallback exist and is tied to either SDK = 22 or AC3 settings? The amazon page states Gen1 has Ac3 support, so why does it explicitly disable AC3 bitstreaming via: var ac3Enabled = booleanPreference("pref_bitstream_ac3", !DeviceUtils.isFireTvStickGen1()) ? Yet it allows to enable the setting anyway via user?

I don't think the raw BaseProfile() should be used for any fire device? I also don't get why the BaseProfile() if used as a h264 fallback has no basic DirectPlay() settings? Like at least a minimal h264/L31 and AAC/AC3 setup or better just check for supported codecs via MediaCodecCapabilitiesTest() ?

PS: Kinda confusing, so my guess is, it's to solve some corner case or device bug?

Andy2244 commented 2 years ago

@ManuLinares can you test this version and report back if it stops transcoding and can play AAC and also test if AC3 5.1 bitstreaming works?

https://drive.google.com/file/d/14eqWdwZiRZ12l51b-f4fTJy8C5FRxKQk

ManuLinares commented 2 years ago

Your build: Exoplayer, H264, AAC2.0 direct play, working fine now, without any dolby or dts options enabled

Exoplayer, H264, AC3 5.1 not working (throws error and does not play) (with and without dolby and dts options enabled)

[2022-07-26 00:16:22.321 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "invitado". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2022-07-26 00:16:22.321 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: RemoteClientBitrateLimit: 10000000, RemoteIp: "192.168.200.149", IsInLocalNetwork: True
[2022-07-26 00:16:22.322 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="AndroidTV-libVLC", Path="/mnt/nasdata2/Library/Movies/Werewolves.Within (2021)/Werewolves.Within.2021.1080p.Bluray.DTS-HD.MA.5.1.X264-EVO.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) "media:/videos/c3f48880-6d8c-5ebe-39bd-933a905f4a45/stream.mkv?MediaSourceId=c3f488806d8c5ebe39bd933a905f4a45&Static=true&VideoCodec=h264&AudioCodec=ac3&AudioStreamIndex=1&api_key=<token>&Tag=1b27c5e4e4323d34d8caf3a27f6e1ebf"
[2022-07-26 00:16:24.404 -03:00] [INF] [100] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "invitado". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2022-07-26 00:16:24.404 -03:00] [INF] [100] Jellyfin.Api.Helpers.MediaInfoHelper: RemoteClientBitrateLimit: 10000000, RemoteIp: "192.168.200.149", IsInLocalNetwork: True
[2022-07-26 00:16:24.404 -03:00] [INF] [100] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="AndroidTV-ExoPlayer", Path="/mnt/nasdata2/Library/Movies/Werewolves.Within (2021)/Werewolves.Within.2021.1080p.Bluray.DTS-HD.MA.5.1.X264-EVO.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) "media:/videos/c3f48880-6d8c-5ebe-39bd-933a905f4a45/stream.mkv?MediaSourceId=c3f488806d8c5ebe39bd933a905f4a45&Static=true&VideoCodec=h264&AudioCodec=ac3&AudioStreamIndex=1&api_key=<token>&Tag=1b27c5e4e4323d34d8caf3a27f6e1ebf"
[2022-07-26 00:16:33.300 -03:00] [INF] [26] Emby.Server.Implementations.Session.SessionManager: Playback stopped reported by app "Android TV" "0.14.0-beta.2-fix.1" playing "Werewolves Within". Stopped at "0" ms
[2022-07-26 00:16:33.368 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "invitado". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2022-07-26 00:16:33.368 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: RemoteClientBitrateLimit: 10000000, RemoteIp: "192.168.200.149", IsInLocalNetwork: True
[2022-07-26 00:16:33.368 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="AndroidTV-libVLC", Path="/mnt/nasdata2/Library/Movies/Werewolves.Within (2021)/Werewolves.Within.2021.1080p.Bluray.DTS-HD.MA.5.1.X264-EVO.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) "media:/videos/c3f48880-6d8c-5ebe-39bd-933a905f4a45/stream.mkv?MediaSourceId=c3f488806d8c5ebe39bd933a905f4a45&Static=true&VideoCodec=h264&AudioCodec=ac3&AudioStreamIndex=1&api_key=<token>&Tag=1b27c5e4e4323d34d8caf3a27f6e1ebf"
[2022-07-26 00:16:33.669 -03:00] [INF] [97] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "invitado". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2022-07-26 00:16:33.669 -03:00] [INF] [97] Jellyfin.Api.Helpers.MediaInfoHelper: RemoteClientBitrateLimit: 10000000, RemoteIp: "192.168.200.149", IsInLocalNetwork: True
[2022-07-26 00:16:33.669 -03:00] [INF] [97] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="AndroidTV-ExoPlayer", Path="/mnt/nasdata2/Library/Movies/Werewolves.Within (2021)/Werewolves.Within.2021.1080p.Bluray.DTS-HD.MA.5.1.X264-EVO.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) "media:/videos/c3f48880-6d8c-5ebe-39bd-933a905f4a45/stream.mkv?MediaSourceId=c3f488806d8c5ebe39bd933a905f4a45&Static=true&VideoCodec=h264&AudioCodec=ac3&AudioStreamIndex=1&api_key=<token>&Tag=1b27c5e4e4323d34d8caf3a27f6e1ebf"
[2022-07-26 00:16:34.910 -03:00] [INF] [26] Emby.Server.Implementations.Session.SessionManager: Playback stopped reported by app "Android TV" "0.14.0-beta.2-fix.1" playing "Werewolves Within". Stopped at "0" ms
[2022-07-26 00:16:34.966 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "invitado". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2022-07-26 00:16:34.966 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: RemoteClientBitrateLimit: 10000000, RemoteIp: "192.168.200.149", IsInLocalNetwork: True
[2022-07-26 00:16:34.966 -03:00] [INF] [60] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="AndroidTV-libVLC", Path="/mnt/nasdata2/Library/Movies/Werewolves.Within (2021)/Werewolves.Within.2021.1080p.Bluray.DTS-HD.MA.5.1.X264-EVO.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) "media:/videos/c3f48880-6d8c-5ebe-39bd-933a905f4a45/stream.mkv?MediaSourceId=c3f488806d8c5ebe39bd933a905f4a45&Static=true&VideoCodec=h264&AudioCodec=ac3&AudioStreamIndex=1&api_key=<token>&Tag=1b27c5e4e4323d34d8caf3a27f6e1ebf"
[2022-07-26 00:16:35.455 -03:00] [INF] [132] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "invitado". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2022-07-26 00:16:35.455 -03:00] [INF] [132] Jellyfin.Api.Helpers.MediaInfoHelper: RemoteClientBitrateLimit: 10000000, RemoteIp: "192.168.200.149", IsInLocalNetwork: True
[2022-07-26 00:16:35.455 -03:00] [INF] [132] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="AndroidTV-ExoPlayer", Path="/mnt/nasdata2/Library/Movies/Werewolves.Within (2021)/Werewolves.Within.2021.1080p.Bluray.DTS-HD.MA.5.1.X264-EVO.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) "media:/videos/c3f48880-6d8c-5ebe-39bd-933a905f4a45/stream.mkv?MediaSourceId=c3f488806d8c5ebe39bd933a905f4a45&Static=true&VideoCodec=h264&AudioCodec=ac3&AudioStreamIndex=1&api_key=<token>&Tag=1b27c5e4e4323d34d8caf3a27f6e1ebf"
[2022-07-26 00:16:38.367 -03:00] [INF] [26] Emby.Server.Implementations.Session.SessionManager: Playback stopped reported by app "Android TV" "0.14.0-beta.2-fix.1" playing "Werewolves Within". Stopped at "0" ms

LibVLC, H264, AC3 5.1 direct play, working fine. <-- This option should be used by default on AFTM with Dolby, AC3 or DTS audio.

Andy2244 commented 2 years ago

Exoplayer, H264, AC3 5.1 not working

Out of curiosity can you try play the ac3 file locally via JustPlayer ?

ManuLinares commented 2 years ago

Exoplayer, H264, AC3 5.1 not working

Out of curiosity can you try play the ac3 file locally via JustPlayer ?

logcat: https://pastebin.com/MKzR8EyF IMG_20220726_014129

edit: I remember when jellyfin-androidtv used the amazon Exoplayer build because this exact issue. Amazon exoplayer needed some patches for ac3 and other stuff to work, but the team decided that moving away from amazon exoplayer build was more important than backward compatibility (which I understood)

Andy2244 commented 2 years ago

@ManuLinares ok can you retest this debug version for Ac3 playback? I tried to fix the exoplayer buffer init issues. https://drive.google.com/file/d/1kqS0mH9INn1LNMoDNCAROEH6QT2wMhQ_/view

logcat from the client would also be nice

ManuLinares commented 2 years ago

@ManuLinares ok can you retest this debug version for Ac3 playback? I tried to fix the exoplayer buffer init issues. https://drive.google.com/file/d/1kqS0mH9INn1LNMoDNCAROEH6QT2wMhQ_/view

logcat from the client would also be nice

H264, AC3 test: logcat https://pastebin.com/kG9RA8kg video choppy, no sound.

I then enabled both DTS and Dolby options, with the same result.

ManuLinares commented 2 years ago

Here are the, assumed, patches needed: https://github.com/amzn/exoplayer-amazon-port

Or just fall back to libVLC, or transcode audio

Source: https://developer.amazon.com/docs/fire-tv/dolby-integration-guidelines.html#exoplayer

edit: libVLC works choppy, maybe just transcode AC3 and DTS.

jellyfin-bot commented 1 year ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.

If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.

This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.