@@ -53,17 +53,18 @@ static const char *GetC353EncoderName(void *)
5353 return obs_module_text (" Encoder.C353" );
5454}
5555
56- static inline void FindDevice (DeviceId &id, const wchar_t *name)
56+ static bool FindDevice (DeviceId &id, const wchar_t *name)
5757{
5858 vector<DeviceId> devices;
5959 DShow::VideoEncoder::EnumEncoders (devices);
6060
6161 for (const DeviceId &device : devices) {
6262 if (device.name .find (name) != string::npos) {
6363 id = device;
64- break ;
64+ return true ;
6565 }
6666 }
67+ return false ;
6768}
6869
6970/*
@@ -81,7 +82,10 @@ inline bool DShowEncoder::Update(obs_data_t *settings)
8182 DStr deviceName;
8283 DeviceId id;
8384
84- FindDevice (id, device);
85+ if (!FindDevice (id, device) || id.name .empty ()) {
86+ blog (LOG_WARNING, " win-dshow-encoder: device '%ls' not found" , device);
87+ return false ;
88+ }
8589
8690 video_t *video = obs_encoder_video (context);
8791 const struct video_output_info *voi = video_output_get_info (video);
@@ -102,13 +106,24 @@ inline bool DShowEncoder::Update(obs_data_t *settings)
102106 width = 1280 ;
103107 height = 720 ;
104108 }
109+ uint32_t fps_num;
110+ uint32_t fps_den;
111+
112+ if (voi) {
113+ fps_num = voi->fps_num ;
114+ fps_den = voi->fps_den ;
115+ } else {
116+ blog (LOG_ERROR, " win-dshow-encoder: video output info is null, using default 30 fps" );
117+ fps_num = 30 ;
118+ fps_den = 1 ;
119+ }
105120
106- int keyint = keyint_sec * voi-> fps_num / voi-> fps_den ;
121+ int keyint = keyint_sec * fps_num / fps_den;
107122
108- frameInterval = voi-> fps_den * 10000000 / voi-> fps_num ;
123+ frameInterval = fps_den * 10000000LL / fps_num;
109124
110- config.fpsNumerator = voi-> fps_num ;
111- config.fpsDenominator = voi-> fps_den ;
125+ config.fpsNumerator = fps_num;
126+ config.fpsDenominator = fps_den;
112127 config.bitrate = bitrate;
113128 config.keyframeInterval = keyint;
114129 config.cx = width;
0 commit comments