FFMPEG Transcode H265 video from 10-bit to 8-bit
Asked Answered
T

1

1

I'm trying to convert my library from various formats into HEVC 8-bit mainly to shrink my library down. This is generally working but I've run into an issue when trying to convert an existing file from 10-bit H.265 to 8-bit H.265.

My processor, an Intel Celeron J3455, supports hardware decoding/encoding H.265 at 8-bit but only hardware decoding for 10-bit.

It seems that ffmpeg is attempting to keep the video as 10-bit to match the source rather than allowing me to convert to 8-bit and this is creating an error.

Here is a sample command that I'm using:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i input.10bit.x265.mkv -map 0:0 -c:v:0 hevc_vaapi -vf "scale_vaapi=w=-1:h=1080" -b:v 4027047 -map 0:1 -c:a:0 aac -b:a 384000 -ac 6 -map 0:s -scodec copy -map_metadata:g -1 -metadata JBDONEVERSION=1 -metadata JBDONEDATE=2020-06-06T20:52:36.072Z -map_chapters 0 output.8bit.x265.mkv

The error I get is:

[hevc_vaapi @ 0x5568b27fb1c0] No usable encoding entrypoint found for profile VAProfileHEVCMain10 (18).

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

From what I can tell ffmpeg looks at the source and selectes VAProfileHEVCMain10 instead of VAProfileHEVCMain. I'd like to force it to output 8-bit.

I've tried adding -pix_fmt yuv420p but that gives me this error:

Incompatible pixel format 'yuv420p' for codec 'hevc_vaapi', auto-selecting format 'vaapi_vld' 

I've also tried making this change to the command: "scale_vaapi=w=-1:h=1080,format=yuv420p"

However that gives me the error:

Impossible to convert between the formats supported by the filter 'Parsed_scale_vaapi_0' and the filter 'auto_scaler_0'

Error reinitializing filters!

Any suggestions?

Teshatesla answered 6/6, 2020 at 18:34 Comment(0)
P
2

I've just been figuring this out as well. Your problem is (most likely) with -hwaccel_output_format vaapi. It's outputting frames in VAAPI format and not the format you need (read more here, also quoted a section at the end of this comment). So you need to adjust for 8-bit there: -hwaccel_output_format yuv420p.

In my case I'm also using -filter_hw_device vaapi0 -vf format=nv12|vaapi,hwupload (specified before -c:v hevc_vaapi). The vaapi0 here is a named device I've initialised with init_hw_device. You're directly using a path with -hwaccel_device so I'm not sure what the name of your device is, but you may not need these extra arguments.


The hardware codecs used by VAAPI are not able to access frame data in arbitrary memory. Therefore, all frame data needs to be uploaded to hardware surfaces connected to the appropriate device before being used. All VAAPI hardware surfaces in ffmpeg are represented by the vaapi pixfmt (the internal layout is not visible here, though).

The hwaccel decoders normally output frames in the associated hardware format, but by default the ffmpeg utility download the output frames to normal memory before passing them to the next component. This allows the decoder to work standlone to make decoding faster without any additional options:

ffmpeg -hwaccel vaapi ... -i input.mp4 -c:v libx264 ... output.mp4

For other outputs, the option -hwaccel_output_format can be used to specify the format to be used. This can be a software format (which formats are usable depends on the driver), or it can be the vaapi hardware format to indicate that the surface should not be downloaded.

Pitiless answered 24/3, 2022 at 20:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.