# OpenCV VideoCapture is not functioning when deployed in Ubuntu server

**URL:** <https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560>\
**Category:** Python\
**Tags:** videoio\
**Created:** [May 27, 2021, 3:17pm UTC](https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560 "2021-05-27T15:17:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bavik](https://avatars.discourse-cdn.com/v4/letter/b/e47c2d/32.png) [@bavik](https://forum.opencv.org/u/bavik)\
**Post date:** [May 27, 2021, 3:17pm UTC](https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560/1 "2021-05-27T15:17:17Z")

</div>

Hi, I’m trying to open webcam using OpenCV after deploying the code in Ubuntu server. But am not able to open it and getting following error.

[WARN:0] global /tmp/pip-req-build-rcdoave0/opencv/modules/videoio/src/cap\_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video1): can’t open camera by index

I tried to change parameters in cv2.VideoCapture(i) where i=[‘cv2.CAP\_V4L2’,0,-1,1] but its not working.

Note: Its working fine with cv2.VideoCapture(0) in local laptop(windows 10) but its not working when deployed in server.

Please help me to resolve the issue.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 27, 2021, 3:58pm UTC](https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560/2 "2021-05-27T15:58:56Z")

</div>

welcome.

`CAP_V4L` (`apiPreference`) wants paths such as `/dev/video0`

CAP\_FFMPEG also wants paths

on Windows, CAP\_DSHOW and CAP\_MSMF (dshow successor/evolution) open video devices by index

---

<div class="post-metadata">

**Author:** ![bavik](https://avatars.discourse-cdn.com/v4/letter/b/e47c2d/32.png) [@bavik](https://forum.opencv.org/u/bavik)\
**Post date:** [May 28, 2021, 2:17pm UTC](https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560/3 "2021-05-28T14:17:21Z")

</div>

Hi, Thanks for the reply.  
Inorder to open webcam in Ubuntu server without any paths, just wants to call by index,  
what is the process that i need to follow?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [May 28, 2021, 3:35pm UTC](https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560/4 "2021-05-28T15:35:28Z")

</div>

try this. what does it say?

```python
import cv2 as cv
camera_backends = cv.videoio_registry.getCameraBackends()
print(camera_backends)
print([
    cv.videoio_registry.getBackendName(apipref)
    for apipref in camera_backends
])

```

[https://docs.opencv.org/master/de/db1/group\_\_videoio\_\_registry.html#gaf6e7163ade0d35b946c3ccccaf504e3e](https://docs.opencv.org/master/de/db1/group __videoio__ registry.html#gaf6e7163ade0d35b946c3ccccaf504e3e)

---

<div class="post-metadata">

**Author:** ![furas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/furas/32/706_2.png) [@furas](https://forum.opencv.org/u/furas)\
**Post date:** [June 4, 2021, 6:10pm UTC](https://forum.opencv.org/t/opencv-videocapture-is-not-functioning-when-deployed-in-ubuntu-server/3560/5 "2021-06-04T18:10:13Z")

</div>

Is this Ubuntu server on your local computer or external server?

Usually external servers don’t have webcams.  
And external server also can’t access your local webcam.
