Project

General

Profile

RE: TVHeadend build and install on Lubuntu 20.04 64bit wi... » lubuntu_22.04_master-ver3 -web.txt

instructions to install tvheadend to Lubuntu 22.04 - Alin Gherghescu, 2023-12-27 01:54

 
1
Commands:
2
sudo systemctl disable tvheadend
3
sudo systemctl enable tvheadend
4
sudo systemctl stop tvheadend
5
sudo systemctl start tvheadend
6

    
7

    
8

    
9

    
10

    
11
HW:
12
NUC element with Celeron 6305
13

    
14
download ISO LUBUNTU 22.04:
15
https://www.cdimage.ubuntu.com/lubuntu/releases/22.04/release/lubuntu-22.04.1-desktop-amd64.iso
16

    
17
flash ISO to USB 32G using rufus-3.21
18
Note: make sure you plug the USB in USB2.0 socket (black).
19

    
20
Install Lubuntu to PC with default settings; connect also to internet.
21

    
22
Update some settings:
23
Preference / LXQt setting / Power Management: Idle --> uncheck Enable Idleness Watcher : Close
24
Preference / LXQt setting / Monitor Settings: 1280 x 720 : Save : Yes
25
Preference / LXQt setting / LXQt Configuration Center : Openbox Settings --> Desktops : Number of desktops : 1
26
Preference / Screen Saver : Mode : Disable screen saver
27

    
28
Install SSH:
29
System Tools / QTerminal
30

    
31
sudo apt update
32
sudo apt install ssh
33

    
34
check status:
35
systemctl status sshd.service
36

    
37
if is not working:
38
sudo systemctl enable sshd
39
and:
40
sudo systemctl start sshd
41

    
42

    
43
connect over SSH to continue:
44

    
45
Update to latest software:
46
sudo apt update
47
sudo apt upgrade
48
sudo reboot
49
sudo apt autoremove --purge
50

    
51
alin@alin-cm8pcb4r:~$ uname -a
52
alin@alin-cmcm2fb:~$ uname -a
53
Linux alin-cmcm2fb 5.15.0-57-generic #63-Ubuntu SMP Thu Nov 24 13:43:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
54

    
55

    
56

    
57
install OneVPL:
58
https://dgpu-docs.intel.com/installation-guides/ubuntu/ubuntu-jammy-legacy.html
59

    
60
Before you start let's check that GPU is supported in OneVPL.
61

    
62
check:
63
sudo lspci -nn | grep -e VGA
64

    
65
alin@alin-cmcm2fb:~$ sudo lspci -nn | grep -e VGA
66
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:9a78] (rev 01)
67

    
68
you can go on: https://dgpu-docs.intel.com/devices/hardware-table.html
69
and search for: "9a78" (check after [8086:****]).
70
and see is: Intel® UHD Graphics --> Gen Xe --> Tiger Lake
71

    
72
according to:
73
https://www.intel.com/content/www/us/en/developer/articles/guide/onevpl-installation-guide.html
74
GPU suported are:
75
Hardware 	Intel Core process 11 generation and above, Intel Xe Max discrete graphic and above
76

    
77

    
78
Step 1 Add package repository:
79
To install the repositories.intel.com/graphics package repository, add the following to your Ubuntu installation. Prior to copy/pasting to your console, you may want to run sudo ls and enter your password to prevent the commands from being swallowed by the sudo password prompt:
80

    
81
sudo apt-get install -y gpg-agent wget
82
wget -qO - https://repositories.intel.com/graphics/intel-graphics.key |
83
  sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
84
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu jammy legacy' | \
85
  sudo tee  /etc/apt/sources.list.d/intel.gpu.jammy.list
86

    
87

    
88
Step 2 Install run-time packages:
89
You can install the GPU software packages by running the following:
90
sudo apt-get update
91
sudo apt-get install \
92
  intel-opencl-icd \
93
  intel-level-zero-gpu level-zero \
94
  intel-media-va-driver-non-free libmfx1 libmfxgen1 libvpl2
95

    
96

    
97
Step 3 Install developer packages:
98
sudo apt-get install -y \
99
  libigc-dev \
100
  intel-igc-cm \
101
  libigdfcl-dev \
102
  libigfxcmrt-dev \
103
  level-zero-dev
104

    
105

    
106
Step 4 Configuring permissions for render:
107

    
108
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:
109

    
110
stat -c "%G" /dev/dri/render*
111
--> render
112

    
113
alin@alin-cmcm2fb:~$ stat -c "%G" /dev/dri/render*
114
render
115

    
116
groups ${USER}
117

    
118
alin@alin-cmcm2fb:~$ groups ${USER}
119
alin : alin adm cdrom sudo dip plugdev lpadmin sambashare
120

    
121
My user doesn't have access because is not part of 'render'
122
Now we add my user (alin) to group (render)
123

    
124
sudo gpasswd -a ${USER} render
125

    
126
alin@alin-cmcm2fb:~$ sudo gpasswd -a ${USER} render
127
Adding user alin to group render
128

    
129
newgrp render
130

    
131
verify:
132
groups ${USER}
133

    
134
alin@alin-cmcm2fb:~$ groups ${USER}
135
alin : alin adm cdrom sudo dip plugdev render lpadmin sambashare
136

    
137
Now we see user is part of render.
138

    
139

    
140
Review of available hw codecs:
141
sudo apt-get install libva-drm2 vainfo
142

    
143
sudo vainfo
144

    
145
alin@alin-cmcm2fb:~$ sudo vainfo
146
Trying display: wayland
147
error: XDG_RUNTIME_DIR not set in the environment.
148
Trying display: x11
149
error: can't connect to X server!
150
Trying display: drm
151
libva info: VA-API version 1.16.0
152
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
153
libva info: Found init function __vaDriverInit_1_16
154
libva info: va_openDriver() returns 0
155
vainfo: VA-API version: 1.16 (libva 2.16.0)
156
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.6.4 (aca8ee0)
157
vainfo: Supported profile and entrypoints
158
      VAProfileNone                   : VAEntrypointVideoProc
159
      VAProfileNone                   : VAEntrypointStats
160
      VAProfileMPEG2Simple            : VAEntrypointVLD
161
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
162
      VAProfileMPEG2Main              : VAEntrypointVLD
163
      VAProfileMPEG2Main              : VAEntrypointEncSlice
164
      VAProfileH264Main               : VAEntrypointVLD
165
      VAProfileH264Main               : VAEntrypointEncSlice
166
      VAProfileH264Main               : VAEntrypointFEI
167
      VAProfileH264Main               : VAEntrypointEncSliceLP
168
      VAProfileH264High               : VAEntrypointVLD
169
      VAProfileH264High               : VAEntrypointEncSlice
170
      VAProfileH264High               : VAEntrypointFEI
171
      VAProfileH264High               : VAEntrypointEncSliceLP
172
      VAProfileVC1Simple              : VAEntrypointVLD
173
      VAProfileVC1Main                : VAEntrypointVLD
174
      VAProfileVC1Advanced            : VAEntrypointVLD
175
      VAProfileJPEGBaseline           : VAEntrypointVLD
176
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
177
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
178
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
179
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
180
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
181
      VAProfileVP8Version0_3          : VAEntrypointVLD
182
      VAProfileHEVCMain               : VAEntrypointVLD
183
      VAProfileHEVCMain               : VAEntrypointEncSlice
184
      VAProfileHEVCMain               : VAEntrypointFEI
185
      VAProfileHEVCMain               : VAEntrypointEncSliceLP
186
      VAProfileHEVCMain10             : VAEntrypointVLD
187
      VAProfileHEVCMain10             : VAEntrypointEncSlice
188
      VAProfileHEVCMain10             : VAEntrypointEncSliceLP
189
      VAProfileVP9Profile0            : VAEntrypointVLD
190
      VAProfileVP9Profile1            : VAEntrypointVLD
191
      VAProfileVP9Profile2            : VAEntrypointVLD
192
      VAProfileVP9Profile3            : VAEntrypointVLD
193
      VAProfileHEVCMain12             : VAEntrypointVLD
194
      VAProfileHEVCMain12             : VAEntrypointEncSlice
195
      VAProfileHEVCMain422_10         : VAEntrypointVLD
196
      VAProfileHEVCMain422_10         : VAEntrypointEncSlice
197
      VAProfileHEVCMain422_12         : VAEntrypointVLD
198
      VAProfileHEVCMain422_12         : VAEntrypointEncSlice
199
      VAProfileHEVCMain444            : VAEntrypointVLD
200
      VAProfileHEVCMain444            : VAEntrypointEncSliceLP
201
      VAProfileHEVCMain444_10         : VAEntrypointVLD
202
      VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
203
      VAProfileHEVCMain444_12         : VAEntrypointVLD
204
      VAProfileHEVCSccMain            : VAEntrypointVLD
205
      VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
206
      VAProfileHEVCSccMain10          : VAEntrypointVLD
207
      VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
208
      VAProfileHEVCSccMain444         : VAEntrypointVLD
209
      VAProfileHEVCSccMain444         : VAEntrypointEncSliceLP
210
      VAProfileAV1Profile0            : VAEntrypointVLD
211
      VAProfileHEVCSccMain444_10      : VAEntrypointVLD
212
      VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP
213

    
214
the data format is:
215
CODEC/profile : Encoder/Decoder
216

    
217
      VAProfileH264High               : VAEntrypointVLD
218
      VAProfileH264High               : VAEntrypointEncSlice
219
      VAProfileH264High               : VAEntrypointFEI
220
      VAProfileH264High               : VAEntrypointEncSliceLP
221

    
222
This is: H264, Profile high with decoder (VAEntrypointVLD) , Encoder (VAEntrypointEncSlice) and LowPower encoder (VAEntrypointEncSliceLP)
223
Is importand to identify if your GPU has this low power (LP) codecs available.
224
In my case I have low power for: H264 profiles Main, High and Constrained
225

    
226

    
227
sudo apt update
228
sudo apt upgrade
229

    
230
Install gpu tools (required to check the work load on GPU):
231
sudo apt install intel-gpu-tools
232

    
233

    
234
Enable GUC firmware (this is a must for encoding with low power codec):
235

    
236
we need to generate a file:
237
sudo vi /etc/modprobe.d/i915.conf
238
with the text (only one line) --> press key 'I':
239
options i915 enable_guc=3
240
--> press esc
241
--> press key : and w
242
--> press key : and q
243

    
244
sudo update-initramfs -k all -u
245
sudo update-grub
246

    
247
sudo reboot
248

    
249
Verify GuC was enabled:
250
sudo dmesg | grep guc
251

    
252
alin@alin-cmcm2fb:~$ sudo dmesg | grep guc
253
[    2.234080] Setting dangerous option enable_guc - tainting kernel
254
[    2.941075] i915 0000:00:02.0: [drm] GuC firmware i915/tgl_guc_62.0.0.bin version 62.0 submission:enabled
255

    
256
-> it sounds scary 'dangerous option' ... but is fine.
257

    
258

    
259
this is required to scan channels later on:
260
sudo apt update
261
sudo apt install w-scan
262
sudo apt upgrade
263

    
264

    
265
clean up:
266
sudo apt autoremove --purge
267

    
268

    
269
Compile tvheadend:
270

    
271
cd ~
272
git clone https://github.com/tvheadend/tvheadend.git
273

    
274

    
275
sudo apt update
276
sudo apt install gettext libssl-dev cmake libpcre2-dev libdvbcsa-dev libva-dev liburiparser-dev libavahi-client-dev debhelper zlib1g-dev 
277
sudo apt install python-is-python3
278
sudo apt install python3-requests
279

    
280

    
281
cd tvheadend
282
./configure
283

    
284

    
285
$###################  log output  ####################
286
alin@alin-cmcm2fb:~/tvheadend$ ./configure
287
Checking support/features
288
  checking for cc execinfo.h ...                    ok
289
  checking for cc -mmmx ...                         ok
290
  checking for cc -msse2 ...                        ok
291
  checking for cc -Wunused-result ...               ok
292
  checking for cc -fstack-protector ...             ok
293
  checking for cc -fstack-protector-strong ...      ok
294
  checking for cc -fstack-check ...                 ok
295
  checking for cc -fPIE ...                         ok
296
  checking for cc strlcat ...                       fail
297
  checking for cc strlcpy ...                       fail
298
  checking for cc fdatasync ...                     ok
299
  checking for cc getloadavg ...                    ok
300
  checking for cc atomic32 ...                      ok
301
  checking for cc atomic64 ...                      ok
302
  checking for cc atomic_time_t ...                 ok
303
  checking for cc atomic_ptr ...                    ok
304
  checking for cc bitops64 ...                      ok
305
  checking for cc lockowner ...                     ok
306
  checking for cc qsort_r ...                       ok
307
  checking for cc stime ...                         fail
308
  checking for cc gmtoff ...                        ok
309
  checking for cc recvmmsg ...                      ok
310
  checking for cc sendmmsg ...                      ok
311
  checking for cc libiconv ...                      fail
312
    ^ using build-in glibc iconv routines
313
  checking for cc ifnames ...                       ok
314
  checking for cc cclang_threadsan ...              fail
315
  checking for py module gzip ...                   ok
316
  checking for pkg-config ...                       ok
317
  checking for xgettext ...                         ok
318
  checking for msgmerge ...                         ok
319
  checking for gzip ...                             ok
320
  checking for bzip2 ...                            ok
321
  checking for pkg openssl  ...                     ok (detected 3.0.2)
322
  checking for cc linux/dvb/version.h ...           ok
323
  checking for pkg zlib  ...                        ok (detected 1.2.11)
324
  checking for pkg libpcre2-8  ...                  ok (detected 10.39)
325
  checking for pkg liburiparser  ...                ok (detected 0.9.6)
326
  checking for pkg avahi-client  ...                ok (detected 0.8)
327
  checking for cmake ...                            ok
328
  checking for cc -lstdc++ ...                      ok
329
  checking for pkg libva >=0.38.0 ...               ok (detected 1.16.0)
330
  checking for pkg libva-drm >=0.38.0 ...           ok (detected 1.16.0)
331
  checking for cc sys/inotify.h ...                 ok
332
  checking for cc inotify_init1 ...                 ok
333
  checking for cc dvbcsa/dvbcsa.h ...               ok
334
  checking for cc -ldvbcsa ...                      ok
335
  fetching dvb-scan files ...                       ok
336
  checking for cc epoll_create1 ...                 ok
337
  checking for pkg dbus-1  ...                      ok (detected 1.12.20)
338

    
339
Compiler:
340
  Using C compiler:                        cc
341
  Using LD flags:                           -ldvbcsa
342
  Build for arch:                          x86_64
343

    
344
Binaries:
345
  Using PYTHON:                            python
346
  Using GZIP:                              gzip
347
  Using BZIP2:                             bzip2
348

    
349
Options:
350
  pie                                      yes
351
  ccdebug                                  no
352
  cardclient                               yes
353
  cwc                                      yes
354
  cccam                                    yes
355
  capmt                                    yes
356
  constcw                                  yes
357
  linuxdvb                                 yes
358
  satip_server                             yes
359
  satip_client                             yes
360
  hdhomerun_client                         yes
361
  hdhomerun_static                         yes
362
  iptv                                     yes
363
  tsfile                                   yes
364
  dvbscan                                  yes
365
  timeshift                                yes
366
  trace                                    yes
367
  avahi                                    yes
368
  zlib                                     yes
369
  libav                                    yes
370
  ffmpeg_static                            yes
371
  libx264                                  yes
372
  libx264_static                           yes
373
  libx265                                  yes
374
  libx265_static                           yes
375
  libvpx                                   yes
376
  libvpx_static                            yes
377
  libtheora                                yes
378
  libtheora_static                         yes
379
  libvorbis                                yes
380
  libvorbis_static                         yes
381
  libfdkaac                                no
382
  libfdkaac_static                         no
383
  libopus                                  yes
384
  libopus_static                           yes
385
  nvenc                                    no
386
  vaapi                                    yes
387
  mmal                                     no
388
  omx                                      no
389
  inotify                                  yes
390
  epoll                                    yes
391
  pcre                                     no
392
  pcre2                                    yes
393
  uriparser                                yes
394
  ccache                                   no
395
  tvhcsa                                   yes
396
  bundle                                   no
397
  pngquant                                 no
398
  kqueue                                   no
399
  dbus_1                                   yes
400
  android                                  no
401
  gtimer_check                             no
402
  slow_memoryinfo                          no
403
  libsystemd_daemon                        no
404
  pcloud_cache                             yes
405
  ddci                                     yes
406
  cclang_threadsan                         no
407
  gperftools                               no
408
  execinfo                                 yes
409
  mmx                                      yes
410
  sse2                                     yes
411
  W_unused_result                          yes
412
  f_stack_protector                        yes
413
  f_stack_protector_strong                 yes
414
  f_stack_check                            yes
415
  f_PIE                                    yes
416
  fdatasync                                yes
417
  getloadavg                               yes
418
  atomic32                                 yes
419
  atomic64                                 yes
420
  atomic_time_t                            yes
421
  atomic_ptr                               yes
422
  bitops64                                 yes
423
  lockowner                                yes
424
  qsort_r                                  yes
425
  gmtoff                                   yes
426
  recvmmsg                                 yes
427
  sendmmsg                                 yes
428
  ifnames                                  yes
429
  py_gzip                                  yes
430
  bin_pkg_config                           yes
431
  bin_xgettext                             yes
432
  bin_msgmerge                             yes
433
  bin_gzip                                 yes
434
  bin_bzip2                                yes
435
  ssl                                      yes
436
  linuxdvbapi                              yes
437
  linuxdvb_ca                              yes
438
  upnp                                     yes
439
  bin_cmake                                yes
440
  stdcpp                                   yes
441
  libogg_static                            yes
442
  hwaccels                                 yes
443
  inotify_h                                yes
444
  inotify_init1                            yes
445
  dvbcsa                                   yes
446
  epoll_create1                            yes
447
  mpegts                                   yes
448
  mpegts_dvb                               yes
449

    
450
Packages:
451
  openssl                                  3.0.2
452
  zlib                                     1.2.11
453
  libpcre2-8                               10.39
454
  liburiparser                             0.9.6
455
  avahi-client                             0.8
456
  libva                                    1.16.0
457
  libva-drm                                1.16.0
458
  dbus-1                                   1.12.20
459

    
460
Installation paths:
461
  Prefix:                                  /usr/local
462
  Binaries:                                ${prefix}/bin
463
  Libraries:                               ${prefix}/lib
464
  Data files:                              ${prefix}/share
465
  Man pages:                               ${datadir}/man
466

    
467
Final Binary:
468
  /home/alin/tvheadend/build.linux/tvheadend
469

    
470
Tvheadend Data Directory:
471
  /usr/local/share/tvheadend
472
$###################  log output end  ####################
473

    
474

    
475

    
476
Build tvheadend:
477
./Autobuild.sh
478

    
479
$###################  log output ####################
480
make[1]: Leaving directory '/home/alin/tvheadend'
481
 dpkg-genbuildinfo --build=binary -O../tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.buildinfo
482
 dpkg-genchanges --build=binary -O../tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.changes
483
dpkg-genchanges: info: binary-only upload (no source code included)
484
 dpkg-source --after-build .
485
dpkg-buildpackage: info: binary-only upload (no source included)
486
doozer-versioned-artifact:/home/alin/tvheadend/../tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.deb:deb:application/x-deb:tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.deb
487
doozer-versioned-artifact:/home/alin/tvheadend/../tvheadend-dbg_4.3-2070~g2beb6c9c8~jammy_amd64.deb:deb:application/x-deb:tvheadend-dbg_4.3-2070~g2beb6c9c8~jammy_amd64.deb
488
doozer-versioned-artifact:/home/alin/tvheadend/../tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.changes:changes:text/plain:tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.changes
489
$###################  log output end  ####################
490

    
491
From this last log you need to copy the file name bolded (in your case will have a different number after '4.3-')
492
In my case is: tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.deb
493

    
494

    
495
cd ..
496

    
497
Install tvheadend:
498

    
499
sudo dpkg -i tvheadend_4.3-2070~g2beb6c9c8~jammy_amd64.deb
500

    
501
Intel GPU:
502
sudo apt install i965-va-driver-shaders
503

    
504
We have to add also user hts to render (or your group that has access to GPU):
505

    
506
sudo gpasswd -a hts render
507

    
508
newgrp render
509

    
510
verify:
511
groups hts
512

    
513
alin@alin-cmcm2fb:~$ groups hts
514
hts : hts render
515

    
516
Now we see user is part of render.
517

    
518
restart:
519
sudo reboot
520

    
521
in browser:
522
http://<IP_NUMBER>:9981
523

    
524
selecteaza 
525
ro-Digi (fara Timisoara)
526

    
527
Setup GPU transcoding:
528
--> make sure you have Expert settings selected
529
[browser menus]: 
530
Configuration / Stream / Codec Profiles --> Add
531
Codec: h264_vaapi
532
Name: h264_vaapi
533
Description: ....
534
Deniterlace: checked (very important)
535
Height: 0
536
Hardware acceleration: checked (very important)
537
Device name: i915 v.1.6.0 (/dev/dri/renderD128) (very important)
538
Bitrate: 0
539
Buffer factor: 3
540
Rate control: 1 (CQP)
541
Constant QP: 27
542
Ignore B-Frames: 0
543
Quality: 1
544

    
545
Press Create button.
546

    
547
[browser menus]: 
548
Configuration / Stream / Stream Profiles --> Add
549
Type: Transcode/av-lib
550
Profile name: h264
551
Enabled: checked
552
Default: checked
553
Comment: ...
554
Data timeout: 5
555
Default priority: Normal
556
Force priority: 0
557
Restart on error: checked
558
Continue if descrambling fails: checked
559
Descrembling timeout: 2000
560
Switch to another service: checked
561
Prefered services vide type: None
562
Container: Matroska
563
Video codec profile: h264_vaapi (very important)
564
Source video codec: EMPTY
565
Audio codec profile: web-aac
566
Source audio codec: EMPTY
567
Subtitle codec profile: Copy
568
Source subtitle codec: EMPTY
569

    
570
Press Create button.
571

    
572
Note:
573
all 'very important' are required.
574

    
575
Now you are ready to test: open one stream with tvh server and check the Tvheadend log:
576
2022-12-09 10:53:37.821 transcode: 0001: 01:MPEG2VIDEO: ==> Using profile h264_vaapi
577
2022-12-09 10:53:37.822 transcode: 0001: 02:AC3: ==> Using profile webtv-aac
578

    
579
To confirm you are using GPU for trancoding you need to send:
580
sudo intel_gpu_top
581

    
582
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.
583

    
584

    
585

    
586

    
(1-1/2)