Giter VIP home page Giter VIP logo

Comments (7)

lawadr avatar lawadr commented on June 16, 2024

You haven't listed your device. Maybe it doesn't support those profiles?

from jellyfin-androidtv.

MichaelRUSF avatar MichaelRUSF commented on June 16, 2024

I tested out the code on Andriod Studio with the emulator. Lots of ways to test it, but I'll try to explain my method.

If this is true (MediaCodecCapabilitiesTest)

fun supportsAVCHigh10(): Boolean = hasDecoder(
		MediaFormat.MIMETYPE_VIDEO_AVC,
		CodecProfileLevel.AVCProfileHigh10,
		CodecProfileLevel.AVCLevel4
	)

Then because of this (ProfileHelper) AVC High 10 is supposed to direct play given no other factors, e.g., subtitles, level support, bitrate, etc..

	val h264VideoProfileCondition by lazy {
		ProfileCondition(
			ProfileConditionType.EqualsAny,
			ProfileConditionValue.VideoProfile,
			listOfNotNull(
				"high",
				"main",
				"baseline",
				"constrained baseline",
				if (MediaTest.supportsAVCHigh10()) "high 10" else null
			).joinToString("|")
		)
	}

Using current build, play AVC High 10 L4.2 media, no subtitles or audio to eliminate other factors. Notice the video will transcode, reason should be unsupported profile.

Change this

fun supportsAVCHigh10(): Boolean = hasDecoder(
		MediaFormat.MIMETYPE_VIDEO_AVC,
		CodecProfileLevel.AVCProfileHigh10,
		CodecProfileLevel.AVCLevel4
	)

to this

fun supportsAVCHigh10(): Boolean = hasDecoder(
		MediaFormat.MIMETYPE_VIDEO_AVC,
		CodecProfileLevel.AVCProfileMain,
		CodecProfileLevel.AVCLevel4
	)

Run a new debug build on emulator and notice the file should now direct play without transcoding. HEVC Main will also come back as true. HEVC Main 10 comes back as false causing the video to transcode. You can run similar tests with different conditions to verify that getHevcMain10Level always comes back false with the getDecoderLevel function.

Note I also tested out the debug builds on real hardware and had the same results

from jellyfin-androidtv.

lawadr avatar lawadr commented on June 16, 2024

This is because the Android emulator doesn't claim support for HEVC Main 10 or AVC High 10:

Media type 'video/avc':
  Decoder "OMX.google.h264.decoder" supports
    profile/levels: [
      65536/65536 (ConstrainedBaseline/5.2),
          1/65536 (Baseline/5.2),
          2/65536 (Main/5.2),
      524288/65536 (ConstrainedHigh/5.2),
          8/65536 (High/5.2) ]
...
Media type 'video/hevc':
  Decoder "OMX.google.hevc.decoder" supports
    profile/levels: [
          1/65536 (Main/Main 5.1),
          4/65536 (MainStill/Main 5.1) ]

On this system, supportsAVCHigh10 and supportsHevcMain10 should both report false. I don't see what the problem is here. These functions seem to work as intended.

from jellyfin-androidtv.

MichaelRUSF avatar MichaelRUSF commented on June 16, 2024

Ok, thanks for that info. I didn’t realize that the emulators were not reporting AVCHigh10 & HEVCMain10 nor did it dawn on me to check. I assumed that they were b/c in my testing AVCHigh10 would directly play without transcoding in the emulator.

I also tested 2 Amazon devices; the Fire TV Stick 2nd gen and Fire TV Stick 4k 2nd gen, along with my Sony Bravia X90J. They all produced the results as the emulator returning false when checking for AVCHigh10 leading to transcoded video and True for HEVCMain & AVCMain producing direct play.

So my conclusions here are wrong. The main issue, as you pointed out, is that devices are not reporting AVCHigh10, even though they are supported. For example, Amazon's device specifically states “H.264. Hardware accelerated up to 3840x2160p (4K) @ 60 fps, 20 Mbps, High 10 Profile Level 5.2”. Yet reports no such decoder thus rendering the decoder check useless.

Decoder "c2.android.avc.decoder" supports
    aliases: [
      "OMX.google.h264.decoder" ]
    attributes: 0x4: [
      encoder: 0,
      vendor: 0,
      software-only: 1,
      hw-accelerated: 0 ]
    owner: "codec2::software"
    rank: 512
    profile/levels: [
      65536/65536 (ConstrainedBaseline/5.2),
          1/65536 (Baseline/5.2),
          2/65536 (Main/5.2),
      524288/65536 (ConstrainedHigh/5.2),
          8/65536 (High/5.2) ]
    colors: [

Well, this still is an issue but not with the hasDecoder function. It's more like what should be done when devices do not properly report their capabilities.

from jellyfin-androidtv.

lawadr avatar lawadr commented on June 16, 2024

That's Google's software decoder you've quoted. If I remember correctly, c2.android.avc.decoder is an alias for OMX.google.h264.decoder. If you keep looking you should find the hardware decoder. Could you post the report of that one please? It would be good to have it here for reference.

from jellyfin-androidtv.

MichaelRUSF avatar MichaelRUSF commented on June 16, 2024

Here's the full output for the Fire TV Stick 4k 2nd gen

from jellyfin-androidtv.

lawadr avatar lawadr commented on June 16, 2024

For AVC, those logs say it supports up to 5.2 High but doesn't support High 10 at all. For HEVC, it supports up to 5.1 Main 10.

The device page you linked to agrees on the level of HEVC support, but claims support for AVC High 10 at level 5.2. Which one is wrong I have no idea.

My suggestion would be to continue the special casing of AVC profile levels per device when support is different from what MediaCodec reports. In fact, this could be expanded to be on a per-profile basis rather than "global" across all AVC profiles.

from jellyfin-androidtv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.