Skip to content
Snippets Groups Projects
Commit f229b6f4 authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by Guillaume Roguez
Browse files

daemon: fix crash when no video device is present

Refs #63235

Change-Id: I05a2f65eedc1c83027573011de9cca31812cfcbb
parent e6933795
No related branches found
No related tags found
No related merge requests found
...@@ -492,13 +492,15 @@ void VideoEncoder::prepareEncoderContext(bool is_video) ...@@ -492,13 +492,15 @@ void VideoEncoder::prepareEncoderContext(bool is_video)
if (is_video) { if (is_video) {
// resolution must be a multiple of two // 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; 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; dstHeight_ = encoderCtx_->height = height ? atoi(height) : 0;
const char *framerate = av_dict_get(options_, "framerate", auto framerate_param = av_dict_get(options_, "framerate", NULL, 0);
NULL, 0)->value; const char *framerate = framerate_param ? framerate_param->value : nullptr;
const int DEFAULT_FPS = 30; const int DEFAULT_FPS = 30;
const int fps = framerate ? atoi(framerate) : DEFAULT_FPS; const int fps = framerate ? atoi(framerate) : DEFAULT_FPS;
encoderCtx_->time_base = (AVRational) {1, fps}; encoderCtx_->time_base = (AVRational) {1, fps};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment