@@ -491,11 +491,27 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float
491491 }
492492 }
493493
494+ if (GSConfig.EnableVideoCaptureParameters )
495+ {
496+ res = wrap_av_dict_parse_string (&s_video_codec_arguments, GSConfig.VideoCaptureParameters .c_str (), " =" , " :" , 0 );
497+ if (res < 0 )
498+ {
499+ LogAVError (res, " av_dict_parse_string() for video failed: " );
500+ InternalEndCapture (lock);
501+ return false ;
502+ }
503+ }
504+
494505 if (hwconfig)
495506 {
496507 Console.WriteLn (Color_StrongGreen, fmt::format (" Trying to use {} hardware device for video encoding." ,
497- wrap_av_hwdevice_get_type_name (hwconfig->device_type )));
498- res = wrap_av_hwdevice_ctx_create (&s_video_hw_context, hwconfig->device_type , nullptr , nullptr , 0 );
508+ wrap_av_hwdevice_get_type_name (hwconfig->device_type )));
509+ const char * device = nullptr ;
510+ if (AVDictionaryEntry* dev = wrap_av_dict_get (s_video_codec_arguments, " vaapi_device" , nullptr , 0 ))
511+ device = dev->value ;
512+ if (AVDictionaryEntry* dev = wrap_av_dict_get (s_video_codec_arguments, " hwaccel_device" , nullptr , 0 ))
513+ device = dev->value ;
514+ res = wrap_av_hwdevice_ctx_create (&s_video_hw_context, hwconfig->device_type , device, nullptr , 0 );
499515 if (res < 0 )
500516 {
501517 LogAVError (res, " av_hwdevice_ctx_create() failed: " );
@@ -539,17 +555,6 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float
539555 }
540556 }
541557
542- if (GSConfig.EnableVideoCaptureParameters )
543- {
544- res = wrap_av_dict_parse_string (&s_video_codec_arguments, GSConfig.VideoCaptureParameters .c_str (), " =" , " :" , 0 );
545- if (res < 0 )
546- {
547- LogAVError (res, " av_dict_parse_string() for video failed: " );
548- InternalEndCapture (lock);
549- return false ;
550- }
551- }
552-
553558 if (output_format->flags & AVFMT_GLOBALHEADER)
554559 s_video_codec_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
555560
0 commit comments