Opened 8 months ago

Last modified 3 months ago

#7764 new enhancement

Support for HW accelerated 10-bit -> 8-bit conversion support

Reported by: eero-t Owned by:
Priority: wish Component: undetermined
Version: git-master Keywords: vaapi
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:

MediaSDK sample application can transcode 10-bit (HEVC) content to 8-bit (AVC), so same should(?) be possible in HW accelerated manner also with VAAPI and/or QSV backend.

However, it fails, and one needs to do the conversion with round trip through CPU side.

How to reproduce:

ffmpeg -y -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i SES.Astra.UHD.Test.1.2160p.UHDTV.AAC.HEVC.x265-LiebeIst.mkv -c:v h264_vaapi -vf format=nv12 output.h264
ffmpeg version N-93264-g85051febc6 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
Input #0, matroska,webm, from 'SES.Astra.UHD.Test.1.2160p.UHDTV.AAC.HEVC.x265-LiebeIst.mkv':
    encoder         : libebml v1.3.1 + libmatroska v1.4.2
    creation_time   : 2015-10-03T13:49:42.000000Z
  Duration: 00:01:49.29, start: 0.816000, bitrate: 18484 kb/s
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn, 60 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_vaapi))
Press [q] to stop, [?] for help
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0: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
Conversion failed!

FFmpeg gives exactly the same error with i965 driver (in Ubuntu 18.04) as with above git version of iHD media-driver.

QSV with git version of MediaSDK gives also exactly the same error:

ffmpeg -y -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v hevc_qsv -i SES.Astra.UHD.Test.1.2160p.UHDTV.AAC.HEVC.x265-LiebeIst.mkv -c:v h264_qsv -vf format=nv12  output.h264

With MediaSDK sample application, it works fine (when one tells with -ec option the format to which the 10-bit data needs to be converted):

sample_multi_transcode -i::h265 SES.Astra.UHD.Test.1.2160p.UHDTV.AAC.HEVC.x265-LiebeIst.h265 -ec::nv12 -o::h264 output.h264

With VAAPI, one can do the conversion with roundtrip through CPU side, but that's several times slower:

ffmpeg -y -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i SES.Astra.UHD.Test.1.2160p.UHDTV.AAC.HEVC.x265-LiebeIst.mkv -c:v h264_vaapi -vf hwdownload,format=nv12,hwupload output.h264

FYI: Test video is from here:

Change History (5)

comment:1 Changed 7 months ago by cehoyos

  • Keywords vaapi added
  • Priority changed from normal to wish

comment:2 Changed 4 months ago by eero-t

There was earlier bug in MSDK or media-driver, but nowadays format conversion works also with MSDK sample_decode application which with this is easier to check against:
sample_decode -hw h265 -w 300 -h 300 -nv12 -i 1920x1080_10bit_50fps.h265 -o /dev/null

comment:3 Changed 4 months ago by eero-t

VAAPI & QSV command lines work (at least with latest Git versions of everything), if one does scale_vaapi/scale_qsv=<size> in addition to format conversion. Just doing format conversion fails (which is nearly reverse of issue #7691).

Hoewever, even that fails, if input is 4K instead of FullHD (tested on KBL).

comment:4 Changed 3 months ago by tvsht

  • Cc added

Just got hit by this on AMD RAVEN APU with the same error, while trying to transcode 10bit hevc to h264 via vaapi

comment:5 Changed 3 months ago by eero-t

Just got hit by this on AMD RAVEN APU with the same error, while trying to transcode 10bit hevc to h264 via vaapi

  • Does that HW and its driver support 10bit HEVC decode + 10-bit -> 8-bit conversion i.e. are you sure it's FFmpeg VAAPI backend and not driver issue?
  • If yes, does it work if you add scaling, like happens with iHD?
  • If yes, have you still a problem in 4K like I have with iHD?
Note: See TracTickets for help on using tickets.