Compiling Kodi to make it have hardware decoding

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

I'm only getting SW decoding. With both h264 and hevc.
Installed with apt-get install kodi aml-libs.
Ubuntu minimal.
Do I have to do something else?
As posted above, I had to run:

Code: Select all

sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev kodi
Maybe there's some group missing to allow HW?

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

Do you use ubuntu-18.04.3-4.9-minimal-odroid-n2-20190806.img.xz?
What happens if you login as a root?

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

odroid wrote:
Wed Oct 16, 2019 9:15 am
Do you use ubuntu-18.04.3-4.9-minimal-odroid-n2-20190806.img.xz?
What happens if you login as a root?
Yes.
Changing the systemd service to run as root works, so it's probably some group that I have to add the 'kodi' user to or some permission I have to change somewhere.
Any idea? I really don't want to keep kodi running as root.
Thanks.
Last edited by alpe on Wed Oct 16, 2019 9:55 am, edited 1 time in total.

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

I have no idea.
I hope other experts can help you.

User avatar
rooted
Posts: 7985
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 724 times
Been thanked: 243 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by rooted »

I think it's the video group.

gerulrich
Posts: 21
Joined: Tue Jun 18, 2019 10:00 pm
languages_spoken: english,spanish
ODROIDs: N2
Location: Argentina
Has thanked: 3 times
Been thanked: 18 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by gerulrich »

Check te kodi log for missing permissions:

cat /home/kodi/.kodi/temp/kodi.log | grep ERROR | grep AML

Enviado desde mi Redmi Note 4 mediante Tapatalk

These users thanked the author gerulrich for the post:
alpe (Wed Oct 16, 2019 9:34 pm)

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

rooted wrote:
Wed Oct 16, 2019 8:26 pm
I think it's the video group.
Thanks, but it's already on that group. :/
gerulrich wrote:
Wed Oct 16, 2019 8:37 pm
Check te kodi log for missing permissions:

cat /home/kodi/.kodi/temp/kodi.log | grep ERROR | grep AML

Enviado desde mi Redmi Note 4 mediante Tapatalk

Code: Select all

2019-10-16 00:48:19.788 T:548116812960   ERROR: AML: no rw on /sys/class/video/axis
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/video/screen_mode
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/video/disable_video
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/tsync/pts_pcrscr
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/module/ionvideo/parameters/freerun_mode
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/video/freerun_mode
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/audiodsp/digital_raw
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/amhdmitx/amhdmitx0/config
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/vfm/map
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/tsync/enable
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/amhdmitx/amhdmitx0/frac_rate_policy
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/module/di/parameters/bypass_prog
2019-10-16 00:48:19.789 T:548116812960   ERROR: AML: no rw on /sys/class/display/mode
Running this before starting kodi fixed it:

Code: Select all

sudo chown kodi /sys/class/video/axis /sys/class/video/screen_mode /sys/class/video/disable_video /sys/class/tsync/pts_pcrscr /sys/module/ionvideo/parameters/freerun_mode /sys/class/video/freerun_mode /sys/class/audiodsp/digital_raw /sys/class/amhdmitx/amhdmitx0/config /sys/class/vfm/map /sys/class/tsync/enable /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/class/amhdmitx/amhdmitx0/frac_rate_policy /sys/module/di/parameters/bypass_prog /sys/class/display/mode
I added it to rc.local and it worked.
Thanks.
These users thanked the author alpe for the post:
tobetter (Wed Oct 16, 2019 9:21 pm)

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

Another question.
After some time with the tv off, after I turn it back on again the screen is black.
It's not the kodi screen saver.
I press various buttons on the keyboard and it stays black. Even restarting kodi doesn't bring it back up again.
This happens when running as root as well.
Tried disabling HPD, but same.

mad_ady
Posts: 8466
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 461 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by mad_ady »

It's consoleblanking. There is a boot option to turn that off.
These users thanked the author mad_ady for the post:
alpe (Wed Oct 16, 2019 9:40 pm)

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

mad_ady wrote:
Wed Oct 16, 2019 9:35 pm
It's consoleblanking. There is a boot option to turn that off.
Disabled it as instructed in viewtopic.php?t=18819
Will update in a while with results.
Edit: It works. Thanks.

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

Another issue. Don't worry, I already solved this one. :lol:

Problem:
If I start the board (kodi starts automatically at boot) with the tv off, and later turn on the tv, there's no image and the Kodi cpu usage is quite high. Restarting kodi with the tv on works.
Looking at the log there was a "WARNING: UpdateResolutions: ProbeResolutions failed.".
Disabling display_autodetect on boot.ini didn't solve it.

Solution, in case someone encounters this issue in the future:
Simply go to Settings -> Display -> Display mode, and change it to Windowed. But by doing this the resolution, at least here, was very small.
So, I also created the file /home/kodi/.kodi/userdata/advancedsettings.xml with this inside:

Code: Select all

<advancedsettings version="1.0">
    <window>
        <width>1920</width>
        <height>1080</height>
    </window>
</advancedsettings>
I didn't notice any downsides to doing this. HW decoding works and CPU usage seems the same...

User avatar
memeka
Posts: 4420
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Has thanked: 2 times
Been thanked: 59 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by memeka »

Try setting an edid in boot.ini with desired resolution

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

memeka wrote:
Thu Oct 17, 2019 4:01 am
Try setting an edid in boot.ini with desired resolution
How?
Tried:

Code: Select all

setenv hdmimode "custombuilt"
setenv modeline "1920,1080,148500,67500,60,1920,2008,2052,2200,1080,1084,1088,1125,0,1,1"
Oh, and is there a way to bring the console up again when the service running kodi stop?

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

Is it possible to get Netflix working on Kodi? (like this: viewtopic.php?f=98&t=34076)
Or not yet?
Thanks.

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

Netflix add-on should work in 1080p resolution.

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

odroid wrote:
Sat Oct 19, 2019 1:05 pm
Netflix add-on should work in 1080p resolution.
"Widevine CDM is currently not available natively on ARM64. Please switch to a 32-bit userspace for Widevice CDM support."
So I guess I would have to use Kodi:armhf, right?
Is kodi:armhf available and updated on the N2 repository?

Update: Just checked and kodi:armhf insn't provided by http://deb.odroid.in/n2. If using armhf is the only way to run Netflix, please consider adding it (and possibly other required packages) to the repository in addition to aarch64.

Nuems
Posts: 171
Joined: Thu Sep 19, 2013 3:50 am
languages_spoken: english, german
ODROIDs: xu, c1, n2
Has thanked: 2 times
Been thanked: 15 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by Nuems »

As far as I know, Widevine CDM isn't officially available for 32-bit Linux either, however, it is part of ChromeOS (both 32 and 64bit). The library can be extracted from ChromeOS recovery images. There are kodi addons outside of the official repsoitory that automate this process and also take care of updating Widevine CDM when necessary (about once a month or so). One of those is the "Joyn" addon from this repo: https://github.com/kodinerds/repo/raw/m ... inerds.zip
[Joyn is an streaming platform for (mostly) German live TV and the channels' media libraries.]

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

Nuems wrote:
Sun Oct 20, 2019 4:50 pm
As far as I know, Widevine CDM isn't officially available for 32-bit Linux either, however, it is part of ChromeOS (both 32 and 64bit). The library can be extracted from ChromeOS recovery images. There are kodi addons outside of the official repsoitory that automate this process and also take care of updating Widevine CDM when necessary (about once a month or so). One of those is the "Joyn" addon from this repo: https://github.com/kodinerds/repo/raw/m ... inerds.zip
[Joyn is an streaming platform for (mostly) German live TV and the channels' media libraries.]
Thanks.
I got that error while using one of these methods. It download the ChromeOS image, but on installation gave that error. :/

desiqx
Posts: 1
Joined: Sat Oct 05, 2019 5:58 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by desiqx »

alpe wrote:
odroid wrote:
Sat Oct 19, 2019 1:05 pm
Netflix add-on should work in 1080p resolution.
"Widevine CDM is currently not available natively on ARM64. Please switch to a 32-bit userspace for Widevice CDM support."
So I guess I would have to use Kodi:armhf, right?
Is kodi:armhf available and updated on the N2 repository?

Update: Just checked and kodi:armhf insn't provided by http://deb.odroid.in/n2. If using armhf is the only way to run Netflix, please consider adding it (and possibly other required packages) to the repository in addition to aarch64.
I had the same problem recently. We need to use Kodi with 32bit userspace and still having 64 bit kernel and everything else. So In perfect world the easiest will be :

apt get install kodi:armhf

But in reality it's not that easy. I need to have fully functional Kodi, like in Coreelec in Ubuntu. I was fighting for some time and in final I'm using Coreelec until will find some easy way to do that.

For example for official odroid n2 repo has kodi 18.3 RC and I couldn't easy install pvr iptv simple addon and inputstream adaptive for Netflix unfortunately.

Maybe there is another better solution to get 32bit Kodi from coreelec in our latest Ubuntu image? Do you have any ideas guys? Is compiling Kodi and addons working without problems with hardware acceleration?


User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

We tried to build the Kodi for armhf but there were too many errors we couldn't fix. :(

mad_ady
Posts: 8466
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 461 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by mad_ady »

Not sure how well kodi is dockerized, but if it has direct access to /dev and /sys, a docker version of kodi might work and bypass dependency issues...

Truly
Posts: 30
Joined: Sun Nov 03, 2019 8:53 am
languages_spoken: english
ODROIDs: N2
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by Truly »

alpe wrote:
Wed Oct 16, 2019 8:02 am
gerulrich wrote:
Fri Oct 04, 2019 1:21 am
alpe wrote:
Fri Oct 04, 2019 12:58 am
While I wait for my board I'm doing some research.

How to install Kodi on Ubuntu minimal?
Acceleration works on minimal?
How can I open Kodi automatically on boot? Rc.local?

Thanks.

if you need cec working with kodi do the following:
Edit /media/boot/boot.ini and add hdmitx=cec3f in bootargs.

Code: Select all

sudo apt-get update
mkdir -p ~/ubuntu-packages/libcec-package
cd ~/ubuntu-packages/libcec-package
apt-get build-dep libcec4
apt-get source libcec4
cd libcec-4.0.2+dfsg1
# edit debian/rules
vim debian/rules # add -DHAVE_AOCEC_API=1 in dh_auto_configure line and save
debuild -us -uc
cd ~/ubuntu-packages/libcec-package
sudo dpkg -i libcec4_4.0.2+dfsg1-2ubuntu1.1_arm64.deb
sudo dpkg -i cec-utils_4.0.2+dfsg1-2ubuntu1.1_arm64.deb
sudo apt-mark hold libcec4
sudo apt-mark hold cec-utils
after that you can install kodi with:

Code: Select all

apt-get install kodi aml-libs
Add a service file for kodi: /etc/systemd/system/kodi.service

Code: Select all

[Unit]
Description=Kodi
After=network.target

[Service]
Type=simple
# Another Type: forking
User=kodi
WorkingDirectory=/home/kodi
ExecStart=/usr/bin/kodi-standalone
Restart=on-failure
# Other restart options: always, on-abort, etc

# The install section is needed to use
# `systemctl enable` to start on boot
# For a user service that you want to enable
# and start automatically, use `default.target`
# For system level services, use `multi-user.target`
[Install]
WantedBy=multi-user.target
I use kodi as user, but you can use whatever you want. You must verify that the user has the required permissions.

Code: Select all


systemctl daemon-reload
systemctl start kodi
systemctl enable kodi

that's all i think
I had to create the user Kodi manually with:

Code: Select all

sudo adduser --disabled-password --disabled-login kodi
And run:
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev kodi
as suggested in other post.
This looks like a comprehensive list of steps needed to compile and install Kodi with HW decoding on ubnuntu minimal.

I'm wondering if we can expect that Kodi with HV decoding will be added to the repository at some point in the future, so that it can be easily installed (apt-get install)? :)

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

The latest minimal Ubuntu image supports "kodi-fbdev" package.
https://wiki.odroid.com/odroid-xu4/os_i ... 10-minimal

Truly
Posts: 30
Joined: Sun Nov 03, 2019 8:53 am
languages_spoken: english
ODROIDs: N2
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by Truly »

Great!

Is this also present in the latest image for N2?

If yes, the only thing needed to install Kodi is:

Code: Select all

apt install kodi-fbdev

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

You might need a couple of more packages probably.
viewtopic.php?f=177&t=34438&start=50#p266126

Truly
Posts: 30
Joined: Sun Nov 03, 2019 8:53 am
languages_spoken: english
ODROIDs: N2
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by Truly »

It looks like the it's not in the repository:

Code: Select all

sudo apt update
sudo apt install kodi-fbdev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package kodi-fbdev

gerulrich
Posts: 21
Joined: Tue Jun 18, 2019 10:00 pm
languages_spoken: english,spanish
ODROIDs: N2
Location: Argentina
Has thanked: 3 times
Been thanked: 18 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by gerulrich »

Truly wrote:
Thu Jan 16, 2020 5:48 am
It looks like the it's not in the repository:

Code: Select all

sudo apt update
sudo apt install kodi-fbdev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package kodi-fbdev
To install kodi you have to execute

Code: Select all

apt-get install mali-fbdev kodi aml-libs
cec is working now with the packages from repository (edit boot.ini and put hdmitx=cec3f in bootargs).

if you have planned to run kodi as regular user (not root) you have to set some permissions to enable hardware decoding)
viewtopic.php?f=177&t=34438&start=150#p270654

if you want run as a service:
viewtopic.php?f=177&t=34438&start=100#p270592
These users thanked the author gerulrich for the post (total 2):
odroid (Thu Jan 16, 2020 10:56 pm) • Truly (Fri Jan 17, 2020 9:24 am)

picamodel
Posts: 5
Joined: Thu Feb 27, 2020 1:31 am
languages_spoken: english
ODROIDs: Odroid N2
Has thanked: 2 times
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by picamodel »

Hello,

Hardware acceleration does not work for me using the package from the repository.
I am running as root.

The playback is choppy. If I seek the video, a big black horizontal bar appears over the screen. It disappears if I enter the menu but returns when I return to the player.

Image

The debug log contains these errors. The file mentioned in the first error doesn't exist.

Code: Select all

ERROR: AML: no rw on /sys/module/di/parameters/bypass_prog
ERROR: DBus error: org.freedesktop.DBus.Error.ServiceUnknown - The name org.freedesktop.UPower was not provided by any .service files
ERROR: GetString: error reading /root/.kodi/userdata/disp_cap
ERROR: GetString: error reading /sys/class/amhdmitx/amhdmitx0/vesa_cap


Here is how I installed:

1. I used a fresh ubuntu minimal install, did:

Code: Select all

apt update && apt full-upgrade
2. Then I installed the packages you listed.

Code: Select all

apt-get install mali-fbdev kodi aml-libs
Any ideas why this is not working for me?


Thanks

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

Did you install the minimal image?
What is your current Kernel version?

picamodel
Posts: 5
Joined: Thu Feb 27, 2020 1:31 am
languages_spoken: english
ODROIDs: Odroid N2
Has thanked: 2 times
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by picamodel »

odroid wrote:
Thu Feb 27, 2020 9:26 am
Did you install the minimal image?
What is your current Kernel version?
Yes, I am using the latest minimal image.

Kernel is

Code: Select all

# uname -a
Linux odroid 4.9.213-67 #1 SMP PREEMPT Thu Feb 13 14:59:00 -03 2020 aarch64 aarch64 aarch64 GNU/Linux

User avatar
odroid
Site Admin
Posts: 35314
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1090 times
Been thanked: 826 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by odroid »

We will check it.
These users thanked the author odroid for the post:
picamodel (Sun Mar 01, 2020 12:19 am)

mdrjr
Site Admin
Posts: 11765
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 1 time
Been thanked: 29 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by mdrjr »

Hello :)

I've updated Kodi to 18.5 and fixed the issue.
apt update
apt install kodi aml-libs mali-fbdev
Enjoy
These users thanked the author mdrjr for the post:
picamodel (Sun Mar 01, 2020 12:19 am)

picamodel
Posts: 5
Joined: Thu Feb 27, 2020 1:31 am
languages_spoken: english
ODROIDs: Odroid N2
Has thanked: 2 times
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by picamodel »

I am still having the same problem.
Image

The playback is choppy and the screen gets a black horizontal bar if I seek the videos.
Seeking also fails sometimes - it doesn't move to the other part of the videos.

Also, HDMI CEC is quite unstable. Lots of times it lags behind key presses. Sometimes it stops working entirely or doesn't work on startup.

I deleted the .kodi directory to reset the settings but everything is the same.

I used CoreELEC before installing Ubuntu, and everything was working perfectly.
I need Ubuntu though, because I also want to run other stuff on the N2.

picamodel
Posts: 5
Joined: Thu Feb 27, 2020 1:31 am
languages_spoken: english
ODROIDs: Odroid N2
Has thanked: 2 times
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by picamodel »

If I open Kodi in the foreground as root I get this output.
(Audio sometimes also fails.)
I think this probably has something to do with the aml decoder libs.

Code: Select all

root@odroid:/home/kodi# kodi-standalone
OPEN es hevc
codec_init amstream version : 2.0
[codec_pause]p->has_audio=0
video_pause!
[codec_pause]p->has_audio=0
video_pause!
[codec_close_cntl]video codec close return=0!
OPEN es hevc
[codec_reset:1211]ret=0

mdrjr
Site Admin
Posts: 11765
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 1 time
Been thanked: 29 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by mdrjr »

Can you try running Kodi as root?

picamodel
Posts: 5
Joined: Thu Feb 27, 2020 1:31 am
languages_spoken: english
ODROIDs: Odroid N2
Has thanked: 2 times
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by picamodel »

I have, same thing happens.

alphahere
Posts: 3
Joined: Sun Dec 29, 2019 5:26 pm
languages_spoken: english
ODROIDs: odroid n2
Has thanked: 4 times
Been thanked: 0
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alphahere »

picamodel wrote:
Sun Mar 01, 2020 2:34 am
I have, same thing happens.
I have exact same problem, even when running as root. Any help on debugging the problem? Everything works fine after turning off hardware encoding.

Thanks

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

Yeah, I have been reporting this bug for some time and still not fixed. :(
viewtopic.php?f=177&t=36351&p=284645#p284645

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

odroid wrote:
Mon Oct 21, 2019 9:52 am
We tried to build the Kodi for armhf but there were too many errors we couldn't fix. :(
Just to remember you guys to try this again when you decide to build Kodi 19.

gerulrich
Posts: 21
Joined: Tue Jun 18, 2019 10:00 pm
languages_spoken: english,spanish
ODROIDs: N2
Location: Argentina
Has thanked: 3 times
Been thanked: 18 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by gerulrich »

I have compiled kodi for armhf.
  • Hardware decoding is not working (kodi crash when play video with hw decoding enabled)
  • Amazon Prime addon is working
  • IPTV Simple Client + inputstream.adaptive + widevine is working
Steps

1 - create chroot enviroment

Code: Select all

sudo apt-get install schroot debootstrap
sudo debootstrap --variant=buildd --arch armhf bionic /var/chroot/bionic-armhf http://ports.ubuntu.com/ubuntu-ports
sudo cp /etc/resolv.conf /var/chroot/bionic-armhf/etc/resolv.conf
sudo cp /etc/apt/sources.list /var/chroot/bionic-armhf/etc/apt/

#create schroot file
sudo vim /etc/schroot/chroot.d/bionic_armhf.conf
[bionic_armhf]
description=Ubuntu bionic
aliases=bionic
type=directory
directory=/var/chroot/bionic-armhf
personality=linux
root-users=odroid,kodi
users=odroid,kodi
preserve-environment=true

# chroot as root
schroot -c bionic -u root
apt-get update
apt-get install sudo
exit

2 - install dependencies

Code: Select all

#chroot as regular odroid user
schroot -c bionic

sudo apt-get install build-essential git binutils gcc g++ autopoint autoconf automake gettext autotools-dev cmake curl default-jre devscripts wget vim

# setup libamcodec

wget https://sources.coreelec.org/libamcodec-31cd6eceaa1402b9f4ff5cc349e53899860fe9b9.tar.xz
tar -xJvf libamcodec-31cd6eceaa1402b9f4ff5cc349e53899860fe9b9.tar.xz
sudo mkdir -p /usr/lib/aml_libs/
sudo cp libamcodec-31cd6eceaa1402b9f4ff5cc349e53899860fe9b9/usr/lib/libamcodec.so.0.0 /usr/lib/aml_libs/
sudo cp -d libamcodec-31cd6eceaa1402b9f4ff5cc349e53899860fe9b9/usr/lib/libamcodec.so /usr/lib/aml_libs/
sudo cp -R libamcodec-31cd6eceaa1402b9f4ff5cc349e53899860fe9b9/usr/include/amcodec /usr/include

# setup mali
apt download libgles2-mesa-dev mesa-common-dev libegl1-mesa-dev
sudo dpkg -x libegl1-mesa-dev_19.2.8-0ubuntu0~18.04.3_armhf.deb /
sudo dpkg -x libgles2-mesa-dev_19.2.8-0ubuntu0~18.04.3_armhf.deb /
sudo dpkg -x mesa-common-dev_19.2.8-0ubuntu0~18.04.3_armhf.deb /

# remove mesa libs
cd /usr/lib/arm-linux-gnueabihf/
sudo rm libGL.so.1 libGL.so.1.0.0 libGLX.so.0.0.0 libGLX_indirect.so.0 libGLX_mesa.so.0 libGLX_mesa.so.0.0.0 libGLdispatch.so.0 libGLdispatch.so.0.0.0 libGLX.so.0

# put libMali.so (i get from coreelec image) inside /usr/lib/arm-linux-gnueabihf/.
# download from https://drive.google.com/drive/folders/11_flbJL-arTNpk8wcbWUrRLQ7DU35rVD?usp=sharing
sudo ln -s libMali.so libEGL.so
sudo ln -s libMali.so libEGL.so.1
sudo ln -s libMali.so libGLES_CM.so.1
sudo ln -s libMali.so libGLESv1_CM.so
sudo ln -s libMali.so libGLESv1_CM.so.1
sudo ln -s libMali.so libGLESv1_CM.so.1.0.1
sudo ln -s libMali.so libGLESv1_CM.so.1.1
sudo ln -s libMali.so libGLESv2.so
sudo ln -s libMali.so libGLESv2.so.2
sudo ln -s libMali.so libGLESv2.so.2.0
sudo ln -s libMali.so libGLESv2.so.2.0.0
sudo ln -s libMali.so libGLESv3.so
sudo ln -s libMali.so libGLESv3.so.3
sudo ln -s libMali.so libGLESv3.so.3.0
sudo ln -s libMali.so libGLESv3.so.3.0.0


# install kodi build dependencies
sudo apt-get install liblzo2-dev libpng-dev libgif-dev libjpeg-dev libcap-dev libcec-dev libmicrohttpd-dev \
	python2.7-dev libxml2-dev libxslt1-dev libass-dev libcdio-dev libiso9660-dev uuid-dev libcurl4-openssl-dev \
	libfstrcmp-dev libssl-dev libsqlite3-dev libtinyxml-dev libinput-dev libxkbcommon-dev default-jre libtag1-dev swig \
	libasound-dev libdbus-1-dev libtag1-dev libfmt-dev rapidjson-dev libdvdread-dev libcrossguid-dev libtool

# move library to arm lib folder
sudo mv /usr/lib/libfstrcmp.so* /usr/lib/arm-linux-gnueabihf/
3 - compile kodi

Code: Select all

cd ~
mkdir armhf && cd armhf

git clone https://github.com/xbmc/xbmc.git kodi
cd kodi
git checkout 18.7.1-Leia
#create patch file
vim ~/armhf/kodi.patch
diff --git a/tools/depends/target/ffmpeg/CMakeLists.txt b/tools/depends/target/ffmpeg/CMakeLists.txt
index 4a2622216c..3dd54f412d 100644
--- a/tools/depends/target/ffmpeg/CMakeLists.txt
+++ b/tools/depends/target/ffmpeg/CMakeLists.txt
@@ -115,6 +115,7 @@ externalproject_add(ffmpeg
                       --enable-protocol=http
                       --enable-encoder=png
                       --enable-encoder=mjpeg
+		      --arch=arm
                       ${ffmpeg_conf})

 install(CODE "Message(Done)")
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp
index 10e73cc74f..f89619a73a 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AMLCodec.cpp
@@ -1779,7 +1779,7 @@ bool CAMLCodec::OpenAmlVideo(const CDVDStreamInfo &hints)
   m_defaultVfmMap = GetVfmMap("default");
   SetVfmMap("default", "decoder ppmgr deinterlace amlvideo amvideo");

-  SysfsUtils::SetInt("/sys/module/amlvideodri/parameters/freerun_mode", 3);
+  SysfsUtils::SetInt("/sys/module/ionvideo/parameters/freerun_mode", 3);

   return true;
 }
diff --git a/xbmc/rendering/MatrixGL.cpp b/xbmc/rendering/MatrixGL.cpp
index fc82cb35c9..4d2d53192c 100644
--- a/xbmc/rendering/MatrixGL.cpp
+++ b/xbmc/rendering/MatrixGL.cpp
@@ -11,7 +11,7 @@

 #if defined(HAS_NEON) && !defined(__LP64__)
 #include "utils/CPUInfo.h"
-void Matrix4Mul(float* src_mat_1, const float* src_mat_2);
+//void Matrix4Mul(float* src_mat_1, const float* src_mat_2);
 #endif

 #include <cmath>
@@ -131,13 +131,13 @@ void CMatrixGL::Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)

 void CMatrixGL::MultMatrixf(const CMatrixGL &matrix) noexcept
 {
-#if defined(HAS_NEON) && !defined(__LP64__)
-    if ((g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON) == CPU_FEATURE_NEON)
-    {
-      Matrix4Mul(m_pMatrix, matrix.m_pMatrix);
-      return;
-    }
-#endif
+//#if defined(HAS_NEON) && !defined(__LP64__)
+//    if ((g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON) == CPU_FEATURE_NEON)
+//    {
+//      Matrix4Mul(m_pMatrix, matrix.m_pMatrix);
+//      return;
+//    }
+//#endif
     GLfloat a = (matrix.m_pMatrix[0]  * m_pMatrix[0]) + (matrix.m_pMatrix[1]  * m_pMatrix[4]) + (matrix.m_pMatrix[2]  * m_pMatrix[8])  + (matrix.m_pMatrix[3]  * m_pMatrix[12]);
     GLfloat b = (matrix.m_pMatrix[0]  * m_pMatrix[1]) + (matrix.m_pMatrix[1]  * m_pMatrix[5]) + (matrix.m_pMatrix[2]  * m_pMatrix[9])  + (matrix.m_pMatrix[3]  * m_pMatrix[13]);
     GLfloat c = (matrix.m_pMatrix[0]  * m_pMatrix[2]) + (matrix.m_pMatrix[1]  * m_pMatrix[6]) + (matrix.m_pMatrix[2]  * m_pMatrix[10]) + (matrix.m_pMatrix[3]  * m_pMatrix[14]);
diff --git a/xbmc/rendering/gles/CMakeLists.txt b/xbmc/rendering/gles/CMakeLists.txt
index fc39514128..ea4481ba01 100644
--- a/xbmc/rendering/gles/CMakeLists.txt
+++ b/xbmc/rendering/gles/CMakeLists.txt
@@ -7,12 +7,12 @@ if(OPENGLES_FOUND)
               ../MatrixGL.h
               GLESShader.h)

-  if(ARCH MATCHES arm AND ENABLE_NEON)
-    list(APPEND SOURCES ../MatrixGL.neon.cpp)
-    if(NOT DEFINED NEON_FLAGS)
-      set_source_files_properties(../MatrixGL.neon.cpp PROPERTIES COMPILE_OPTIONS -mfpu=neon)
-    endif()
-  endif()
+      #if(ARCH MATCHES arm AND ENABLE_NEON)
+      #list(APPEND SOURCES ../MatrixGL.neon.cpp)
+      #if(NOT DEFINED NEON_FLAGS)
+      #set_source_files_properties(../MatrixGL.neon.cpp PROPERTIES COMPILE_OPTIONS -mfpu=neon)
+      #endif()
+      #endif()

   core_add_library(rendering_gles)
 endif()
diff --git a/xbmc/utils/AMLUtils.cpp b/xbmc/utils/AMLUtils.cpp
index 995891bb32..bb3225f5cc 100644
--- a/xbmc/utils/AMLUtils.cpp
+++ b/xbmc/utils/AMLUtils.cpp
@@ -101,9 +101,9 @@ bool aml_permissions()
       CLog::Log(LOGERROR, "AML: no rw on /dev/video10");
       permissions_ok = 0;
     }
-    if (!SysfsUtils::HasRW("/sys/module/amlvideodri/parameters/freerun_mode"))
+    if (!SysfsUtils::HasRW("/sys/module/ionvideo/parameters/freerun_mode"))
     {
-      CLog::Log(LOGERROR, "AML: no rw on /sys/module/amlvideodri/parameters/freerun_mode");
+      CLog::Log(LOGERROR, "AML: no rw on /sys/module/ionvideo/parameters/freerun_mode");
       permissions_ok = 0;
     }
     if (!SysfsUtils::HasRW("/sys/class/video/freerun_mode"))

#apply patch (remove a neon code that fails to compile, and add flag for compile ffmpeg)
patch -p1 -i ../kodi.patch
cd ..
mkdir kodi-build && cd kodi-build

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=aml \
	-DENABLE_INTERNAL_FLATBUFFERS=ON -DENABLE_ALSA=ON -DENABLE_AIRTUNES=OFF -DENABLE_UPNP=OFF \
	-DENABLE_INTERNAL_FMT=OFF -DENABLE_INTERNAL_RapidJSON=OFF -DENABLE_OPENGLES=ON -DENABLE_OPENGL=OFF \
	-DENABLE_X=OFF -DENABLE_X11=OFF -DVERBOSE=OFF -DENABLE_NEON=ON  -DENABLE_PULSEAUDIO=OFF -DENABLE_CCACHE=OFF \
	-DENABLE_INTERNAL_FFMPEG=ON -DENABLE_APP_AUTONAME=OFF -DENABLE_DVDCSS=OFF -DENABLE_INTERNAL_CROSSGUID=ON \
	-DENABLE_OPTICAL=OFF -DENABLE_EVENTCLIENTS=ON -DENABLE_CAP=ON -DENABLE_VDPAU=OFF -DENABLE_MMAL=ON \
	-DENABLE_AVAHI=OFF -DENABLE_BLURAY=OFF -DENABLE_CEC=ON -DENABLE_DBUS=ON -DENABLE_EGL=ON -DENABLE_MICROHTTPD=ON \
	-DENABLE_MYSQLCLIENT=OFF -DENABLE_NFS=OFF -DENABLE_NONFREE=ON -DENABLE_OPENSSL=ON -DENABLE_SMBCLIENT=OFF \
	-DENABLE_SSH=OFF -DENABLE_UDEV=ON -DENABLE_UPNP=ON -DENABLE_VAAPI=OFF -DENABLE_XSLT=ON -DENABLE_LIRC=ON \
	-DWITH_CPU=cortex-a73.cortex-a53 -DWITH_ARCH=arm ../kodi

make -j6
4 - fix libcec for armhf

Code: Select all

#build libcec4 for armhf
cd ~/armhf
sudo apt-get build-dep libcec4
apt-get source libcec4
cd libcec-4.0.2+dfsg1
# edit debian/rules
vim debian/rules # add -DHAVE_AOCEC_API=1 in dh_auto_configure line and save
debuild -us -uc
cd ~/armhf
sudo dpkg -i libcec4_4.0.2+dfsg1-2ubuntu1.1_armhf.deb
5 - compile and install addons

Code: Select all

# install script.module.inputstreamhelper
mkdir -p ~/.kodi/addons
cd ~/.kodi/addons

wget https://github.com/emilsvennesson/script.module.inputstreamhelper/archive/master.tar.gz
tar xzf master.tar.gz 
mv script.module.inputstreamhelper-master/ script.module.inputstreamhelper
sudo apt-get install python-pip
pip install wheel
pip install pycryptodomex

# compile and install inputstream.adaptive
cd ~/armhf
git clone https://github.com/peak3d/inputstream.adaptive.git
cd inputstream.adaptive/
git checkout 2.4.5-Leia
mkdir build && cd build
cmake -DADDONS_TO_BUILD=inputstream.adaptive -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../kodi/addons -DPACKAGE_ZIP=1 ../../kodi/cmake/addons
cmake --build . --config Debug --target inputstream.adaptive
cp -R ~/armhf/kodi/addons/inputstream.adaptive ~/armhf/kodi-build/addons/

# compile and install pvr.iptvsimple
cd ~/armhf
cd pvr.iptvsimple/
git checkout 3.9.8-Leia
mkdir build && cd build
cmake -DADDONS_TO_BUILD=pvr.iptvsimple -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../kodi/addons -DPACKAGE_ZIP=1 ../../kodi/cmake/addons
make -j6
cp -R ~/armhf/kodi/addons/pvr.iptvsimple ~/armhf/kodi-build/addons/
6 - run kodi (in chroot)

Code: Select all

# run kodi (inside chroot).
# remember enable inputstream.adaptive, pvr.iptvsimple inputstreamhelper
# install Amazon VOD from Sandmann79 and install libwidevine.so with inputstreamhelper
cd ~
./armhf/kodi-build/kodi.bin

# for watch live tv with widevine encription (pvr.iptvsimple):
# create a file tv.m3u8 (example) and configute the addon
#EXTM3U
#EXTINF:-1 tvg-id="id" tvg-name="name" tvg-chno="1",NAME
#KODIPROP:inputstreamaddon=inputstream.adaptive
#KODIPROP:inputstream.adaptive.manifest_type=mpd
#KODIPROP:inputstream.adaptive.license_type=com.widevine.alpha
#KODIPROP:inputstream.adaptive.license_key=https://url-license-server|User-Agent=Mozilla%2F5.0|R{SSM}|
http://url/Channel.mpd

# exit the chroot
exit
7 - run kodi outside chroot

Code: Select all

# to run kodi (outside the chroot) all dependencies need to be installed
sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture armhf && sudo apt update

#remove conflicting packages
apt-get remove kodi libcec4 python2.7 python2.7-minimal

sudo apt install libc6:armhf libstdc++6:armhf libcec4:armhf
cd ~/armhf 
sudo dpkg -i libcec4_4.0.2+dfsg1-2ubuntu1.1_armhf.deb

sudo apt-get install liblzo2-2:armhf libpng16-16:armhf libgif7:armhf libcap2:armhf libmicrohttpd12:armhf libxml2:armhf \
	libpython2.7:armhf libxslt1.1:armhf libass9:armhf libcdio17:armhf libiso9660-10:armhf libuuid1:armhf libcurl4:armhf \
	libfstrcmp0:armhf libsqlite3-0:armhf libtinyxml2.6.2v5:armhf libinput10:armhf libxkbcommon0:armhf libtag1v5:armhf \
	libasound2:armhf libdbus-1-3:armhf libdvdread4:armhf libcrossguid0:armhf libpcrecpp0v5:armhf

#put libMali in /usr/lib/arm-linux-gnueabihf
sudo ln -s /usr/lib/arm-linux-gnueabihf/libMali.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so
./armhf/kodi-build/kodi.bin
enjoy!!!
These users thanked the author gerulrich for the post (total 6):
odroid (Fri Jun 19, 2020 1:18 pm) • mad_ady (Fri Jun 19, 2020 1:46 pm) • Truly (Fri Jun 19, 2020 3:41 pm) • Rmiino (Fri Jun 19, 2020 9:48 pm) • istanbulls (Sun Jun 21, 2020 5:04 am) • alpe (Thu Jul 23, 2020 10:49 am)

alpe
Posts: 116
Joined: Sat Apr 12, 2014 1:21 pm
languages_spoken: portuguese, english
ODROIDs: C1, N2 4GB
Location: Rio de Janeiro, Brazil
Has thanked: 35 times
Been thanked: 9 times
Contact:

Re: Compiling Kodi to make it have hardware decoding

Post by alpe »

Anyone trying to make kodi work on Ubuntu minimal 20.04?

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 0 guests