# VIDEOIO(V4L2:/dev/video0): select() timeout

**URL:** <https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822>\
**Category:** Python\
**Tags:** wsl, videoio\
**Created:** [May 18, 2022, 2:17am UTC](https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822 "2022-05-18T02:17:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xskaisx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/xskaisx/32/4574_2.png) [@xskaisx](https://forum.opencv.org/u/xskaisx)\
**Post date:** [May 18, 2022, 2:17am UTC](https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822/1 "2022-05-18T02:17:36Z")

</div>

I 'm trying to connect my webcam USB with WSL2. I can get it showed up on WSL2 with command

```auto
$lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 046d:08cb Logitech, Inc. Mic (Notebooks Pro)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

```

or

```auto
$ v4l2-ctl --list-devices
UVC Camera (046d:08c9) (usb-vhci_hcd.0-1):
        /dev/video0
        /dev/video1

```

When I tried to run my program

```auto
import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):

    ret, frame = cap.read()
    if ret:

        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        cv2.imshow('frame',gray)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break
cap.release()
cv2.destroyAllWindows()

```

The webcam light is on, its mean activating but can not capture any frame.

```auto
[WARN:0@10.310] global /io/opencv/modules/videoio/src/cap_v4l.cpp (1000) tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.

```

I tried these command below but seems doesn’t help

```auto
lsmod
rmmod uvcvideo
modprobe uvcvideo nodrop=1 timeout=5000

```

its showed error

```auto
rmmod uvcvideo
rmmod: ERROR: Module uvcvideo is builtin.

```

Any solutions?

---

<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 18, 2022, 7:15am UTC](https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822/2 "2022-05-18T07:15:39Z")

</div>

`assert cap.isOpened()`

always do that after creating the object

can you receive frames using ffmpeg or vlc (inside the container)?

---

<div class="post-metadata">

**Author:** ![hezhexi2002](https://avatars.discourse-cdn.com/v4/letter/h/22d042/32.png) [@hezhexi2002](https://forum.opencv.org/u/hezhexi2002)\
**Post date:** [October 4, 2022, 3:15pm UTC](https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822/3 "2022-10-04T15:15:20Z")

</div>

Hi,I meet the same problem with you and I haven’t solved that yet,so is there any progress you have made to solve the error?I would appreciate it if you can give me some advice!🙂

---

<div class="post-metadata">

**Author:** ![hezhexi2002](https://avatars.discourse-cdn.com/v4/letter/h/22d042/32.png) [@hezhexi2002](https://forum.opencv.org/u/hezhexi2002)\
**Post date:** [October 4, 2022, 3:20pm UTC](https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822/4 "2022-10-04T15:20:36Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/6/6b6e347a365326014c28bc7289c115700d8cb557.jpeg)  
I use ffplay -f video4linux2 -input\_format mjpeg -framerate 30 -video\_size 640\*480 /dev/video0 to test if ffmpeg can show frames correctly and the result the picture above,it seems that ffmpeg can’t open the camera too,so what’s the problem with this,do you have any idea?

---

<div class="post-metadata">

**Author:** ![flyingtiger](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@flyingtiger](https://forum.opencv.org/u/flyingtiger)\
**Post date:** [November 8, 2022, 7:37am UTC](https://forum.opencv.org/t/videoio-v4l2-dev-video0-select-timeout/8822/5 "2022-11-08T07:37:26Z")

</div>

Hey, I got simmilar issue and solve it with setting format as MJPG int the 4-character code of codec.

```auto
from cv2 import cv2

camera = cv2.VideoCapture(0)
camera.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
status, image = camera.read()
camera.release()

```
