diff --git a/modules/videoio/src/cap_msmf.cpp b/modules/videoio/src/cap_msmf.cpp index a55f919ed1..4b234b8cae 100644 --- a/modules/videoio/src/cap_msmf.cpp +++ b/modules/videoio/src/cap_msmf.cpp @@ -1159,7 +1159,12 @@ bool CvCapture_MSMF::configureVideoOutput(MediaType newType, cv::uint32_t outFor { initStream(dwVideoStreamIndex, nativeFormat); } - return initStream(dwVideoStreamIndex, newFormat); + if (!initStream(dwVideoStreamIndex, newFormat)) + { + return false; + } + outputVideoFormat = outFormat; + return true; } bool CvCapture_MSMF::configureOutput() diff --git a/modules/videoio/test/test_camera.cpp b/modules/videoio/test/test_camera.cpp index fc269959c3..8b0f0efe83 100644 --- a/modules/videoio/test/test_camera.cpp +++ b/modules/videoio/test/test_camera.cpp @@ -119,6 +119,21 @@ TEST(DISABLED_videoio_camera, v4l_read_mjpg) capture.release(); } +TEST(DISABLED_videoio_camera, msmf_read_yuyv) +{ + VideoCapture capture(CAP_MSMF); + ASSERT_TRUE(capture.isOpened()); + ASSERT_TRUE(capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('Y', 'U', 'Y', 'V'))); + std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl; + std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl; + std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl; + std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl; + int fourcc = (int)capture.get(CAP_PROP_FOURCC); + std::cout << "FOURCC code: " << cv::format("0x%8x", fourcc) << std::endl; + test_readFrames(capture); + capture.release(); +} + TEST(DISABLED_videoio_camera, v4l_open_mjpg) { VideoCapture capture;