5

on Linux i am trying to encode file to H€VC using hardware acceleration. Successful attempt is:

ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i '/path/file.mkv' -vcodec libx265 -crf 28 '/path/file.mp4'

but it is slow like 30fps, "ffmpeg -codecs|grep 265" shows: (encoders: libx265 nvenc_hevc hevc_amf hevc_nvenc hevc_qsv hevc_v4l2m2m hevc_vaapi )

so i have tried hevc_vaapi:

ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i '/path/file.mkv' -vcodec hevc_vaapi -crf 28 '/path/file.mp4'

but it fails:

Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
[AVIOContext @ 0x55d831121340] Statistics: 0 seeks, 0 writeouts
[aac @ 0x55d831142a00] Qavg: 30414.529
[aac @ 0x55d831142a00] 2 frames left in the queue on closing
[AVIOContext @ 0x55d831109ec0] Statistics: 65536 bytes read, 0 seeks
Conversion failed!

$ ffmpeg -hwaccels shows "

Hardware acceleration methods:
vdpau
cuda
vaapi
qsv
drm

"

$ vaapi shows this (seems like va-api is there, mesa driver)

$ ls /dev/dri/*

/dev/dri/card0 /dev/dri/renderD128

/dev/dri/by-path:

pci-0000:0a:00.0-card pci-0000:0a:00.0-render

What do you think about this error or how would you proceed to discover which ffmpeg parameters to use for HW H€VC accelerated?

Update: i think that the "-hwaccel vaapi" may be redundant parameter

16851556
  • 493
  • 2
  • 5
  • 17

3 Answers3

5

I think that it requires proper encoding parameters like -vf 'format=nv12,hwupload' and following one-liner may work if you have VAAPI driver:

echo "Input file:" && read -r i && echo "Quality: 25=identic, 30=a bit worse but small file size, or other numbers:" && read -r q && ffmpeg -vaapi_device /dev/dri/renderD128 -i "$i" -vf 'format=nv12,hwupload' -c:v hevc_vaapi -f mp4 -rc_mode 1 -qp "$q" "$i.hevc.mp4"
16851556
  • 493
  • 2
  • 5
  • 17
2

none of other answer helps me, not until I install intel-media-va-driver-non-free following the Installation of https://wiki.debian.org/HardwareVideoAcceleration.

sudo apt install intel-media-va-driver-non-free

It should help if you are using intel gpu.

And if you need to scale video, use '-vf scale_vaapi=640:360' to scale video without string like 'format=nv12,hwupload'

Carl Cheung
  • 121
  • 3
1

May I suggest you add the two following flags:

  • -hwaccel vaapi
  • -hwaccel_output_format vaapi

so the command line look like this:

ffmpeg -v verbose -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i INPUT.VIDEO -vf 'format=nv12,hwupload' -c:v hevc_vaapi OUTPUT.mp4

(on my computer, specify vaapi_device is not necessary)