Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update device profile - direct play, transcoding, and codec profiles #1299

Merged
merged 47 commits into from
Sep 11, 2023

Conversation

cewert
Copy link
Member

@cewert cewert commented Jun 7, 2023

Update the code to test each codec for each container instead of making assumptions. Updates maxAudioChannels logic - this should enable direct play support for 8 channel audio. Updates preferred audio codec if user supports surround sound. Adds a couple things from web profile i.e. Property: "IsAnamorphic".

Still a WIP. Adding as draft
The main thing I still need to test is multichannel audio and I don't have hardware to test so I'm removing the draft tag. Do the codecs direct play if the device supports it? When transcoding a multichannel audio that the device can't support, which codec is used? Is the DTS user setting working? Does 8 channel audio direct play?

Changes

  • Test all containers and codecs for direct play support
    • Test for all possible video and audio codecs (except those found in user settings)
    • mpeg4 and mpeg2 user setting overrides what the device says.
  • Save maxAudioChannels as string
    • This fixes the profile showing " 2" on occasion
  • Update maxAudioChannels logic to test for 8 channel support
    • This should enable direct play support for 8 channel audio
  • Add support for h264 files with DolbyVision
    • docs say Dolby Vision: dvav.09 is supported but I have no file to test with
  • Add playback info to global device object
    • Height, Width, Refresh rate, Bit depth
  • Create new user settings to allow the user to control the maximum resolution requested from the server.
    • Defaults: Only restrict transcoded files. Use connected TVs resolution.
    • User can choose to restrict all files instead of just trancoded files as well as being able to specify the resolution(off, auto, 360p, 480p, 720p etc.)
      • The web client setting Maximum Allowed Video Transcoding Resolution wasn't available using the API so I made a client side setting
  • Prefer EAC3 (then AC3 -> DTS) when transcoding surround sound audio by default
    • Add user setting to prefer DTS over EAC3 and AC3
  • Modify session.user.settings.Save() to stop trying to auto convert to int. This was causing a bug where strings were being converted to ints.
  • Update session info shown in web client admin dashboard (see below for pictures)
  • Add user setting to completely disable HEVC codec to improve playback for certain devices like the Ultra - 1080 HEVC SDR files choppy on Roku Ultra 2021 #449

web client admin dashboard before
roku-session-dashboard

web client admin dashboard after
roku-session-dashboard-after

Built on top of PR #1287 (merge that one first)

Fixes #1307
Fixes #944
Fixes #1348
Addresses #904

@jellyfin-bot jellyfin-bot added this to In progress in Ongoing development Jun 7, 2023
@cewert cewert mentioned this pull request Jun 7, 2023
@dotModded
Copy link

dotModded commented Aug 5, 2023

mpeg2 seems to be broken at line 486 of deviceCapabilities.brs, I'd fix it but I don't have the time atm:

mpeg2Levels = []
for each container in profileSupport
    for each level in profileSupport[container]["mpeg2"]
        if mpeg2Levels[level] = invalid
            mpeg2Levels.push(level)
        end if
    end for
end for

It seems as though you're treating profiles as levels for mpeg2, additionally mpeg2 profiles/levels are not numerical, see https://en.wikipedia.org/wiki/H.262/MPEG-2_Part_2#Video_profiles_and_levels I'm not sure what Roku's names for them are to test compatibility however. Not a huge issue as this format is basically dead and is more just here for completeness.

As a side note, audio transcoding with eac3 has been finnicky in my testing with a Roku Ultra. Codec support contradicts: https://developer.roku.com/docs/specs/media/streaming-specifications.md. TS/MP4 did not support E-AC3 or DTS (Even though the containers themselves support it, possibly something with the Jellyfin Server logic).

Currently testing your changes with the if condition removed, transcoding DTS:X to a device that does not support it, but supports eac3 is still playing back in aac with your changes. My setup supports multichannel AAC however I find Jellyfin to do an extremely poor job converting it. DD/DD+ offer far better results to my ears (even though the codecs are extremely similar)

@dotModded
Copy link

Further testing writing out the profiles manually on the Roku Ultra, disabling all codecs on the playback device besides AAC, DD, and DD+. Assuming Jellyfin server prioritizes lists from first element being the most significant.

TS:

  • Supports E-AC3, AC3, and AAC
  • AC3 is not chosen if AAC is present in any position.
  • E-AC3 is not chosen if AC3/AAC is present in any position.

MP4

  • Supports AC3 and AAC
  • E-AC3 results in no audio output

MKV:

  • Supports E-AC3, AC3, and AAC
  • E-AC3 is not chosen if AC3 is present in any position.

@cewert
Copy link
Member Author

cewert commented Aug 17, 2023

@dotModded Thank you for all the feedback!

As a side note, audio transcoding with eac3 has been finnicky in my testing with a Roku Ultra. Codec support contradicts: developer.roku.com/docs/specs/media/streaming-specifications.md. TS/MP4 did not support E-AC3 or DTS (Even though the containers themselves support it, possibly something with the Jellyfin Server logic).

That's strange. So the device profile told the server it could play the file but audio didn't play? Did AC3 work?

Currently testing your changes with the if condition removed, transcoding DTS:X to a device that does not support it, but supports eac3 is still playing back in aac with your changes. My setup supports multichannel AAC however I find Jellyfin to do an extremely poor job converting it. DD/DD+ offer far better results to my ears (even though the codecs are extremely similar)

Which if statement do you mean? Did the device profile correctly put eac3 first in the list of supported codecs (the device profile is printed when debugging)?

Further testing writing out the profiles manually on the Roku Ultra, disabling all codecs on the playback device besides AAC, DD, and DD+. Assuming Jellyfin server prioritizes lists from first element being the most significant.

Yea, from my understanding, the Jellyfin server prioritizes the transcoding codecs from left to right but your results seem to indicate that's not the case. You were modifying the transcoding profile right? It seems like the solution would be to pick a preferred codec and remove the other multichannel codecs from the device profile. Would you agree?

PS: Are you on matrix? Would you mind if I PM you to chat about the codec stuff when I get around to working on it? I'm not an expert with codecs and you seem to know your stuff 😄

@cewert
Copy link
Member Author

cewert commented Aug 18, 2023

@dotModded I believe I fixed the bug with mpeg2 but I don't have a file to test with. Mpeg2 is the only codec that has supported levels you can test for but no specific profiles according to the docs here.

I'm using an associative array called profileSupport to save what the device can support. Instead of creating a "dummy" profile array to save the mpeg2 levels under, I'm saving the levels as if they were profiles. I've added some comments to make that clear.

@dotModded
Copy link

@cewert No Matrix account, same handle on discord though. @dotModded I'd love to chat more about this

@cewert cewert marked this pull request as ready for review September 1, 2023 20:08
@cewert
Copy link
Member Author

cewert commented Sep 1, 2023

It's ready for testing now. The main thing I need help testing is multichannel audio:

  • Does 8 channel audio direct play?
  • Do the codecs direct play if the device supports it? EAC3 AC3 DTS
  • When transcoding a multichannel audio that the device can't support, which codec is used? EAC3 by default
  • Is the DTS user setting working for transcoded files?

@cewert
Copy link
Member Author

cewert commented Sep 3, 2023

I figured out how to restrict playback resolution for only transcoded files 🎉

I've added a user setting that allows the user to restrict resolution for all files or just transcoded files. Defaults to just transcoded files.
The other Maximum Resolution setting remains and is applied to either the Codec Profile or TranscodingProfile depending on what mode is set in settings (but only when the max res setting <> "off")

NOTE: The transcoding reason "The videos' resolution is not supported" will only show up when the mode is set to everything. transcoding mode will not show a transcoding reason but can be observed by checking the ffmpeg log.

Copy link
Contributor

@jimdogx jimdogx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

  • I tested DTS 5.1 on a non DTS system and things transcoded as expected. Then I played the same video on a DTS capable system and it directed played.
  • I also tested the Max Res setting. Transcoded to the max resolution when the setting was on. Then direct played when it was off.

Ongoing development automation moved this from In progress to Reviewer approved Sep 4, 2023
@jellyfin-bot jellyfin-bot moved this from Reviewer approved to In progress in Ongoing development Sep 4, 2023
Copy link
Member

@neilsb neilsb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned, I only have stereo audio, so not specifically able to to test the DTS stuff etc, but used the version over the weekend and certainly didn't hit any problems, and everything appeared to work as expected. And code all looks good.

Ongoing development automation moved this from In progress to Reviewer approved Sep 11, 2023
@cewert cewert merged commit aaeceb7 into jellyfin:unstable Sep 11, 2023
8 checks passed
Ongoing development automation moved this from Reviewer approved to Done Sep 11, 2023
@cewert cewert deleted the update-device-profile branch September 11, 2023 13:50
@cewert cewert added the new-feature A new feature that currently doesn't exist. label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature A new feature that currently doesn't exist.
Projects
5 participants