Repository navigation
qsv: enable QSV encoder via FFmpeg API - #6446
Conversation
Co-authored-by: Kesy, Anton <[email protected]>
548add5 to
a7b85b0
Compare
galad87
left a comment
There was a problem hiding this comment.
Seems mostly ok, however encavcodec.c has become a complete mess, and it still doesn't pass the correct timestamps to the encoders, so if the source is VFR the rate control won't be able to correctly assign the bits.
Is there any plan to add a way to insert Dolby Vision RPUs and HDR10 Plus SEIs in the FFmpeg QSV encoders?
|
|
||
| #if HB_PROJECT_FEATURE_QSV | ||
| // postponed encoder initialization, reused code from encavcodecInit() | ||
| if (hb_hwaccel_is_full_hardware_pipeline_enabled(pv->job) && |
There was a problem hiding this comment.
This postponed initialization is a quite ugly, isn't there a way to avoid it? Like manually creating a hw frames context, and is the hw frames context so expensive that needs to be reused?
There was a problem hiding this comment.
not the prettiest piece of code, but the initialization logic in ffmpeg and handbrake is different. in case of two separate contexts, it requires copying frames each time, which is quite expensive.
| hb_buffer_t * buf; | ||
| #if HB_PROJECT_FEATURE_QSV | ||
| if (hb_qsv_hw_filters_via_video_memory_are_enabled(graph->job)) | ||
| if (hb_hwaccel_is_full_hardware_pipeline_enabled(graph->job) && |
There was a problem hiding this comment.
Same as in encavcodec.c, is there a way to avoid waiting for these hw frames contexts?
There was a problem hiding this comment.
ffmpeg inside creates the video memory hw frames context for output frames during first frame processing
|
We can review and possibly close off the following:
|
Basic TestingFirst pass in testing. Just basic "full path" encodes with each encoder:
Everything seems fine. Good utilisation of the GPU. HyperEncode TestingIt looks like there may be a performance regression using HyperEncode A370M.txt ~176fps Seeping utilisation spread across the GPU and Integrated GPU but it's 40~60% range. Update: Moved to 101.6314 driver and hyperencode isn't being used anymore. It's all going to the A370M |
|
Do we want to merge this and then improve things later? |
|
I will double check this PR with latest changes from master and let you know. In regards to the Hyper Encode issue, it looks that it is reproducible even with current major release. Investigation is in progress and fix might be provided separately. |
|
Thank you for feedback. PR has been updated and tested against latest master. |
| * Reload colorimetry settings in case custom | ||
| * values were set in the encoder_options string. | ||
| */ | ||
| pv->job->color_prim_override = pv->context->color_primaries; |
There was a problem hiding this comment.
It's too late to set these, because the previous values have already been set to the mp4/mkv/webm container.
There was a problem hiding this comment.
Can you point out where?
I am exiting earlier from the init function https://github.com/galinart/HandBrake/blob/enable-ffmpeg-qsv-encoder/libhb/encavcodec.c#L947
There was a problem hiding this comment.
Somewhere in encavcodecInit, hopefully the avcodec_open won't change the context values.
|
Encoding a 10bit video to 10bit using the full hw path seems to introduce a lot of artifacts, but 10bit to 8bit and 8bit to 8bit looks ok. |
We are not able to reproduce on Battlemage, LunarLake, AlderLake. Can you please share more information?
Thanks |
|
Here's a sample to reproduce the issue. I tried on Lunar Lake, with the latest driver provided by Windows Update:
|
|
@galad87 thanks for the details. Still no luck..
|
|
It doesn't happen with the latest driver, so I guess whatever was going wrong has already been fixed 🎉 |
|
Thanks for confirmation! |
|
I've run a suite of tests on it. Couple of questions:
Otherwise, All my encodes, including 10bit and 8bit sources are working so it's looking mostly good. |
|
Thanks for the feedback.
|
|
Is there any plan to implement AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE in the QSV encoder? Without that it would be quite hard to support Dolby Vision and HDR10 Plus. Obviously a way to insert NALs and SEIs and OBUs would be better, but with AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE at least we could do it in HandBrake by reusing the existing code for HEVC. |
|
I suggest to merge it while we don't have much conflicts and not block other PRs Hyper Encode issues are on track on our side and will be addressed as separate PR along with driver update. |
For now, I don't see that as planned. I will keep you updated. |
Switched QSV encoding from native VPL to FFmpeg API.
It comes with a lot of advantages:
Both
--enable-hw-decoding qsvand--enable-qsv-decodingCLI options supported for backward compatibility.