# Error when opening two cameras in FullHD using MSMF backend

**URL:** <https://forum.opencv.org/t/error-when-opening-two-cameras-in-fullhd-using-msmf-backend/11098>\
**Category:** Python\
**Tags:** windows, camera, videoio\
**Created:** [November 25, 2022, 5:02am UTC](https://forum.opencv.org/t/error-when-opening-two-cameras-in-fullhd-using-msmf-backend/11098 "2022-11-25T05:02:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vnd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vnd/32/6600_2.png) [@vnd](https://forum.opencv.org/u/vnd)\
**Post date:** [November 25, 2022, 5:02am UTC](https://forum.opencv.org/t/error-when-opening-two-cameras-in-fullhd-using-msmf-backend/11098/1 "2022-11-25T05:02:03Z")

</div>

I’m trying to get FullHD picture from two UC70 web cameras connected to a PC, however reading frame from the second camera fails with `videoio(MSMF): can't grab frame. Error: -2147483638`. Checked with OpenCV 4.5.1 and 4.6.

If CAP\_DSHOW is used, then the error is gone, however with DirectShow there’s just 1 FPS so it’s unusable.

If after the error I re-create the capture and set 640x480 resolution, then it works (but we need both in FullHD).

If the first capture is released before creating the second one, then it works (but we need both simultaneously).

Error still happens if second camera is opened from another process.

```auto

import cv2
 
def copen(index, fullhd):    
    cap = cv2.VideoCapture(index)
    if fullhd:
        cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
        cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
    if not cap.isOpened():
        print(f"Cannot open webcam {index}")
    if not cap.read()[0]:
        print(f"Cannot read webcam {index}")
 
    return cap
 
cap1 = copen(0, True)
cap2 = copen(1, True)
 
cap1.release()
cap2.release()

```

Any ideas? Thanks!

---

<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:** [November 25, 2022, 8:59am UTC](https://forum.opencv.org/t/error-when-opening-two-cameras-in-fullhd-using-msmf-backend/11098/2 "2022-11-25T08:59:27Z")

</div>

> [@vnd](#):
>
> just 1 FPS

set CAP\_PROP\_FOURCC to MJPG. order of set() calls matters. try this call last. works for most people.

the MSMF backend is fairly immature. when in doubt go with dshow.

USB has limited bandwidth, per controller (chip in your computer). cameras are designed to use up almost all of that. expect to be running one camera per controller. you’ll have to identify which ports belong to the same controller, and use just one of each group.

---

<div class="post-metadata">

**Author:** ![vnd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vnd/32/6600_2.png) [@vnd](https://forum.opencv.org/u/vnd)\
**Post date:** [November 25, 2022, 2:40pm UTC](https://forum.opencv.org/t/error-when-opening-two-cameras-in-fullhd-using-msmf-backend/11098/3 "2022-11-25T14:40:07Z")

</div>

Setting FOURCC and using DirectShow worked, thank you!

Also initial test was done in a VM, double FullHD actually worked on a real PC (but there’s a similar problem with double 4K).
