Project

General

Profile

Actions

Feature #6224

open

enable Intel VAAPI low power encoding (for iGPU 9+)

Added by Alin Gherghescu over 2 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Normal
Category:
Transcoding
Target version:
-
Start date:
2022-11-29
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I am trying to add low power encoding (H264) to a J4125 (iGPU 9.5) in order to save power.
I have two option (that I know):
1. use ffmpeg spawn with "-low_power 1"

/home/hts/bin/ffmpeg -hide_banner -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 -preset veryslow -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

ffmpeg is compiled from: https://github.com/FFmpeg/FFmpeg and copied to /home/hts/bin/

This works very well (with some significant delay when I switch channel) ... I can see with intel_gpu_top that is using less resources (not using Render / 3D / 0).
Downside --> I am forced to use http transport

2. use tvheadend with built in ffmpeg with low_power mode enabled (for H264 encoding).
advantage: I can use htsp transport
For that I did the following:
https://github.com/tvheadend/tvheadend/blob/master/src/transcoding/transcode/hwaccels/vaapi.c --> line 586 -- 589 changed:

if (!(hwaccel_context =
tvhva_context_create("encode", avctx, VAEntrypointEncSlice))) {
return -1;
}

with:

if (avctx->codec->id == AV_CODEC_ID_H264){
if (!(hwaccel_context =
tvhva_context_create("encode", avctx, VAEntrypointEncSliceLP))) {
return -1;
}
}
else{
if (!(hwaccel_context =
tvhva_context_create("encode", avctx, VAEntrypointEncSlice))) {
return -1;
}
}

The goal is to return VAEntrypointEncSliceLP for H264 encoding and VAEntrypointEncSlice for other codecs.

Everything compiled and worked but when I checked the gpu top I did not see the same results as with ffmpeg with low_power 1 ... meaning the Render / 3D / 0 was > 0 for tvheadend build ; also the CLK was higher.
I see that tvheadend is using an old ffmpeg build (4.4.1) --> is this the reason why my change was not working? meaning ffmpeg is too old to recognize "VAEntrypointEncSliceLP"?
If anyone sees and other reason please let me know.
Also, can I update the scipt to download a new version of ffmpeg (in Makefile.ffmpeg)? Does anyone has a stable version to recommend?

To clarify:
I have GUC enabled and vaapi is showing the LP codec.

alin@alin-gk41:~$ dmesg | grep guc
[ 1.771782] Setting dangerous option enable_guc - tainting kernel
[ 1.807689] i915 0000:00:02.0: [drm] GuC firmware i915/glk_guc_62.0.0.bin version 62.0 submission:disabled

alin@alin-gk41:~$ 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
VAProfileMPEG2Main : VAEntrypointVLD
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


Files

variable.png (12.7 KB) variable.png Alin Gherghescu, 2022-12-11 02:15
UI_code.png (31.9 KB) UI_code.png Alin Gherghescu, 2022-12-11 02:18
UI.png (6.15 KB) UI.png Alin Gherghescu, 2022-12-11 02:19
avlib.png (10.9 KB) avlib.png Alin Gherghescu, 2022-12-11 02:21
tvh_low_power_1.zip (565 KB) tvh_low_power_1.zip logs with low power = 1 Alin Gherghescu, 2022-12-11 02:27
tvh_low_power_0.zip (344 KB) tvh_low_power_0.zip logs with low power = 0 Alin Gherghescu, 2022-12-11 02:27
variable.png (6.61 KB) variable.png Alin Gherghescu, 2022-12-13 03:31
UI_code.png (22.2 KB) UI_code.png Alin Gherghescu, 2022-12-13 03:32
UI.png (6.26 KB) UI.png Alin Gherghescu, 2022-12-13 03:32
avlib.png (22.6 KB) avlib.png Alin Gherghescu, 2022-12-13 03:33
UI_full.png (91.3 KB) UI_full.png Alin Gherghescu, 2022-12-14 07:14
h264_docs.zip (376 KB) h264_docs.zip Alin Gherghescu, 2023-01-07 08:03
Actions

Also available in: Atom PDF