obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

obs-ffmpeg: Add HDR and HEVC to VA-API encoder

Open yuriy-chumak opened this issue 1 year ago • 5 comments

Description

Add HEVC support to create HDR videos using FFmpeg VA-API on Linux.

EDIT (jpark37): I have reworked the changes to add NV12 back to support narrow SDR again. I've also consolidated the files, so no new files are added.

Motivation and Context

HDR streaming.

How Has This Been Tested?

  • HDR video was recorded using "FFmpeg HEVC VAAPI" encoder with AMD hardware device selected. Video parameters were tested using the ffprobe tool. The recorded video was played using mpv.
  • HDR Video was streamed to YouTube using "FFmpeg HEVC VAAPI" encoder with AMD hardware device selected. Video parameters were tested using the Stats for nerds YouTube feature. The streamed video was viewed using chrome web browser.

AMD Ryzen 7 5700U with Radeon Graphics

EDIT (jpark37): I've tested recordings with these combinations on my Rocket Lake on Ubuntu 22.10.

  • H.264, Rec. 709, NV12
  • HEVC, Rec. 709, NV12
  • HEVC, Rec. 2100 (PQ), P010
  • HEVC, Rec. 2100 (HLG), P010
  • ENABLE_HEVC=OFF builds, and the encoders are removed

I was unable to test streaming because we seem to require CBR, and the Intel HEVC encoder reports that it only supports CQP (for me at least).

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

yuriy-chumak avatar Jul 18 '22 17:07 yuriy-chumak

This PR should stay as draft until #6678 is tested and merged.

tytan652 avatar Jul 18 '22 18:07 tytan652

I've reworked the changes to bring back NV12 support, and fit our style.

The PR itself is ready, but I'm holding this in draft status until #7850 is merged because I stacked the changes on top.

jpark37 avatar Nov 26 '22 20:11 jpark37

Back to draft because I remounted on #7916.

jpark37 avatar Dec 11 '22 19:12 jpark37

Also suspect we need to be using VAHdrMetaDataHDR10 for metadata, but the only code example I could find is FFmpeg vf_tonemap_vaapi.c, which is a filter and not an encoder. It might still be applicable, but that's not a research project I want to take on.

jpark37 avatar Dec 11 '22 19:12 jpark37

#7916 was merged, so back to reviewable.

jpark37 avatar Dec 11 '22 23:12 jpark37

Resolved the merge conflict.

jpark37 avatar Mar 20 '23 16:03 jpark37