diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc index d539b38264..ef1300f9b6 100644 --- a/modules/video_capture/video_capture_impl.cc +++ b/modules/video_capture/video_capture_impl.cc @@ -149,11 +149,17 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame, } // Not encoded, convert to I420. - if (frameInfo.videoType != VideoType::kMJPEG && - CalcBufferSize(frameInfo.videoType, width, abs(height)) != - videoFrameLength) { - RTC_LOG(LS_ERROR) << "Wrong incoming frame length."; - return -1; + if (frameInfo.videoType != VideoType::kMJPEG) { + // Allow buffers larger than expected. On linux gstreamer allocates buffers + // page-aligned and v4l2loopback passes us the buffer size verbatim which + // for most cases is larger than expected. + // See https://github.com/umlaeute/v4l2loopback/issues/190. + if (auto size = CalcBufferSize(frameInfo.videoType, width, abs(height)); + videoFrameLength < size) { + RTC_LOG(LS_ERROR) << "Wrong incoming frame length. Expected " << size + << ", Got " << videoFrameLength << "."; + return -1; + } } int stride_y = width;