From 9de40e5a97930de5d002ae3460db25bb2cb6c54c Mon Sep 17 00:00:00 2001 From: sudden6 Date: Fri, 28 Sep 2018 21:35:38 +0200 Subject: [PATCH] fix(video): don't pass invalid pixel format strings to ffmpeg --- src/video/cameradevice.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/video/cameradevice.cpp b/src/video/cameradevice.cpp index 242e4b9cb..79e9061ff 100644 --- a/src/video/cameradevice.cpp +++ b/src/video/cameradevice.cpp @@ -191,8 +191,9 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode) av_dict_set(&options, "video_size", videoSize.c_str(), 0); av_dict_set(&options, "framerate", framerate.c_str(), 0); const std::string pixelFormatStr = v4l2::getPixelFormatString(mode.pixel_format).toStdString(); - const char* pixel_format = pixelFormatStr.c_str(); - if (strncmp(pixel_format, "unknown", 7) != 0) { + // don't try to set a format string that doesn't exist + if (pixelFormatStr != "unknown" && pixelFormatStr != "invalid") { + const char* pixel_format = pixelFormatStr.c_str(); av_dict_set(&options, "pixel_format", pixel_format, 0); } }