Browse Source

Have v4l2 read MJPEG video by default

Fixes #2826

Thanks to @seanlaguna for finding a fix
pull/2851/head
tux3 10 years ago
parent
commit
aef447d7c7
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 1
      src/video/cameradevice.cpp
  2. 16
      src/video/videoframe.cpp

1
src/video/cameradevice.cpp

@ -164,6 +164,7 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode) @@ -164,6 +164,7 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
{
av_dict_set(&options, "video_size", QString("%1x%2").arg(mode.width).arg(mode.height).toStdString().c_str(), 0);
av_dict_set(&options, "framerate", QString().setNum(mode.FPS).toStdString().c_str(), 0);
av_dict_set(&options, "pixel_format", "mjpeg", 0);
}
#endif
#ifdef Q_OS_OSX

16
src/video/videoframe.cpp

@ -32,6 +32,22 @@ VideoFrame::VideoFrame(AVFrame* frame, int w, int h, int fmt, std::function<void @@ -32,6 +32,22 @@ VideoFrame::VideoFrame(AVFrame* frame, int w, int h, int fmt, std::function<void
frameOther{nullptr}, frameYUV420{nullptr}, frameRGB24{nullptr},
width{w}, height{h}, pixFmt{fmt}
{
// Silences pointless swscale warning spam
// See libswscale/utils.c:1153 @ 74f0bd3
frame->color_range = AVCOL_RANGE_MPEG;
if (pixFmt == AV_PIX_FMT_YUVJ420P)
pixFmt = AV_PIX_FMT_YUV420P;
else if (pixFmt == AV_PIX_FMT_YUVJ411P)
pixFmt = AV_PIX_FMT_YUV411P;
else if (pixFmt == AV_PIX_FMT_YUVJ422P)
pixFmt = AV_PIX_FMT_YUV422P;
else if (pixFmt == AV_PIX_FMT_YUVJ444P)
pixFmt = AV_PIX_FMT_YUV444P;
else if (pixFmt == AV_PIX_FMT_YUVJ440P)
pixFmt = AV_PIX_FMT_YUV440P;
else
frame->color_range = AVCOL_RANGE_UNSPECIFIED;
if (pixFmt == AV_PIX_FMT_YUV420P)
frameYUV420 = frame;
else if (pixFmt == AV_PIX_FMT_RGB24)

Loading…
Cancel
Save