Commit f229b6f4 authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by Guillaume Roguez

daemon: fix crash when no video device is present

Refs #63235

Change-Id: I05a2f65eedc1c83027573011de9cca31812cfcbb
parent e6933795
......@@ -492,13 +492,15 @@ void VideoEncoder::prepareEncoderContext(bool is_video)
if (is_video) {
// resolution must be a multiple of two
char *width = av_dict_get(options_, "width", NULL, 0)->value;
auto width_param = av_dict_get(options_, "width", NULL, 0);
char *width = width_param ? width_param->value : nullptr;
dstWidth_ = encoderCtx_->width = width ? atoi(width) : 0;
char *height = av_dict_get(options_, "height", NULL, 0)->value;
auto height_param = av_dict_get(options_, "height", NULL, 0);
char *height = height_param ? height_param->value : nullptr;
dstHeight_ = encoderCtx_->height = height ? atoi(height) : 0;
const char *framerate = av_dict_get(options_, "framerate",
NULL, 0)->value;
auto framerate_param = av_dict_get(options_, "framerate", NULL, 0);
const char *framerate = framerate_param ? framerate_param->value : nullptr;
const int DEFAULT_FPS = 30;
const int fps = framerate ? atoi(framerate) : DEFAULT_FPS;
encoderCtx_->time_base = (AVRational) {1, fps};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment