Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NVENC AV1 FFmpeg encoder #8794

Closed
wants to merge 2 commits into from

Conversation

Bleuzen
Copy link

@Bleuzen Bleuzen commented Apr 22, 2023

Description

Adds NVENC AV1 support to obs-ffmpeg

image

Motivation and Context

Linux users can use NVENC only for H264 and HEVC currently. However current gen GPUs do support encoding AV1, which should be exposed as an option in OBS.

How Has This Been Tested?

Tested recording in mp4 and mkv so far on a Linux system with Nvidia RTX40xx GPU.

TODO

  • Testing (general functionality / performance / different bitrate & quality settings...)
  • The detection of AV1 support is not optimal - only ffmpeg is checked if it offers the av1_nvenc encoder but afaik this does not guarantee that the GPU really supports it

Types of changes

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

Checklist:

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

@Bleuzen Bleuzen marked this pull request as draft April 22, 2023 21:39
@gxalpha gxalpha added the Enhancement Improvement to existing functionality label Apr 22, 2023
@norihiro
Copy link
Contributor

The first word for each commit title should be capitalized, for example, like below. However, I think all commits should be squashed into one commit rather than making a 'fix' commit.

- obs-ffmpeg: fix nvenc av1 encoder name
+ obs-ffmpeg: Fix nvenc av1 encoder name

@Bleuzen Bleuzen force-pushed the nvenc-av1-ffmpeg branch 2 times, most recently from ead038e to 50270b2 Compare April 27, 2023 20:44
@Bleuzen
Copy link
Author

Bleuzen commented Apr 27, 2023

@norihiro Thanks for the hint. Commits are now squashed, rebased on latest master and commit message is corrected.

@Bleuzen Bleuzen force-pushed the nvenc-av1-ffmpeg branch 2 times, most recently from cdd89bf to 38031cd Compare August 19, 2023 00:50
@Bleuzen
Copy link
Author

Bleuzen commented Aug 19, 2023

Just tested with the "obs_extract_av1_headers" function from this PR:
#8832
it fixes the first seconds of the video being corrupted & mkv recording

@M-Ro
Copy link

M-Ro commented Aug 19, 2023

av1 = nvenc_codec_exists("av1_nvenc", NULL);

This seems to return false for me, which is a bit strange on a 4080. I've definitely got AV1 NVenc working as I currently use it without issue through ffmpeg 6. Any ideas on what I might be missing?

libnvidia-encode.so.1 points to libnvidia-encode.so.535.98 which are the most recent drivers.

Edit: Nevermind, I'm probably compiling against a stale version of libavcodec.

@ryzendew
Copy link

i have tested this on Arch linux and it worked so well thank you for your hardwork

@ryzendew
Copy link

one issue when using MKV the video is blank but mp4 works

@Bleuzen
Copy link
Author

Bleuzen commented Oct 31, 2023

@ryzendew

one issue when using MKV the video is blank but mp4 works

Known issue, as I wrote in the initial post. This is because OBS currently lacks a function to extract av1 headers. However there is another PR adding it. You need to merge this too:
#9475
And add the call to the obs_extract_av1_headers function here:
https://github.com/obsproject/obs-studio/pull/8794/files#diff-fc007c567208a25eac997f8ad710956b8be02bbc3f95b401719c971830ca42ebR293

@ryzendew
Copy link

@ryzendew

one issue when using MKV the video is blank but mp4 works

Known issue, as I wrote in the initial post. This is because OBS currently lacks a function to extract av1 headers. However there is another PR adding it. You need to merge this too: #9475 And add the call to the obs_extract_av1_headers function here: https://github.com/obsproject/obs-studio/pull/8794/files#diff-fc007c567208a25eac997f8ad710956b8be02bbc3f95b401719c971830ca42ebR293

thank you i hope they merge your work soon AV1 is a god send!

@Bleuzen
Copy link
Author

Bleuzen commented Nov 12, 2023

when using MKV the video is blank

should be fixed now with latest commit (at least in my testing)

@ryzendew
Copy link

when using MKV the video is blank

should be fixed now with latest commit (at least in my testing)

Yes the MKV issues is solved i just did a 3 hour recording without any issues thank you for such hard work i can now record on linux again!

@Bleuzen Bleuzen marked this pull request as ready for review November 18, 2023 00:43
@ANISANi
Copy link

ANISANi commented Nov 24, 2023

Cool all work with
GPU: 4070-max q.
OS: Arch linux.
Tested Bitrate: CBR 6000 Kbps, CQP: CQ level 20-50. (at 20 - bitrate up to 150 000 Kbps, at 50 - 41 000 Kbps).
Driver: 535.43.16 with open-dkms.
using mkv.

@ghost
Copy link

ghost commented Dec 15, 2023

Any news if this will get merged ?

@ryzendew
Copy link

sometimes the Video still goes blank and it's random

13:13:49.024: ==== Recording Start =============================================== 13:13:49.025: [ffmpeg muxer: 'adv_file_output'] Writing file '/home/matt/2023-12-26 13-13-48.mkv'... 13:13:49.226: [FFmpeg NVENC encoder: 'advanced_video_recording'] Applying DTS value corrections 13:13:53.137: [ffmpeg muxer: 'adv_file_output'] Output of file '/home/matt/2023-12-26 13-13-48.mkv' stopped 13:13:53.137: Output 'adv_file_output': stopping 13:13:53.137: Output 'adv_file_output': Total frames output: 234 13:13:53.137: Output 'adv_file_output': Total drawn frames: 244 (247 attempted) 13:13:53.137: Output 'adv_file_output': Number of lagged frames due to rendering lag/stalls: 3 (1.2%)

@ryzendew
Copy link

ryzendew commented Jan 5, 2024

Going to test the newest changes now

@ryzendew
Copy link

ryzendew commented Jan 5, 2024

VLC is trash! mpv shows the video is working!

@derrod derrod self-assigned this Jan 20, 2024
@derrod
Copy link
Member

derrod commented Jan 22, 2024

Likely to be superseeded by #10122 which adds support for the native NVENC encoder on Linux (only without texture sharing for now).

@ryzendew
Copy link

ryzendew commented Feb 8, 2024

I tried the other 2 AV1 Pr's and both failed to work
image
with the same error and i would post on the PR's but i can't yet the PR asked for testers
obs.log

This is the only PR that works for AV1 on my 4070

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants