# Read camera failed

**URL:** <https://forum.opencv.org/t/read-camera-failed/14746>\
**Category:** C++\
**Created:** [October 4, 2023, 12:19pm UTC](https://forum.opencv.org/t/read-camera-failed/14746 "2023-10-04T12:19:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocvfasc](https://avatars.discourse-cdn.com/v4/letter/o/eb8c5e/32.png) [@ocvfasc](https://forum.opencv.org/u/ocvfasc)\
**Post date:** [October 4, 2023, 12:19pm UTC](https://forum.opencv.org/t/read-camera-failed/14746/1 "2023-10-04T12:19:24Z")

</div>

Hello,

I am trying to stream an IP camera, via sdp extension,

int main()  
{  
VideoCapture input(“CAM\_configuration.sdp”);  
if (!input.isOpened())  
{  
cout \<\< “failed” \<\< endl;  
return -1;  
}

```
Mat img;

while (true)
{
	if (!input.read(img))
		break;
	imshow("cameraRead", img);
	waitKey(2);
}
return 0;

```

}

I get the error,  
[INFO:0] global C:\build\master\_winpack-build-win64-vc15\opencv\modules\videoio\src\backend\_plugin.cpp (233) cv::impl::PluginBackend::PluginBackend Video I/O: loaded plugin ‘FFmpeg OpenCV Video I/O plugin’  
[rtp @ 000002cbcd6c5c80] Protocol ‘rtp’ not on whitelist ‘file,crypto’!  
[INFO:0] global C:\build\master\_winpack-build-win64-vc15\opencv\modules\videoio\src\backend\_plugin.cpp (172) cv::impl::DynamicLib::libraryLoad load opencv\_videoio\_intel\_mfx420\_64.dll =\> FAILED  
OpenCV(4.2.0) Error: Bad argument (CAP\_IMAGES: can’t find starting number (in the name of file): CAM\_configuration.sdp) in cv::icvExtractPattern, file C:\build\master\_winpack-build-win64-vc15\opencv\modules\videoio\src\cap\_images.cpp, line 253  
[ERROR:0] global C:\build\master\_winpack-build-win64-vc15\opencv\modules\videoio\src\cap.cpp (116) cv::VideoCapture::open VIDEOIO(CV\_IMAGES): raised OpenCV exception:

OpenCV(4.2.0) C:\build\master\_winpack-build-win64-vc15\opencv\modules\videoio\src\cap\_images.cpp:253: error: (-5:Bad argument) CAP\_IMAGES: can’t find starting number (in the name of file): CAM\_configuration.sdp in function ‘cv::icvExtractPattern’

failed  
(process 23560) exited with code -1.  
To automatically close the console when debugging stops, enable Tools-\>Options-\>Debugging-\>Automatically close the console when debugging stops.  
Press any key to close this window . . .

this woks well when I try with ffmpeg command,  
ffmpeg -protocol\_whitelist file,rtp,udp -i CAM\_configuration.sdp -c:v copy test.mp4

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 4, 2023, 2:21pm UTC](https://forum.opencv.org/t/read-camera-failed/14746/2 "2023-10-04T14:21:43Z")

</div>

4.2.0 is terribly old, try recent 4.8.0 ffmpeg wrappers, where you can add ffmpeg params via `OPENCV_FFMPEG_CAPTURE_OPTIONS=something` environment vars.  
(but i still think, you need to point the Videoapture at a valid url, not an sdp file)

also, use CAP\_FFMPEG to explicitly specify the backend  
(so it wont try CAP\_IMAGES or such)

---

<div class="post-metadata">

**Author:** ![ocvfasc](https://avatars.discourse-cdn.com/v4/letter/o/eb8c5e/32.png) [@ocvfasc](https://forum.opencv.org/u/ocvfasc)\
**Post date:** [October 5, 2023, 12:26pm UTC](https://forum.opencv.org/t/read-camera-failed/14746/3 "2023-10-05T12:26:34Z")

</div>

I tried with the 4.8.0 openCV version, It dint help to stream the Images (  
I tried with the valid link, before trying the SDP file.)  
Could you share any references to refer to add ffmpeg params via environment varaibles in openCV (visual studio environment).

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [October 5, 2023, 12:32pm UTC](https://forum.opencv.org/t/read-camera-failed/14746/4 "2023-10-05T12:32:54Z")

</div>

sorry, but for now, i can only point you at the [resp. commit here](https://github.com/opencv/opencv/pull/19460/files)

or, well [request to document it](https://github.com/opencv/opencv/issues/21155) 😉
