From cc63bffaf7fc04ca2cefb7ae77dd426ef34afaff Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 1 Apr 2023 23:24:12 +0200 Subject: [PATCH] Dont initialize vaapi on nvidia (fixes crash on startup) --- TODO | 4 +++- src/main.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index d1a47fd..bcd913a 100644 --- a/TODO +++ b/TODO @@ -41,4 +41,6 @@ JPEG color range on amd seems to produce too bright video with h264 but not hevc Support recording screen/monitor on amd/intel. Better configure vaapi. The file size is too large. -Better colors for vaapi. It looks a bit off when recording vscode for example. \ No newline at end of file +Better colors for vaapi. It looks a bit off when recording vscode for example. + +Clear vaapi surface (for focused window). diff --git a/src/main.cpp b/src/main.cpp index 12fb37a..5ace938 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -490,12 +490,14 @@ static bool check_if_codec_valid_for_hardware(const AVCodec *codec, gpu_vendor v if(!codec_context) return false; - codec_context->width = 32; - codec_context->height = 32; + codec_context->width = 512; + codec_context->height = 512; - if(!vaapi_create_codec_context(codec_context)) { - avcodec_free_context(&codec_context); - return false; + if(vendor != GPU_VENDOR_NVIDIA) { + if(!vaapi_create_codec_context(codec_context)) { + avcodec_free_context(&codec_context); + return false; + } } bool success = false; @@ -526,7 +528,6 @@ static const AVCodec* find_h264_encoder(gpu_vendor vendor) { return checked_success ? codec : nullptr; } - static const AVCodec* find_h265_encoder(gpu_vendor vendor) { const AVCodec *codec = avcodec_find_encoder_by_name(vendor == GPU_VENDOR_NVIDIA ? "hevc_nvenc" : "hevc_vaapi"); if(!codec)