PM4K / PlexMod for Kodi (18, 19, 20, 21, 22+)

OK guys, Release day, time for a double-whammy! :man_cartwheeling:

As you’ll see, I’ve been a little busy since the end of last year. And no, no dynamic home hubs, yet. I made a little detour.

PM4K

1.2.6-beta1: script.plexmod.zip (3.2 MB)

Changelog:

  • Core/Player: Auto switch to LAV Full/SB if possible (CoreELEC U3k B9+ detected)
  • Core: Detect avdvplus as dynamic seamless branching fix enabled build, starting with R2
  • Core: Detect CoreELEC p3i build as auto seamless branching fix capable build
  • Core/Player: Only switch LAV modes if not already LAV Full or SB
  • Core: Re-jig waitForOpen
  • Core/SignIn/Auth: Fix wonky first start of plugin (home shown briefly after device auth and user select)
  • Core/Codecs: Improve JOC audio detection substantially in some cases; lower JOC bitrate likelihood to 736kbit due to Plex server calculation bug (was 768)
  • Home/Main/UserSelect: Refresh home users when receiving a 401 from plex.tv when switching home users, as its protected bit might have changed (pin set), retry two times
  • Main: Allow not showing any played/unplayed indicators at all
  • PostPlay: Fix wrong next-up item after re-playing the previously played item (e.g. played EP2, replaying EP2 from post-play, EP4 will be next up)
  • Player/SeekDialog: Fix marker skip button not showing on consecutive episode playback (introduced with 1.1.4-beta)
  • VideoInfo: Show seamless branching state on audio streams of affected videos
  • Player: Adjust resume point by user setting
  • Settings/Videoplayer: Add setting to adjust resume points negatively on resume, to avoid lost content due to keyframes/seek behaviour (default: -2.5s)
  • Settings/Video: Add setting for auto seamless branching LAV mode fix
  • Settings: Extend User Interface/Played indicators with option β€œNone”
  • AddonSettings: Add β€œSeamless branching LAV mode (CoreELEC U3k B9+)”, default: LAV SB

Notables

Apart from a lot of fixes vs. 1.1.4-beta, we have two great additions:

Auto-adjust resume points

This feature still baffles me, as it’s so obvious and so easy to implement. Ever noticed that when stopping a video mid-playback, then resuming, you’re losing up to a couple of seconds of content? Yes, this fixes that. It dynamically subtracts the configured (milli-) second value (default: 2.5 s) from the resume point value.

It’s that simple but so effective.

Auto seamless branching fix

Now this is an interesting one. If you’ve never heard of this, or you aren’t using CoreELEC, this might not really interest you, but bear with me. I won’t go into the details of what seamless branching is, that’s easily googlable.

With many current custom CoreELEC builds there’s an β€œaudio fix” feature included, which can be set to β€œLAV SB” (or β€œLAV Full”), which changes the internal handling of audio/video sync and fixes audio dropouts in affected seamless branching titles.

PM4K now implements a json file that lists all the known affected titles, and once detected, temporarily enables the β€œLAV SB” (or Full, depending on AddonSettings) mode in CoreELEC, automatically.

If you find other affected titles not yet included, please report them. In the meantime you can place a similarly formatted seamless_branching.json in your userdata/addon_data/script.plexmod folder and PM4K will use this in addition to the bundled one.

The shipped json file is based on: PLEX TrueHD/Atmos Seamless Branch Nvidia SHIELD "BAD MOVIES"

–

CoreELEC p3i

Yeah. I’ve created my own CoreELEC build. As many of you know, I’ve switched my daily driver to the Ugoos AM6B+, have been using Jamal’s great U3k build for a while, until he decided to stop maintaining it.

At the end of last year a user of PM4K discovered that in library views, idle CPU usage was extremely high for no apparent reason. That’s when I started exploring the Kodi guilib codebase, which ended up in pretty massive findings.

This build aims to be a stable, well maintained continuation of U3k and a potential replacement for the all time great CPM A14.

More details and the release/binaries: https://github.com/pannal/CoreELEC

As a shortcut, https://ce.pm4k.eu leads there, as well.

Release p3i T1

This is the initial release of p3i, directly based off of U3k B11, with a lot of improvements, most notably:

UI rendering improvements

I was able to discover a whole bunch of performance issues within the guilib code of Kodi, many of them existed for years, or even decades. Changes have been made to specific compositing, message queueing, as well as efficiency across a wide range of GUI controls.

All in all, the guilib changes result in:

  • faster UI rendering (especially complex UIs, such as PM4K and skins)

  • more efficient invalidation of controls across the board

  • less CPU usage during transitions and texture loading

  • significantly less CPU usage when idle while showing certain types of UIs

This can be very roughly summarized as (vs. other builds/stock Kodi):

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                Scenario                 β”‚             Estimated Improvement             β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ Idle with scrollbar visible             β”‚ 60-80% reduction in GUI CPU usage             β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ Idle with images/buttons (no scrollbar) β”‚ 30-50% reduction in GUI CPU usage             β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ Active scrolling                        β”‚ 20-40% reduction in per-frame processing      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ Image cross-fade transitions            β”‚ ~80% reduction in dirty region overhead       β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ Complex UIs with many controls          β”‚ 30-50% reduction due to message deduplication β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Those fixes will be pull requested towards Kodi upstream, so everybody can benefit.

There’s more to be done here, this β€œjust” fixes the most obvious ones.

Other notable changes

  • β€œLow latency audio mode” backported from Kodi 22 (via thexai and subsequent commits/PRs)
    This adds a new setting under System/Audio called β€œLow latency mode”, enabled by default. It significantly reduces the time audio streams take to β€œresume” when playback is resumed, vs. the video stream. If you encounter any issues, try disabling this first.

  • Fixed BT/Wi-Fi pairing in the β€œCoreELEC Settings”-Addon
    Since U3k B9’s Python upgrade, BT and Wi-Fi pairing stopped working. Due to a very old dbus library used by that addon, which isn’t supported anymore and doesn’t work with Python 3.13, I decided to rewrite a big part of it to utilize the newer dbussy/ravel library. This also reduces the time it takes to actually reboot when hitting the β€œReboot” option in the exit menu.

  • VideoPlayer: Fix seeking to resume point with LAV filters
    This fixes the issue where seeking to a resume point would incorrectly
    jump back to position 0 when LAV Full mode is active.

    Based on commit 7d47c17 from avdvplus/xbmc (cpm-code).

  • VideoPlayer: Sync to later start time to fix AV desync
    This prevents AV desync that can occur when video starts later than
    audio, particularly noticeable with LAV filter chain.

    Based on commit 31c65c3 from avdvplus/xbmc (cpm-code).

VC-1 fixes have not been included in this release, as we’ve found last-minute compatibility issues. Expect them in T2.

LAV Filters & PM4K

As with U3k B11, LAV filters are included as an option for fixing audio issues (under Settings/System/CoreELEC, bottom). By default this is set to Off, as during testing these fixes weren’t necessary (anymore). If you tend to watch seamless branching titles, you can set this to β€œLAV SB”. If you’re a user of the latest PM4K beta, the addon will take care of automatically enabling LAV SB for affected seamless branching titles, so you can leave this at Off. β€œLAV Full” isn’t necessary or recommended, but can be beneficial in certain scenarios, and should be fully compatible with PM4K’s Alternate Seek functionality.

Installation

1. Dirty

Drop the update tar into your CoreELEC update folder and reboot - this can be used as a dirty upgrade from CPM A14 or any of the U3k builds. Resetting Settings/System/CoreELEC to defaults after doing this is not necessary but recommended.

2. Flash

Use the provided Flash img.gz to prepare your SD card as you would with any other CoreELEC build.

advancedsettings.xml

If you’d like, you can add the following to your advancedsettings.xml, which further improves UI rendering, but is not strictly necessary:

<gui>
    <fronttobackrendering>true</fronttobackrendering>
    <geometryclear>false</geometryclear>
  </gui>

Thanks

A massive shoutout to everyone involved in this build!

Full Changelog (Kodi core): https://github.com/pannal/xbmc/commits/T1
Full Changelog (CoreELEC-Settings): https://github.com/pannal/service.coreelec.settings/commits/T1