Jump to content

[GUIDE] Kodi on Orange Pi 5 with GPU Hardware Acceleration and HDMI Audio


adr3nal1n27

Recommended Posts

Kodi on Orange Pi 5 with GPU Hardware Acceleration and HDMI Audio

 

Huge thanks to user @roykon the Armbian forums for the directions on this in their various forum posts and Armbian forum user @amazingfate for maintaining the PPAs and software builds required for GPU acceleration. I have simply listed below, for the reference of others, the minimum Steps used to get Kodi running with GPU hardware acceleration (for x264/x265 decode) plus HDR auto switching and with HDMI Audio output*. (I am using the Orange Pi 5 with a Samsung 4K TV)

 

*No instructions added yet for enabling HDMI passthrough.

** No instructions added yet for enabling HDMI CEC.
 

Step 1 (SD card image creation)

Download the image below, uncompress it and write it to an SD card.

https://github.com/armbian/build/releases/download/23.02.0-trunk.0173/Armbian_23.02.0-trunk.0173_Orangepi5_jammy_legacy_5.10.110_xfce_desktop.img.xz#orangepi5 

 

Step 2 (First boot)

Boot the SD card image and complete the on-screen prompts for user & password creation.

Note down the IP address of the Orange Pi 5, you will need it in step 3.

 

Step 3 (SSH into the Orange Pi 5)

SSH to the IP address of your Orange Pi 5 and login using the user account and password you set up in Step 2.

 

Step 4 (Enable PPAs and install other elements required for GPU hardware acceleration)

At the command line, enter the following commands (highlighted in Blue):

sudo add-apt-repository ppa:liujianfeng1994/panfork-mesa

sudo add-apt-repository ppa:liujianfeng1994/rockchip-multimedia

sudo apt update

sudo apt full-upgrade

sudo apt install ubuntu-desktop kodi

When prompted on-screen if you wish to use gdm or lightdm, select gdm. 
 

Step 5 (Configuration file additions & changes)

At the command line, enter the following commands (highlighted in Blue):

sudo mv /usr/share/xsessions/kodi.desktop /usr/share/wayland-sessions/kodi-wayland.desktop

sudo nano /etc/udev/rules.d/11-rockchip-multimedia.rules

KERNEL=="mpp_service", MODE="0660", GROUP="video"
KERNEL=="rga", MODE="0660", GROUP="video"
KERNEL=="system-dma32", MODE="0666", GROUP="video"
KERNEL=="system-uncached-dma32", MODE="0666", GROUP="video" RUN+="/usr/bin/chmod a+rw /dev/dma_heap"

 

sudo nano /etc/gdm3/custom.conf

Add the line below and save the file.

WaylandEnable=true

 

sudo nano /usr/share/alsa/cards/HDMI-OUT.conf

Add all of the content below and save the file.

# configuration for HDMI connection which just expose the
# audio out device

<confdir:pcm/hdmi.conf>

HDMI-OUT.pcm.hdmi.0 {
        @args [ CARD DEVICE CTLINDEX AES0 AES1 AES2 AES3 ]
        @args.CARD {
                type string
        }
        @args.DEVICE {
                type integer
        }
        @args.CTLINDEX {
                type integer
        }
        @args.AES0 {
                type integer
        }
        @args.AES1 {
                type integer
        }
        @args.AES2 {
                type integer
        }
        @args.AES3 {
                type integer
        }
        type hw
card $CARD 
}

 

sudo nano /usr/share/alsa/cards/aliases.conf

Add the line below and save the file.

rockchip-hdmi0 cards.HDMI-OUT


 

Step 6 (Reboot and Start Kodi)

At the command line, enter the following commands (highlighted in Blue):

sudo reboot

At the login screen, select “kodi” in the bottom right hand corner menu.

Now login using your username and password. Kodi should now load.

 

Step 7 (Adjust Kodi settings)

  • From within Kodi goto Settings -> Player -> Videos goto the bottom left corner of the screen and change it from Standard to Expert.
  • From within Kodi goto Settings -> Player -> Videos, Playback, and change Adjust display refresh rate to “On start/stop”
  • From within Kodi goto Settings -> Player -> Videos, Processing, enable "Allow using DRM PRIME decoder" and "Allow hardware acceleration with DRM PRIME". And set "PRIME Render Method" to "Direct To Plane"
  • From within Kodi goto Settings -> System -> Display, and change the resolution to 1920x1080p
  • From within Kodi goto Settings -> System -> Audio, and change the Audio output device to “Built in Audio Digital Stereo (HDMI),HDMI / DisplayPort (PULSEAUDIO)”

 

Step 8 (Test video playback and check that GPU acceleration & HDMI Audio are working)

  • During video playback, press ‘o’ on the keyboard, and it should show Video decoder: ff-hevc_rkmpp-drm_prime (HW)
  • During video playback, if you have a Samsung TV, press the “Info” button on your Samsung TV remote to show the current playback resolution, frame rate and whether or not HDR is in use. (Depending on the video content being played)


 

Thank you again to Armbian forum users @royk and @amazingfate 









 

Link to comment
Share on other sites

Thanks for the instructions!

For me stereo HDMI Audio works good in this setup. I am using Armbian_23.02.0-trunk.0179_Orangepi5_jammy_legacy_5.10.110_minimal.img.xz.

 

Is anyone else having 5.1 channel audio issues over HDMI?

When I switch to 5.1 then I do get some sound, but seems like only side channels are actually playing or the channels are mixed up somehow (movies have sound but can't hear people talk).

Link to comment
Share on other sites

On 1/17/2023 at 10:39 PM, adr3nal1n27 said:

Kodi on Orange Pi 5 with GPU Hardware Acceleration and HDMI Audio

Thank you for the instructions. I done it on Rock5B with Jammy.
I had tried before but wasn't able to make it work. Must have had one of the steps missing. It plays 4K files great and with HDMI audio.
Thanks to all involved. Not sure if I can make a video about it, I'll just refer to this thread in the next RK3588 review. Thanks.

Link to comment
Share on other sites

@martivoIn case you use pulseaudio you could edit the mapping with "sudo nano  /usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf" and search for [Mapping hdmi-surround]

I used to change that mapping to: front-left,front-right,front-center,lfe,rear-left,rear-right   but I would say when you don´t hear the voices that lfe is at the place of front center, so you might want to try to only swap the front-center and lfe.

For testing you could use: https://www2.iis.fraunhofer.de/AAC/ChID-BLITS-EBU.mp4

After saving the mapping "pulseaudio -k && pulseaudio -D"

 

@adr3nal1n27 I only did some copy/paste work of especially @amazingfate and @Efe Çetin their work and from my .bash_history file with a lot of useless steps😀 I think Igor, amazingfate and Efe Çetin should earn most of the credits

 

But this manual is indeed a good starting point👍

Instead of ubuntu-desktop I'm pretty sure a lot of people would prefer Gnome or KDE which should also work with Wayland, but I haven´t test that yet to know the exact steps. It should also be possible to start a Wayland/GBM session from lightdm, but somehow I couldn´t make that work, perhaps a setting in a config file that I was missing. If someone knows how to do that it might be a nice add on for this manual.

After looking at the defaults of GDM3 I saw that the setting "WaylandEnable=true" is most likely not needed.

Edited by royk
Forgotten name
Link to comment
Share on other sites

@royk Yes it is pulse audio. I had now more time to test. I used the ChID-BLITS-EBU.mp4 file. Only front-left and front-right speaker work when I select Digital Surround 5.1 (HDMI) Output and the sound comes from the correct speakers.
 When I switch front-left and front-right  in /usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf then they are switched (front left speaker says "front right"). When I switch front-left and front-center, then I can hear from the left speaker "front-center". I also tried your suggestion but it did not change anything, I also tried some other combinations, but seems only physical front left and front right speaker do anything. I tested it with Kodi(gdm3 directly starts Kodi) and with mpv(In Ubuntu desktop with Wayland) - same behaviour.  Test were done with kernel 5.10.110-rockchip-rk3588 #trunk.0184 SMP Fri Jan 20 18:24:04 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
 

My old setup works with an Intel motheboard and Ubuntu Linux, I am trying to replace it with this Orange Pi 5.  I am using ARC (From Orange Pi 5 HDMI to TV and ARC from TV to receiver), maybe that is somehow affecting it. I am now using the same HDMI port on the TV too, so only thing changed is the HDMI source(The Orange Pi 5). I also tried to reduce the resolution to 1080p@30Hz in case it might be a bandwidth issue(HDMI 1.4).

About Wayland and KDE I would not bee too hopefull yet, it is "tech-preview state". https://community.kde.org/KWin/Wayland

 

Since the armbian image updates require re-installation I have created a set of Ansible roles that can do what the guide describes in steps 3 to 5. I used ubuntu-desktop-minimal to avoid installing libre office etc.  

This made testing different stuff a lot faster and easy to go back to an original state.  There are some other roles too but they are not related to this Guide.


https://github.com/martivo/armbian-orange-pi-5-ansible readme provided for How-to use it.

 

To do the same as the original guide activate the following roles in site.yml:

---
- hosts: all
  become: yes
  roles:
    - role: orangepi5-hdmi
    - role: ubuntu-desktop-minimal
    - role: gdm-enable-wayland
    - role: kodi
    - role: gdm-auto-login #optional

 

Edited by martivo
Link to comment
Share on other sites

2 hours ago, martivo said:

I am using ARC (From Orange Pi 5 HDMI to TV and ARC from TV to receiver), maybe that is somehow affecting it. I am now using the same HDMI port on the TV too, so only thing changed is the HDMI source(The Orange Pi 5). I also tried to reduce the resolution to 1080p@30Hz in case it might be a bandwidth issue(HDMI 1.4).

Multichannel PCM over ARC will not work indeed but it could do DTS and AC3 passthrough. To make that work you've to set the profile of pulseaudio at stereo and enable passthrough (ouput devices --> advanced options) and enable passthrough in Kodi. It seems like that pulseaudio transcodes DTS-HD to DTS, so that should work work over ARC. AAC multichannel audio however will not be transcoded so that's why you'll only hear front-left and front-right.

It might be easier to connect the OPI5 directly to the amp and set pulseaudio and kodi at 5.1 to let Kodi decode and send the MPCM to your amp. This way all multichannel audio files should work.

 

2 hours ago, martivo said:

Since the armbian image updates require re-installation I have created a set of Ansible roles that can do what the guide describes in steps 3 to 5. I used ubuntu-desktop-minimal to avoid installing libre office etc.  

This made testing different stuff a lot faster and easy to go back to an original state.  There are some other roles too but they are not related to this Guide.


https://github.com/martivo/armbian-orange-pi-5-ansible readme provided for How-to use it.

 

 

Nice!

Do you install the whole image every time? Wouldn't the following command be enough to install the fixes for rk3588?

 

sudo apt update && sudo apt install linux-dtb-legacy-rockchip-rk3588 linux-headers-legacy-rockchip-rk3588 linux-image-legacy-rockchip-rk3588 linux-libc-dev linux-source-5.10.110-legacy-rockchip-rk3588 linux-u-boot-orangepi5-legacy

 

@adr3nal1n27 I suspect that editing your post is only possible within a certain time, moderators still could do of course, but might be better to ask when there is more material to add.

Edited by royk
Link to comment
Share on other sites

@royk Ill do some more testing with these options and get back with results. I did try to only connect it to the TV and see if I can hear all the channels(without actual surround of course), but only front-left and front-right were there from that test clip. Yes I am installing the entire image - few reasons...firstly I can reset all the configuations/nonsense that I have tried and start with a clean setup and secondly to be sure that I am exactly where everyone else is by installing image from trunk. 

Can someone confirm that HDMI 5.1 works for them correctly? so I can conclude that it is an issue with my TV/Rceiver setup and not an issue with Armbian/OPI5?

@adr3nal1n27 I was frustrated too by the limits, but seems pay-to-play here if you are in a hurry - I bought the subscription for 5€ and can edit and post normally now.
 

Link to comment
Share on other sites

TLDR; The HDMI 5.1 output works fine with OPI5, except the channels can be mixed up, fix here. The issues I have are not related to Orange PI or Armbian.


@roykThank you for your help! After a ton of testing I can conclude that the issue is within my TV. I also tried connecting the TV and receiver with Optical cables and tried different passthrough settings and configurations. When connecting OPI5 straight to receiver then 5.1 works. It works when I play things from the TV itself (Using for example DLNA) over HDMI or SPDIF/Optical. The problem is that the TV  I have will not pass anything from inputs except 2 channels PCM. The issue is same as described here. I don't want to connect the OPI5 to the receiver because the receiver is limited to 1080p/60Hz resolutions - but the TV is 4k. I don't feel like replacing a perfectly good 7.1 Yamaha receiver to get a better video resolution. Ill get my hands on a service remote soon and try this hack.

Link to comment
Share on other sites

@martivo Remember that with that hack you could still only pass 2 channels. You could get 5.1 if it's a compressed DTS or ac3 file, multichannel PCM won't work.

Maybe a HDMI splitter an option? It might even work to put the audio through the second HDMI port.

Edited by royk
Link to comment
Share on other sites

@roykYes, I did get that to work(kind of), but not thanks to pulse-audio options(I really tried all of them in different combinations), I resorted to using dacenc for that(I refuse to have to check or know if my media file has the needed formats already with it in order to use it or if I want to play a game on the OPI5). My Receiver is rather old(2012 Yamaha RX-V567) and it supports only DolbyDigital or DTS(with most of their sub types. I will try out AC3 later to see if it works ). Seems LG has a beef with DTS, even though my TV(LG 60UF776V ~2016) lists support for it. I am having a suspicion that they have disabled passthrough for it in a later firmware update or it never supported passthrough like that - reading in many multimedia formus people are pissed at LG that buying a an expensive LG tv even in 2020 does not support DTS passthrough(and other brands do). I did try forcing PCM in TV with hopes that it will just pass it to the receiver and force the receiver to DTS without any luck. I really treied all of the combinations.
I have a 4k HDMI  splitter/audio extractor and yesterday I managed to get the 5.1 sound to the receiver using compressed DTS over SPDIF from it and 4k/60Hz to the TV at the same time[when using "Audio only" HDMI in the splitter to the receiver the TV picture got screwed up thats why I used SPDIF - ill investigate later]. So the remaining problem is the TV passthrough. I am still hoping to get the passthrough to work using a service menu configuration or maybe the TV will manage AC3. I want to get the TV passthrough to work so I would not have to switch sources when the source of the sound is the TV or the OPI5.

Ill create the relevant ansible roles for that setup too in case someone finds it useful.
 

#Start rant# At least now I understand what all those fancy words in user manuals mean...I never thought as a consumer I need to know all of that..."just plug in the ARC and have only one cable that does it all - it's Magic!" The good old times when we only had 1080p and everything worked perfectly no matter in what order you connect things up. We have open source processors, printable guns, but some companies are still playing licencing games over 6 channel audio as if it's some high tech future feature. #End rant#

Link to comment
Share on other sites

With AC3 I am able to send 5.1 audio throught the TV! Also content from the TV is played properly and ARC works. No need to change any audio sources.

I have created an ansible role that will setup DTS and AC3 ALSA devices on Orange PI 5 so any audio that you play is sent with compression over HDMI/DP. Pulseaudio will show them as sinks.

So if anyone else wan'ts to use an older receiver without 4K resolution support but has a new 4K tv then either of these could solve that issue. Both of these methods also work with a HDMI audio extractor.

Link to comment
Share on other sites

When /usr/share/wayland-sessions/kodi-wayland.desktop

 exec=kodi-standalone is modified to exec=pasuspender — env KODI_AE_SINK=ALSA kodi-standalone

, audio passthrough works. dd+atoms also works. But dthd doesn't work.

Link to comment
Share on other sites

Now that there is an official build for the Orange Pi 5, I decided to try this procedure with the Armbian_22.11.4_Orangepi5_jammy_legacy_5.10.110_gnome_desktop.img build.

 

My observations are:

 

1. If Allow hardware acceleration with DRM prime is turned on, any 10 bit X265 video shows a black screen, even though playback is running.

Turning it off will enable playback, but of course all rendering will be in software, whether 8 or 10 bit.

 

2. After enabling Allow hardware acceleration with DRM PRIME, the option "PRIME Render Method" to "Direct To Plane" is not shown.

 

3. At the login screen, there is no option to select “kodi” anywhere, just the user profile I initially created. So Kodi is run manually.

 

4. In Kodi, under Settings -> System -> Display, there is no option to change the resolution to 1920x1080p. The only option available is Monitor, for which there are 2 options, default or xwayland0.
 

Things do run well though.

 

 

Link to comment
Share on other sites

Actually this is what my problem is. After following the instructions, I got kodi running and Wayland. Now after few days I realise that I am not running wayland anymore, and the kodi option (when logging in) has disappeared! How can I get Wayland again?

Link to comment
Share on other sites

@compent I would recommend to get the trunk release instead rather than the stable.
"3. At the login screen, there is no option to select “kodi” anywhere, just the user profile I initially created. So Kodi is run manually."
You have to first press on the username and only when you are at the password promt the selection is displayed in the bottom right (it is only a tiny gear icon). If you run Kodi from desktop you will not get it to work right as far as I know and possibly other issues are also related to it.

@Tony3 Possibly the repo priorities are not set and some packages are later taken from default repo? Check this thread

Link to comment
Share on other sites

I found how to fix it!

If your mesa drivers/chromium have been overwritten by an update, do the following:

in rockchip-multimedia-ppu and panfork-mesa-ppu  put a priority 1000 instead of 600

Using 1000 instead of 600 apparently forces a reinstallation of them.

 

Then :

sudo add-apt-repository ppa:liujianfeng1994/panfork-mesa
sudo add-apt-repository ppa:liujianfeng1994/rockchip-multimedia
sudo apt update
sudo apt full-upgrade

 

Then reboot.

You will then see again the possibility to login with ubuntu using Wayland 

 

Hope I did not forgot something.......but still may help for the ones having lost Wayland.

 

 

 

 

Edited by Tony3
Link to comment
Share on other sites

@martivo I tried the trunk release and the problems that I experienced are no longer there, so thanks for the tip.

 

I happened to notice one thing though. I don't have an HDR TV and when I have tested HDR content on other platforms, whilst the quality on an SDR panel is distinctly average, there did seem to be a degree of tone mapping present to prevent it from being too washed out but with this, it is pretty much unwatchable.

When I had tried the official release I did notice that HDR content was as I would have expected and with the options for manual tone mapping using Hable, AECS and Reinhart also added into the video controls. Only a minor thing but hopefully something to come in subsequent trunk releases.

 

Link to comment
Share on other sites

martivo

 

Whilst testing with every new trunk release I decided to try your Ansible roles but I came across a problem.

 

When I run the ansible, ansible-playbook site.yml, I am prompted with BECOME password: and whatever I enter returns the following.

 

[WARNING]:  * Failed to parse /root/armbian-orange-pi-5-ansible/inventory.yml
with auto plugin: We were unable to read either as JSON nor YAML, these are the
errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.   mapping values are not allowed in this
context  The error appears to be in '/root/armbian-orange-
pi-5-ansible/inventory.yml': line 6, column 91, but may be elsewhere in the
file depending on the exact syntax problem.  The offending line appears to be:
vars:     normal_user: <non root user of your SBC that you created during
armbian first boot, ex: martin>
^ here
[WARNING]:  * Failed to parse /root/armbian-orange-pi-5-ansible/inventory.yml
with yaml plugin: We were unable to read either as JSON nor YAML, these are the
errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.   mapping values are not allowed in this
context  The error appears to be in '/root/armbian-orange-
pi-5-ansible/inventory.yml': line 6, column 91, but may be elsewhere in the
file depending on the exact syntax problem.  The offending line appears to be:
vars:     normal_user: <non root user of your SBC that you created during
armbian first boot, ex: martin>
^ here
[WARNING]:  * Failed to parse /root/armbian-orange-pi-5-ansible/inventory.yml
with ini plugin: Invalid host pattern 'all:' supplied, ending in ':' is not
allowed, this character is reserved to provide a port.
[WARNING]: Unable to parse /root/armbian-orange-pi-5-ansible/inventory.yml as
an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

Link to comment
Share on other sites

@compent you have to replace the values in inventory.yml file with values that are specific to your environment. In this specific case You have to replace "<non root user of your SBC that you created during armbian first boot, ex: martin>" with the normal username that you use for the Pi. In my case I use "martin" there. There are also other fields that you have to replace in the inventory.yml depending on what roles you have activated (most of them have example values too.) The Readme also lists what variables are needed for what roles. Depending weather you execute it locally or remotely as in the Readme, you will have slightly different inventory file.

 

Here is the top part of my inventory.yml that I use: 
 

all:
  hosts:
    192.168.0.3: #Replace with your Orange PI IP address
      ansible_user: martivo #Replace with oyur Orange PI 5 username for SSH
  vars:
    normal_user: martivo
    timezone: Europe/Tallinn
    hostname: loovsys.eu
...


I hope it helps.

Link to comment
Share on other sites

Thank you to Armbian forum users @royk and @amazingfate , i tried to run Kodi on Armbian trunk release , everything works well except HEVC or X265 codec show only black screen ( i can hear the sound from playback but no display)
Do you have any idea to fix this issue ?
And one more question , i tried to update lib panforst-mali from launchpad to DDK version 15 with hope can fix this issue, but after "sudo apt dist-upgrade ;sudo apt install mali-g610-firmware" , i checked current version only 13,
@amazingfate can you help update your launchpad to latest version ? Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines