Feature #6224
openenable Intel VAAPI low power encoding (for iGPU 9+)
0%
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