pion / mediadevices

Go implementation of the MediaDevices API.
https://pion.ly/
MIT License
521 stars 120 forks source link

failed to find the best driver that fits the constraints to open usb camera #503

Closed learncodingforweb closed 1 year ago

learncodingforweb commented 1 year ago

Tried example https://github.com/pion/mediadevices/blob/master/examples/webrtc/main.go

s, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{
    Video: func(c *mediadevices.MediaTrackConstraints) {
        c.FrameFormat = prop.FrameFormat(frame.FormatI420)
        c.Width = prop.Int(640)
        c.Height = prop.Int(480)
    },
    Audio: func(c *mediadevices.MediaTrackConstraints) {
    },
    Codec: codecSelector,
})
if err != nil {
    fmt.Println("phase 3")
    panic(err)
}

Getting panic error phase 3 panic: failed to find the best driver that fits the constraints

Your environment.

What did you do?

I tried example https://github.com/pion/mediadevices/blob/master/examples/webrtc/ -->

What did you expect?

Should open usb camera and send stream of data on webrtc communication.

What happened?

It failed to open usb camera.

learncodingforweb commented 1 year ago

Fixed importing

    _ "github.com/pion/mediadevices/pkg/driver/camera"
    _ "github.com/pion/mediadevices/pkg/driver/microphone"