OvenLiveKit-Web icon indicating copy to clipboard operation
OvenLiveKit-Web copied to clipboard

Can't get 720x1280 stream from webcam

Open brootle opened this issue 3 years ago • 10 comments

Hi! I am trying to get 720x1280 stream, but it doesn't seem to work regardless of what settings I am passing as constraints on a client side. Inside OvenLiveKit-Web it's obvious that you set params in a way to get max possible resolution, but even when I set video: true to let the Kit take the resolution, oven media engine outputs 480x640 max. Maybe I am missing something obvious? I did try passing video: { deviceId: undefined, width: 1280, height: 720 } in constraints and a bunch of other settings without any luck. At some point I got 720 as oven media engine output while testing, but couldn't reproduce it.

https://github.com/AirenSoft/OvenLiveKit-Web/blob/17e7387782bc63485ea6694cda18a2b2d7161ab9/src/OvenLiveKit.js#L84

  const constraints = {
      audio: { deviceId: undefined },
      video: { deviceId: undefined, width: 1920, height: 1080 }
  };

brootle avatar Feb 21 '22 18:02 brootle

@brootle Hi. First, make sure your input device supports that resolution. You can test different values here.

  • https://webrtc.github.io/samples/src/content/peerconnection/constraints/

And please note that the browser will get the ideal resolution from the input device if there is no matching constraint. Please refer here.

  • https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters

In addition, please let us know which browser and OS you are testing.

Thanks.

SangwonOh avatar Feb 22 '22 08:02 SangwonOh

@SangwonOh well, yes, I tested at https://ovenplayer.com/demo_input.html and on client side it takes 1280x720 no problem. I am on Google Chrome Version 98.0.4758.102 (Official Build) (64-bit) and Win10.

image

I tested at https://webrtc.github.io/samples/src/content/peerconnection/constraints/

{
    "audio": true,
    "video": {
        "width": {
            "min": "300",
            "max": "4096"
        },
        "height": {
            "min": "200",
            "max": "2160"
        }
    }
}

And got this result Video dimensions: 1280x720px So I am thinking maybe there could be something wrong on oven media engine side. I will doublecheck everything again and post if I find a solution

brootle avatar Feb 22 '22 09:02 brootle

@brootle It's very difficult to select a value, but how is the Video dimensions with below settings at https://webrtc.github.io/samples/src/content/peerconnection/constraints/?

This is to determine if this is an OvenMediaEngine-side issue or something else..

{
    "audio": true,
    "video": {
        "width": {
            "min": "720",
            "max": "720"
        },
        "height": {
            "min": "1280",
            "max": "1280"
        }
    }
}

SangwonOh avatar Feb 22 '22 09:02 SangwonOh

@SangwonOh

Yes, it gave me getUserMedia error: OverconstrainedError This may mean invalid constraints. error

image

and OvenLiveKit-Web also gave me same error when I tried to get media using minimal example needed to get client media, so what does it mean?

constraint: "height"
message: ""
name: "OverconstrainedError"

PS these settings below work fine to get 720x1280, I am logging getVideoTracks settings from stream on client side image

brootle avatar Feb 22 '22 10:02 brootle

@brootle Experientially, OverconstrainedError occurred when the webcam did not support the resolution.

Because the minimum and maximum values of the width and height were set to the same value, the browser requested media to the webcam with the exact values set, and it failed because the webcam did not support the resolution.

Looking at the HD attached to the webcam name, it looks like the webcam can go up to 1080.

And the last log screenshot you posted seems to have a height of 1080 :).

SangwonOh avatar Feb 22 '22 11:02 SangwonOh

@SangwonOh yes, these settings worked on client side

{
    "audio": true,
    "video": {
        "width": {
            "min": "1280",
            "max": "1280"
        },
        "height": {
            "min": "720",
            "max": "720"
        }
    }
}

and it also works if I put exact parameters video: { width: 1280, height: 720 } so not sure what might go wrong when it hits media engine, all looks green in client logs for peer and socket connection

When I am testing at https://webrtc.github.io/samples/src/content/peerconnection/constraints/ The connected on the right starts with min resolution and eventually goes up. image

brootle avatar Feb 22 '22 12:02 brootle

@brootle

so not sure what might go wrong when it hits media engine, all looks green in client logs for peer and socket connection

What specifically is the problem? WebRTC input succeeded, but having problems playing through OvenMediaEngine?

Did you set up the WebRTC input properly?

  • https://airensoft.gitbook.io/ovenmediaengine/live-source/webrtc-beta#configuration

SangwonOh avatar Feb 23 '22 00:02 SangwonOh

@SangwonOh thanks! yeah, this was a problem with settings on engine side, something related to "prevent upscaling", I wasn't the guy setting up the engine, so had no idea about it 😀

brootle avatar Feb 23 '22 06:02 brootle

@SangwonOh I have one more question, when peer connections is established and I am streaming, basically when ICE State [connected] event happened, how using client side ovenLivekit instance to view peer connection details, specifically the actual resolution of the stream that server is getting from my side?

brootle avatar Feb 23 '22 18:02 brootle

@brootle Hi. The ovenLivekit instance has a peerConnection property. Thanks!

SangwonOh avatar Feb 25 '22 07:02 SangwonOh