Dont initialize vaapi on nvidia (fixes crash on startup)

This commit is contained in:
dec05eba 2023-04-01 23:24:12 +02:00
parent 9f0b98dc5e
commit cc63bffaf7
2 changed files with 10 additions and 7 deletions

2
TODO
View File

@ -42,3 +42,5 @@ JPEG color range on amd seems to produce too bright video with h264 but not hevc
Support recording screen/monitor on amd/intel. Support recording screen/monitor on amd/intel.
Better configure vaapi. The file size is too large. Better configure vaapi. The file size is too large.
Better colors for vaapi. It looks a bit off when recording vscode for example. Better colors for vaapi. It looks a bit off when recording vscode for example.
Clear vaapi surface (for focused window).

View File

@ -490,13 +490,15 @@ static bool check_if_codec_valid_for_hardware(const AVCodec *codec, gpu_vendor v
if(!codec_context) if(!codec_context)
return false; return false;
codec_context->width = 32; codec_context->width = 512;
codec_context->height = 32; codec_context->height = 512;
if(vendor != GPU_VENDOR_NVIDIA) {
if(!vaapi_create_codec_context(codec_context)) { if(!vaapi_create_codec_context(codec_context)) {
avcodec_free_context(&codec_context); avcodec_free_context(&codec_context);
return false; return false;
} }
}
bool success = false; bool success = false;
success = avcodec_open2(codec_context, codec_context->codec, NULL) == 0; success = avcodec_open2(codec_context, codec_context->codec, NULL) == 0;
@ -526,7 +528,6 @@ static const AVCodec* find_h264_encoder(gpu_vendor vendor) {
return checked_success ? codec : nullptr; return checked_success ? codec : nullptr;
} }
static const AVCodec* find_h265_encoder(gpu_vendor vendor) { 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"); const AVCodec *codec = avcodec_find_encoder_by_name(vendor == GPU_VENDOR_NVIDIA ? "hevc_nvenc" : "hevc_vaapi");
if(!codec) if(!codec)