jellyfin-roku icon indicating copy to clipboard operation
jellyfin-roku copied to clipboard

Ability to set a bitrate limit

Open Nerdy314159265 opened this issue 2 years ago • 9 comments

Describe the feature you'd like I would like the ability to limit the bitrate that a device connecting via the Roku app will receive.

Additional context Despite having what should be a rather strong wifi connection it seems that my Roku streaming stick struggles with movies that are past a certain bitrate. Having a method to limit the bitrate to something it could handle would be very helpful and is a feature that I believe I remember using before the split from Emby.

Nerdy314159265 avatar Mar 26 '22 00:03 Nerdy314159265

I would also love this feature. On a roku LE device - even with excellent local wifi connection able to provide far beyond the needed bitrate - the roku seems to choke on super HD HDR releases - causing crashes and disconnects. I can limit bandwidth for remote users, please allow me to limit bandwidth for LAN users as well!

teh-mouses avatar Apr 03 '22 17:04 teh-mouses

I've noticed some oddness with the Roku Express 4k in that it seems when I play back at greater than 10mbps direct play, there's stuttering. A 20mbps movie direct play stutters, but playback at 15mbps to cause transcode and it's fine. Likewise a 35mbps movie direct play stutters, but transcoded to 30mbps appears to play back fine.

The transcode testing was done via emby client as there's no client quality setting in the jellyfin-roku yet.

I mention this as mearly being able to set resolution/bitrate might not be sufficient to resolve the #733 issue. As, for example, setting 1080p @ 30mbps max, would result in any movie with a lower bitrate still playing via direct play and potentially stuttering (as with the 20mbps movie I tested).

Would it be possible to include an option to force a transcode regardless of whether the current movie is under the set max resolution/bitrate and could normally direct play?

That is assuming the oddness I'm seeing is some issue with the Roku and not some jellyfin & emby quirk when direct play is active. It seems strange that lower bitrates direct play stutter whilst higher bitrates transcoded are smooth.

It doesn't seem to be bandwidth nor bitrate specifically that's the issue.

Sector14 avatar Aug 09 '22 23:08 Sector14

I've noticed some oddness with the Roku Express 4k in that it seems when I play back at greater than 10mbps direct play, there's stuttering. A 20mbps movie direct play stutters, but playback at 15mbps to cause transcode and it's fine. Likewise a 35mbps movie direct play stutters, but transcoded to 30mbps appears to play back fine.

Interesting. Do you have the details audio & video codecs and container used for the original file.

Would it be possible to include an option to force a transcode regardless of whether the current movie is under the set max resolution/bitrate and could normally direct play?

The way it works is that the client tells the server what it supports (codecs, profile levels, bitrate, containers etc etc) and then the server will provide a compatible file. If there are no compatible files, it will provide a transcode URL which will be used to retrieve the transcoded URL. The transcode URL is only supplied is there is no media that would match what the client said it supports.

So it's not quite as simple as being able to say "I want this media, but transcoded". The best thing would be to determine what was causing the stuttering (i.e. combination or codecs. or bitrate etc), we we can inform the server that it's not supported on a particular device.

If you were to be able to force transcode, how would you see this as working? Would be be a global option that would mean all video media would transcoded, or would you choose that when beginning playback of a particular item?

neilsb avatar Aug 10 '22 07:08 neilsb

Interesting. Do you have the details audio & video codecs and container used for the original file.

I can check codec details later tonight, but off hand the BluRays I tested were Aliens, Harry Potter & the Philosopher's stone, Deathly Hallows Part 1, Avatar and Ender's Game. All were direct BluRay rips, no re-encoding. Stored in a mkv container.

There's a few different codecs/bitrates in use there. I also tried some DVDs as well as re-encodes, those played without issue.

Regarding forcing transcode, I was thinking more from a "debug" point of a view. So that we can play around on a given device to find things that do/don't work even if they should. Although you are correct that it shouldn't really be needed.

Sector14 avatar Aug 10 '22 09:08 Sector14

Had a spare moment, here's a selection of the media info taken from the web interface:

Ender's Game

Audio

  • Title: Surround 5.1 - Eng - DTS-HD MA - Default
  • Language: eng
  • Codec: DTS
  • Profile: DTS-HD MA
  • Layout: 5.1
  • Channels: 6 ch
  • Bitrate: 3627 kbps
  • Sample rate: 48000 Hz
  • Bit depth: 24 bit
  • Default: Yes
  • Forced: No
  • External: No

(There's also the DTS stream 1536kbps)

Video

  • Title: 1080p H264 SDR
  • Codec: H264
  • AVC: No
  • Profile: High
  • Level: 41
  • Resolution: 1920x1080
  • Aspect ratio: 16:9
  • Interlaced: No
  • Framerate: 23.976025
  • Bitrate: 34913 kbps
  • Bit depth: 8 bit
  • Video range: SDR
  • Video range type: SDR
  • Pixel format: yuv420p
  • Ref frames: 1
  • NAL: 0

Harry Potter, Deathly Hallows Pt1.

Audio

  • Title: Surround 5.1 - Eng - DTS-HD MA - Default
  • Language: eng
  • Codec: DTS
  • Profile: DTS-HD MA
  • Layout: 5.1
  • Channels: 6 ch
  • Bitrate: 3586 kbps
  • Sample rate: 48000 Hz
  • Bit depth: 24 bit
  • Default: Yes
  • Forced: No
  • External: No

Video

  • Title: 1080p H264 SDR
  • Codec: H264
  • AVC: No
  • Profile: High
  • Level: 41
  • Resolution: 1920x1080
  • Aspect ratio: 16:9
  • Interlaced: No
  • Framerate: 23.976025
  • Bitrate: 20944 kbps
  • Bit depth: 8 bit
  • Video range: SDR
  • Video range type: SDR
  • Pixel format: yuv420p
  • Ref frames: 1
  • NAL: 0

Avatar

Audio

  • Title: Surround 5.1 - Eng - DTS-HD MA - Default
  • Language: eng
  • Codec: DTS
  • Profile: DTS-HD MA
  • Layout: 5.1
  • Channels: 6 ch
  • Bitrate: 4133 kbps
  • Sample rate: 48000 Hz
  • Bit depth: 24 bit
  • Default: Yes
  • Forced: No
  • External: No

Video

  • Title: 1080p H264 SDR
  • Codec: H264
  • AVC: No
  • Profile: High
  • Level: 41
  • Resolution: 1920x1080
  • Aspect ratio: 16:9
  • Interlaced: No
  • Framerate: 23.976025
  • Bitrate: 27709 kbps
  • Bit depth: 8 bit
  • Video range: SDR
  • Video range type: SDR
  • Pixel format: yuv420p
  • Ref frames: 1
  • NAL: 0

If you'd like any further info let me know.

Sector14 avatar Aug 10 '22 09:08 Sector14

The developer docs mention that the Roku can only do 10mbps h264 but up to 40mbps h265. If we take that as accurate even though it seems unusually low for h264 (and when transcoding I've had higher appear to play back fine, albeit only testing a few small/specific scenes), would it make sense to include not just a resolution/bitrate client option, but a codec choice too?

Perhaps in a debug menu, options being "auto" and then h264, h265. etc Which in theory would allow higher bitrate playback at the cost of transcoding to h265 when needed. (likewise for audio)

Having the option to play around with more settings on the client could be useful for troubleshooting. It would also provide a way to retain higher bitrates for those who don't mind the transcode to h265 overheard (even though h264 is supported), without removing the ability to direct play for those that want that, even if they end up needing to drop to 10mbps (assuming this is a roku express 4k limit and not just some issue with my setup or hw).

Edit: On a related note, it would be useful to have a similar stats display as the emby client has. It's useful to see when direct play is in use and what the original/current bitrates are as well as transcoding progress/fps to know if you're likely to keep ahead for real time playback.

Sector14 avatar Aug 10 '22 12:08 Sector14

Post in #734 adds a further twist to this issue. Apparently there's an issue on newer Roku's with DTS in mkv containers. This thread sheds more light on this:-

https://community.roku.com/t5/Playback-Issues-Audio-Video-Power/Rou-4800x-Stuttering-During-Playback-with-DTS-Audio/td-p/783744/highlight/true

If I have a spare moment this weekend I'll try to remux a few of the blurays I've had this problem with and see if that resolves it.

Sector14 avatar Aug 12 '22 19:08 Sector14

Based on the suggestion @lakerssuperman made about DTS and mkv tags (post linked above), I remuxed Ender's Game using mkvtoolnix gui and also using avidemux. Remux was nothing more than open the file in each app, ensure everything was set to copy (should be defaults) and saved to a new file.

Stuttering persisted with the mkvtoolnix remuxed version however stuttering is gone with the avidemux one. I assume mkvtoolnix is working the same as makemkv which is what was used to rip the BluRay originally, avidemux is for whatever reason doing things differently.

Given there's posts about this for the last couple of years I have my doubts Roku care about fixing it their end. Not sure what that means for Jellyfin. It's not really something Jellyfin can/should fix imo. It's up to Roku and in the mean time I guess anyone else having this issue, using avidemux to open/save their rips (less than ideal even if it's scriptable)

This does however make me think a debug menu to let you select a codec for audio/video to force transcoding to would be useful for testing, along with the option to select bitrate.

Edit: Just tried playing back with an alternative audio track, the non DTS director's commentary. Stuttering is also gone there on the non-remuxed version. So this does look like the DTS/tags are causing the Roku issue.

Edit2: For anyone on linux, you can remux the files with "ffmpeg -i input.mkv -c copy -map 0 output.mkv" This should preserve everything.

Sector14 avatar Aug 16 '22 18:08 Sector14

Based on the suggestion @lakerssuperman made about DTS and mkv tags (post linked above), I remuxed Ender's Game using mkvtoolnix gui and also using avidemux. Remux was nothing more than open the file in each app, ensure everything was set to copy (should be defaults) and saved to a new file.

Stuttering persisted with the mkvtoolnix remuxed version however stuttering is gone with the avidemux one. I assume mkvtoolnix is working the same as makemkv which is what was used to rip the BluRay originally, avidemux is for whatever reason doing things differently.

Given there's posts about this for the last couple of years I have my doubts Roku care about fixing it their end. Not sure what that means for Jellyfin. It's not really something Jellyfin can/should fix imo. It's up to Roku and in the mean time I guess anyone else having this issue, using avidemux to open/save their rips (less than ideal even if it's scriptable)

This does however make me think a debug menu to let you select a codec for audio/video to force transcoding to would be useful for testing, along with the option to select bitrate.

Edit: Just tried playing back with an alternative audio track, the non DTS director's commentary. Stuttering is also gone there on the non-remuxed version. So this does look like the DTS/tags are causing the Roku issue.

Edit2: For anyone on linux, you can remux the files with "ffmpeg -i input.mkv -c copy -map 0 output.mkv" This should preserve everything.

I'm glad you had found success!!

lakerssuperman avatar Aug 17 '22 07:08 lakerssuperman

This will be fixed / addressed in the next release via #975

jimdogx avatar Feb 10 '23 12:02 jimdogx