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

obs-ffmpeg: Implement texture encoding for VAAPI

Open nowrep opened this issue 1 year ago • 5 comments

Description

Implement texture encoding for VAAPI

Motivation and Context

Based on #8312

How Has This Been Tested?

Tested with mesa driver.

Types of changes

  • Performance enhancement (non-breaking change which improves efficiency)

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.

nowrep avatar Jan 24 '24 12:01 nowrep

Encoder crashes/fails on intel when using bframes. Unfortunately ffmpeg encoder dying this way hangs obs... Otherwise it seems to work.

--- Edit

Actually caught a

warning: [FFmpeg VAAPI encoder: 'advanced_video_recording'] Failed to export VA surface handle: operation failed
warning: [FFmpeg VAAPI encoder: 'advanced_video_recording'] vaapi_encode: failed to create texture hw frame

With a shorter attempt. But this is just logged during shutdown it may be unrelated to the PR.

kkartaltepe avatar Jan 24 '24 17:01 kkartaltepe

Not sure why would it cause issues with bframes, it is copying into VA surfaces allocated by ffmpeg which should keep them until they are used and only release them after.

Can you post full log?

nowrep avatar Jan 24 '24 17:01 nowrep

Sorry I forgot to mention the most important part that it was with AV1, which does not support bframes on intel iirc. Confirmed this happens with the existing master so its unrelated to this PR.

kkartaltepe avatar Jan 25 '24 03:01 kkartaltepe

So that looks like intel driver issue. Both obs and ffmpeg checks if the driver support bframes for given profile.

nowrep avatar Jan 25 '24 06:01 nowrep

Got my multi gpu device, and I guess im lucky and I'm not seeing the fallback warning so I presume its working at copying textures across devices without falling back to host memory. Tested and it is working cross device.

kkartaltepe avatar Jan 28 '24 02:01 kkartaltepe

Added libdrm dep to non-legacy cmake and changed the function names in logging.

nowrep avatar Apr 18 '24 14:04 nowrep

It seems master might be broken, gpu_encode_available ends up being false as the video mix's using_nv12_tex = false. In this case the regular encode path is taken, however the texture encoder doesnt fallback as it is working as expected. So libobs ends up jumping into the missing encode function on the texture encoder.

kkartaltepe avatar Apr 18 '24 15:04 kkartaltepe

With #10567 it should be working again.

kkartaltepe avatar Apr 18 '24 15:04 kkartaltepe