This tutorial is intended for beginners interested in compiling tvheadend with HW GPU transcoding (using iGPU form Intel gen 8+).
It is a little messy how Intel is combining CPU generations with GPU generations so before you buy a platform I strongly recommend you to check "
www.cpu-monkey.com" and "
www.cpu-world.com" to confirm your GPU is hardware capable decoding/encoding, Gen 9+ is recommended to 'low power encoders'.
I tested this methodology on following platforms:
- atomicpi (Atom x5-Z8350) iGPU gen 8 "Atom
x5-Z8350" downloading lubuntu 20.04 from:
http://ehxz.tk/atomicpi
Note: this CPU doesn't have the H264 Low Power Mode encoder
- gk41 celeron J4125 "
Amazon" iGPU 9.5 "celeron
J4125"
- NUC8 Compute Element with Pentium Gold 5405U "Compute
Element" iGPU 9.5 "Pentium Gold
5405U"
- NUC11 Compute Element with "Celeron 6305"
Date:
Jan 4, 2023.
HW:
NUC element with Pentium Gold 5405u
download ISO LUBUNTU 20.04:
https://www.cdimage.ubuntu.com/lubuntu/releases/20.04/release/
lubuntu-20.04.5-desktop-amd64.iso
flash ISO to USB 32G using rufus-3.21
Note: make sure you plug the USB stick in USB2.0 socket (black).
Install Lubuntu to PC with default settings; connect also to internet.
At boot you will see some i915 error about DRM ... don't worry.
Update some settings:
Preference / LXQt setting / Power Management: Idle --> uncheck Enable Idleness Watcher : Close
Preference / LXQt setting / Monitor Settings: 1280 x 720 : Save : Yes
Preference / LXQt setting / LXQt Configuration Center : Openbox Settings --> Desktops : Number of desktops : 1
Preference / Screen Saver : Mode : Disable screen saver
Install SSH:
System Tools / QTerminal
sudo apt update
sudo apt install ssh
check status:
systemctl status sshd.service
You should see is Active.
if is not working:
sudo systemctl enable sshd
and:
sudo systemctl start sshd
I prefer to connect over SSH to continue, but you can remain in terminal (on desktop):
Update to latest kernel version:
sudo apt update
sudo apt upgrade
sudo reboot
sudo apt autoremove --purge
uname -a
alin@alin-cm8pcb4r:~$ uname -a
Linux alin-cm8pcb4r 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
install Media SDK:
https://docs.unified-streaming.com/documentation/transcode/media-sdk.html#ubuntu-20-04-intel-media-sdk-2020
sudo apt-get -q -y update
sudo apt-get -q -y install intel-media-va-driver-non-free libmfx1 libva-drm2 vainfo
sudo vainfo
alin@alin-cm8pcb4r:~$ sudo vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function
vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.1.1 ()
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointFEI
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointFEI
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileVP8Version0_3 : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
the data format is:
CODEC/profile : Encoder/Decoder
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
This is: H264, Profile high with decoder (VAEntrypointVLD) , Encoder (VAEntrypointEncSlice) and LowPower encoder (VAEntrypointEncSliceLP)
Is importand to identify if your GPU has this low power (LP) codecs available.
In my case I have low power for: H264 profiles Main, High and Constrained
OPTION 1: Gen8 / Gen9 / Gen9.5
Install required development packages:
https://www.linuxfordevices.com/tutorials/ubuntu/install-intel-graphic-drivers
Note:
- some packages are already installed ... but is no harm to install them again.
check:
sudo lspci -nn | grep -e VGA
alin@alin-cm8pcb4r:~$ sudo lspci -nn | grep -e VGA
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3ea1] (rev 02)
you can go on:
https://dgpu-docs.intel.com/devices/hardware-table.html
and search for: "3ea1" (check after [8086:****]).
and see is: IntelĀ® UHD Graphics 610 --> Gen 9 --> Coffee Lake
sudo apt install mesa-utils
sudo apt autoremove
Now, enter the following command to get the driver details. It will also give you other GPU details along with driver details.
in Desktop (not SSH):
glxinfo -B
How to install Intel graphic drivers on Ubuntu?
sudo apt install -y gpg-agent wget
wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | sudo apt-key add -
sudo apt-add-repository \
'deb [arch=amd64] https://repositories.intel.com/graphics/ubuntu focal main'
Install run-time packages:
sudo apt-get update
sudo apt install \
intel-opencl-icd \
intel-level-zero-gpu level-zero \
intel-media-va-driver-non-free libmfx1
Install developer packages:
sudo apt install \
libigc-dev \
intel-igc-cm \
libigdfcl-dev \
libigfxcmrt-dev \
level-zero-dev
END OPTION 1
OPTION 2: Gen11+
https://dgpu-docs.intel.com/installation-guides/ubuntu/ubuntu-focal-legacy.html
Note:
- some packages are already installed ... but is no harm to install them again.
check:
sudo lspci -nn | grep -e VGA
alin@alin-cm8pcb4r:~$ sudo lspci -nn | grep -e VGA
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:9a78] (rev 01)
you can go on:
https://dgpu-docs.intel.com/devices/hardware-table.html
and search for: "9a78" (check after [8086:****]).
and see is: IntelĀ® UHD Graphics --> Gen Xe --> Tiger Lake
Step 1 Add package repository:
sudo apt-get install -y gpg-agent wget
wget -qO - https://repositories.intel.com/graphics/intel-graphics.key |
sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal-legacy main' | \
sudo tee /etc/apt/sources.list.d/intel.gpu.focal.list
Step 2 Install run-time packages:
sudo apt-get update
sudo apt-get install \
intel-opencl-icd \
intel-level-zero-gpu level-zero \
intel-media-va-driver-non-free libmfx1 libmfxgen1 libvpl2
Install developer packages:
sudo apt-get install \
libigc-dev \
intel-igc-cm \
libigdfcl-dev \
libigfxcmrt-dev \
level-zero-dev
END OPTION 2
Configuring permissions:
To access GPU capabilities, a user needs to have the correct permissions. The following will list the group assigned ownership of the render nodes, and list the groups the active user is a member of:
stat -c "%G" /dev/dri/render*
alin@alin-cm8pcb4r:~$ stat -c "%G" /dev/dri/render*
render
My expectation is that you receive 'render' ... but you might receive also other names (like video). In that case you have to replace in commands below the 'render' with 'video' (or what ever you receive).
Now we check if user is part of that group:
groups ${USER}
alin@alin-cm8pcb4r:~$ groups ${USER}
alin : alin adm cdrom sudo dip plugdev lpadmin sambashare
--> as expected is not.
we add user to group 'render' (or video if you received video above):
sudo gpasswd -a ${USER} render
newgrp render
Now we have to verify that actual user is part of render (or video):
groups ${USER}
alin@alin-cm8pcb4r:~$ groups ${USER}
alin : alin adm cdrom sudo dip plugdev render lpadmin sambashare
Note we have render in the list.
Update to latest:
sudo apt update
sudo apt upgrade
Install gpu tools (required to check the work load on GPU):
sudo apt install intel-gpu-tools
Enable GUC firmware (this is a must for encoding with low power codec):
we need to generate a file:
sudo vi /etc/modprobe.d/i915.conf
with the text (only one line) --> press key 'I':
OPTION 1: Gen8 / Gen9 / Gen9.5
options i915 enable_guc=2
END OPTION 1
OPTION 2: Gen11+
options i915 enable_guc=3
END OPTION 2
--> press key : and w
--> press key : and q
sudo update-initramfs -k all -u
sudo update-grub
sudo reboot
Verify GuC was enabled:
dmesg | grep guc
OPTION 1: Gen8 / Gen9 / Gen9.5
alin@alin-cm8pcb4r:~$ dmesg | grep guc
[ 1.460690] Setting dangerous option enable_guc - tainting kernel
[ 2.610368] i915 0000:00:02.0: [drm] GuC firmware i915/kbl_guc_62.0.0.bin version 62.0 submission:disabled
END OPTION 1
OPTION 2: Gen11+
alin@alin-6305:~$ dmesg | grep guc
[ 1.685204] Setting dangerous option enable_guc - tainting kernel
[ 2.391513] i915 0000:00:02.0: [drm] GuC firmware i915/tgl_guc_62.0.0.bin version 62.0 submission:enabled
END OPTION 2
-> it sounds scary 'dangerous option' ... but is fine.
check vainfo:
vainfo
OPTION 1: Gen8 / Gen9 / Gen9.5
alin@alin-cm8pcb4r:~$ vainfo
error: can't connect to X server!
libva info: VA-API version 1.15.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function
vaDriverInit_1_15
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.15 (libva 2.15.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.5.0 (7e9cc59)
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointFEI
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointFEI
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileVP8Version0_3 : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
You should see that "VA-API version: 1.15 (libva 2.15.0)" updated from previous "VA-API version: 1.7 (libva 2.6.0)"
END OPTION 1
OPTION 2: Gen11+
alin@alin-6305:~$ vainfo
Trying display: wayland
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.16.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function
vaDriverInit_1_16
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.16 (libva 2.16.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.6.4 (aca8ee0)
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointFEI
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointFEI
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain : VAEntrypointEncSliceLP
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileHEVCMain10 : VAEntrypointEncSliceLP
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile0 : VAEntrypointEncSliceLP
VAProfileVP9Profile1 : VAEntrypointVLD
VAProfileVP9Profile1 : VAEntrypointEncSliceLP
VAProfileVP9Profile2 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointEncSliceLP
VAProfileVP9Profile3 : VAEntrypointVLD
VAProfileVP9Profile3 : VAEntrypointEncSliceLP
VAProfileHEVCMain12 : VAEntrypointVLD
VAProfileHEVCMain12 : VAEntrypointEncSlice
VAProfileHEVCMain422_10 : VAEntrypointVLD
VAProfileHEVCMain422_10 : VAEntrypointEncSlice
VAProfileHEVCMain422_12 : VAEntrypointVLD
VAProfileHEVCMain422_12 : VAEntrypointEncSlice
VAProfileHEVCMain444 : VAEntrypointVLD
VAProfileHEVCMain444 : VAEntrypointEncSliceLP
VAProfileHEVCMain444_10 : VAEntrypointVLD
VAProfileHEVCMain444_10 : VAEntrypointEncSliceLP
VAProfileHEVCMain444_12 : VAEntrypointVLD
VAProfileHEVCSccMain : VAEntrypointVLD
VAProfileHEVCSccMain : VAEntrypointEncSliceLP
VAProfileHEVCSccMain10 : VAEntrypointVLD
VAProfileHEVCSccMain10 : VAEntrypointEncSliceLP
VAProfileHEVCSccMain444 : VAEntrypointVLD
VAProfileHEVCSccMain444 : VAEntrypointEncSliceLP
VAProfileAV1Profile0 : VAEntrypointVLD
VAProfileHEVCSccMain444_10 : VAEntrypointVLD
VAProfileHEVCSccMain444_10 : VAEntrypointEncSliceLP
END OPTION 2
This is required to scan channels later on:
sudo apt update
sudo apt install w-scan
clean up:
sudo apt autoremove
Compile tvheadend:
cd ~
git clone https://github.com/tvheadend/tvheadend.git
sudo apt update
sudo apt install gettext libssl-dev cmake libpcre2-dev libdvbcsa-dev libva-dev liburiparser-dev libavahi-client-dev debhelper zlib1g-dev python
sudo apt install pip
cd tvheadend
./configure
$################### log output ####################
alin@alin-cm8pcb4r:~/tvheadend$ ./configure
Checking support/features
checking for cc execinfo.h ... ok
checking for cc -mmmx ... ok
checking for cc -msse2 ... ok
checking for cc -Wunused-result ... ok
checking for cc -fstack-protector ... ok
checking for cc -fstack-protector-strong ... ok
checking for cc -fstack-check ... ok
checking for cc -fPIE ... ok
checking for cc strlcat ... fail
checking for cc strlcpy ... fail
checking for cc fdatasync ... ok
checking for cc getloadavg ... ok
checking for cc atomic32 ... ok
checking for cc atomic64 ... ok
checking for cc atomic_time_t ... ok
checking for cc atomic_ptr ... ok
checking for cc bitops64 ... ok
checking for cc lockowner ... ok
checking for cc qsort_r ... ok
checking for cc stime ... fail
checking for cc gmtoff ... ok
checking for cc recvmmsg ... ok
checking for cc sendmmsg ... ok
checking for cc libiconv ... fail
^ using build-in glibc iconv routines
checking for cc ifnames ... ok
checking for cc cclang_threadsan ... fail
checking for py module gzip ... ok
checking for pkg-config ... ok
checking for xgettext ... ok
checking for msgmerge ... ok
checking for gzip ... ok
checking for bzip2 ... ok
checking for pkg openssl ... ok (detected 1.1.1f)
checking for cc linux/dvb/version.h ... ok
checking for pkg zlib ... ok (detected 1.2.11)
checking for pkg libpcre2-8 ... ok (detected 10.34)
checking for pkg liburiparser ... ok (detected 0.9.3)
checking for pkg avahi-client ... ok (detected 0.7)
checking for cmake ... ok
checking for cc -lstdc++ ... ok
checking for pkg libva >=0.38.0 ... ok (detected 1.15.0)
checking for pkg libva-drm >=0.38.0 ... ok (detected 1.15.0)
checking for cc sys/inotify.h ... ok
checking for cc inotify_init1 ... ok
checking for cc dvbcsa/dvbcsa.h ... ok
checking for cc -ldvbcsa ... ok
fetching dvb-scan files ... ok
checking for cc epoll_create1 ... ok
checking for pkg dbus-1 ... ok (detected 1.12.16)
Compiler:
Using C compiler: cc
Using LD flags: -ldvbcsa
Build for arch: x86_64
Binaries:
Using PYTHON: python
Using GZIP: gzip
Using BZIP2: bzip2
Options:
pie yes
ccdebug no
cardclient yes
cwc yes
cccam yes
capmt yes
constcw yes
linuxdvb yes
satip_server yes
satip_client yes
hdhomerun_client yes
hdhomerun_static yes
iptv yes
tsfile yes
dvbscan yes
timeshift yes
trace yes
avahi yes
zlib yes
libav yes
ffmpeg_static yes
libx264 yes
libx264_static yes
libx265 yes
libx265_static yes
libvpx yes
libvpx_static yes
libtheora yes
libtheora_static yes
libvorbis yes
libvorbis_static yes
libfdkaac no
libfdkaac_static no
libopus yes
libopus_static yes
nvenc no
vaapi yes
mmal no
omx no
inotify yes
epoll yes
pcre no
pcre2 yes
uriparser yes
ccache no
tvhcsa yes
bundle no
pngquant no
kqueue no
dbus_1 yes
android no
gtimer_check no
slow_memoryinfo no
libsystemd_daemon no
pcloud_cache yes
ddci yes
cclang_threadsan no
gperftools no
execinfo yes
mmx yes
sse2 yes
W_unused_result yes
f_stack_protector yes
f_stack_protector_strong yes
f_stack_check yes
f_PIE yes
fdatasync yes
getloadavg yes
atomic32 yes
atomic64 yes
atomic_time_t yes
atomic_ptr yes
bitops64 yes
lockowner yes
qsort_r yes
gmtoff yes
recvmmsg yes
sendmmsg yes
ifnames yes
py_gzip yes
bin_pkg_config yes
bin_xgettext yes
bin_msgmerge yes
bin_gzip yes
bin_bzip2 yes
ssl yes
linuxdvbapi yes
linuxdvb_ca yes
upnp yes
bin_cmake yes
stdcpp yes
libogg_static yes
hwaccels yes
inotify_h yes
inotify_init1 yes
dvbcsa yes
epoll_create1 yes
mpegts yes
mpegts_dvb yes
Packages:
openssl 1.1.1f
zlib 1.2.11
libpcre2-8 10.34
liburiparser 0.9.3
avahi-client 0.7
libva 1.15.0
libva-drm 1.15.0
dbus-1 1.12.16
Installation paths:
Prefix: /usr/local
Binaries: ${prefix}/bin
Libraries: ${prefix}/lib
Data files: ${prefix}/share
Man pages: ${datadir}/man
Final Binary:
/home/alin/tvheadend/build.linux/tvheadend
Tvheadend Data Directory:
/usr/local/share/tvheadend
$################### log output end ####################
Build tvheadend:
./Autobuild.sh
This step will take sometime ... you will see a lot of workings. Is OK as long as the long will end with something like:
$################### log output ####################
dpkg-deb: building package 'tvheadend-dbg' in '../tvheadend-dbg_4.3-2063~gd88549603~focal_amd64.deb'.
dpkg-deb: building package 'tvheadend' in '../
tvheadend_4.3-2063~gd88549603~focal_amd64.deb '.
make[1]: Leaving directory '/home/alin/tvheadend'
dpkg-genbuildinfo --build=binary
dpkg-genchanges --build=binary >../tvheadend_4.3-2063~gd88549603~focal_amd64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
dpkg-source --after-build .
dpkg-buildpackage: info: binary-only upload (no source included)
doozer-versioned-artifact:/home/alin/tvheadend/../tvheadend_4.3-2063~gd88549603~focal_amd64.deb:deb:application/x-deb:tvheadend_4.3-2063~gd88549603~focal_amd64.deb
doozer-versioned-artifact:/home/alin/tvheadend/../tvheadend-dbg_4.3-2063~gd88549603~focal_amd64.deb:deb:application/x-deb:tvheadend-dbg_4.3-2063~gd88549603~focal_amd64.deb
doozer-versioned-artifact:/home/alin/tvheadend/../tvheadend_4.3-2063~gd88549603~focal_amd64.changes:changes:text/plain:tvheadend_4.3-2063~gd88549603~focal_amd64.changes
$################### log output end ####################
From this last log you need to copy the file name bolded (in your case will have a different number after '4.3-')
In my case is:
tvheadend_4.3-2063~gd88549603~focal_amd64.deb
cd ..
Install tvheadend:
sudo dpkg -i tvheadend_4.3-2063~gd88549603~focal_amd64.deb
Intel GPU:
sudo apt install i965-va-driver-shaders
We have to add also user hts to render (or your group that has access to GPU):
sudo gpasswd -a hts render
newgrp render
verify:
groups hts
alin@alin-cm8pcb4r:~$ groups hts
hts : hts render
Now we see user is part of render.
start tvheadend:
sudo systemctl start tvheadend.service
in browser:
http://[IP_NUMBER]:9981
From this point you need to perfom the tvheadend setup (not in the scope of this tutorial).
Setup GPU transcoding:
--> make sure you have 'Expert' settings enabled
[browser menus]:
Configuration / Stream / Codec Profiles --> Add
Codec: h264_vaapi
Name: h264_vaapi
Description: ....
Deniterlace: checked (very important)
Height: 0
Hardware acceleration: checked (very important)
Device name: i915 v.1.6.0 (/dev/dri/renderD128) (very important)
Bitrate: 0
Buffer factor: 3
Rate control: 1 (CQP)
Constant QP: 27
Ignore B-Frames: 0
Quality: 1
Press Create button.
[browser menus]:
Configuration / Stream / Stream Profiles --> Add
Type: Transcode/av-lib
Profile name: h264
Enabled: checked
Default: checked
Comment: ...
Data timeout: 5
Default priority: Normal
Force priority: 0
Restart on error: checked
Continue if descrambling fails: checked
Descrembling timeout: 2000
Switch to another service: checked
Prefered services vide type: None
Container: Matroska
Video codec profile: h264_vaapi (very important)
Source video codec: EMPTY
Audio codec profile: web-aac
Source audio codec: EMPTY
Subtitle codec profile: Copy
Source subtitle codec: EMPTY
Press Create button.
Note:
all 'very important' are required.
Now you are ready to test: open one stream with tvh server and check the Tvheadend log:
2022-12-09 10:53:37.821 transcode: 0001: 01:MPEG2VIDEO: ==> Using profile h264_vaapi
2022-12-09 10:53:37.822 transcode: 0001: 02:AC3: ==> Using profile webtv-aac
To confirm you are using GPU for trancoding you need to send:
sudo intel_gpu_top
When you don't have any streams open you will see all numbers: 0; after you open streams you should see values non-zero in: Render/3D , Video and VideoEnhance.
Next we enable 'low power' encoding.
For that we need to use ffmpeg + spwan (because tvheadend is not supporting this feature natively). This will come with some limitation (like you have to use http instead of htsp for transport, Kodi client will require this feature to be enabled by hand).
Install ffmpeg:
sudo apt install ffmpeg
We check the location of ffmpeg:
which ffmpeg
alin@alin-cm8pcb4r:~$ which ffmpeg
/usr/bin/ffmpeg
We have to create a spawn profile:
[browser menus]:
Configuration / Stream / Stream Profiles --> Add
Type: MPEG-TS Spawn/built-in
Profile name: fh264
Enabled: checked
Default: checked
Comment: ...
Data timeout: 5
Default priority: Normal
Force priority: 0
Restart on error: checked
Continue if descrambling fails: checked
Descrembling timeout: 2000
Switch to another service: checked
Prefered services vide type: None
Command line:
/usr/bin/ffmpeg -hide_banner -err_detect ignore_err -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i pipe:0 -map 0:v -vf 'deinterlace_vaapi' -low_power 1 -c:v h264_vaapi -profile:v high -qp:v 28 -map 0:a? -c:a aac -b:a 64k -map 0:s? -c:s copy -fflags +nobuffer+discardcorrupt+genpts+flush_packets -avoid_negative_ts disabled -f mpegts pipe:1
Mime type: video/mp2t
Kill signal (pipe): SIGTERM
Kill timeout: 15
Rewrite Service ID: 0
Rewrite PMT: uncheck
Rewrite PAT: uncheck
Rewrite SDT: uncheck
Rewrite NIT: uncheck
Rewrite EIT: uncheck
Press Create button.
To confirm you are using GPU for trancoding you need to send:
sudo intel_gpu_top
When you don't have any streams open you will see all numbers: 0; after you open streams you should see values zero for Render/3D and non-zero in: Video and VideoEnhance.
Also you shuld see a power consumption differece (CLK freq difference) on first row.
In my particular tests (720p60 mpeg2-->h264):
- without low power (native tvh): 360 --> 410 MHz with average 0.8W
- with low power (ffmpeg): 290 -- 370 MHz with average 0.4W
After we manage to implement low power natively in tvh I will update this tutorial.