0

I want to support up to full HD. Is this possible with tokbox? If not tokbox can I do it with say jitsi? Tokbox is just super easy to get started with.

Pineapple Joe
  • 199
  • 10

2 Answers2

2

That's not officially supported with TokBox. It's hard to find webcams that actually support full HD. You should be able to call getUserMedia yourself though and pass your own MediaStream to an OpenTok Publisher.

navigator.mediaDevices.getUserMedia({
  video: {
    width: {ideal: 1920}, 
    height: {ideal: 1080}
  },
  audio: true
}).then(stream => {
  let publisher = OT.initPublisher(null, {
    audioSource: stream.getAudioTracks()[0],
    videoSource: stream.getVideoTracks()[0],
    fitMode: 'contain'
  }, function(err) {
    if (err) {
      alert(err.message);
    } else {
      videoWidth.innerHTML = publisher.videoWidth();
      videoHeight.innerHTML = publisher.videoHeight();
    }
  });
});

Here is a demo of it working https://output.jsbin.com/yiwupoc

Note this code will try to get 1080p but if your camera does not support it then it will just try to get the closest resolution. Also it won't work with Internet Explorer.

Adam Ullman
  • 1,517
  • 7
  • 12
  • Thanks Adam. It didn't seem to work for me. The source is still being clipped where I dont see all of it. I used Chrome for the test. I can understand the lack of availability of cameras but why would tokbox limit it? I would use their service if they had this but I have had to move on because they dont. really liked the simplicity of the apis and the documentation is beyond superb but I need configurable resolution (both h and v to get what I need). Do you know of any other service that offers what I am looking for? – Pineapple Joe Nov 09 '17 at 21:48
  • If you can't get the vanilla WebRTC code above to work then no WebRTC service will work for you. Does https://webrtc.github.io/samples/src/content/getusermedia/resolution/ work for you? – Adam Ullman Nov 13 '17 at 03:57
  • Its weird. The link you provided does not capture the full image but the basic getusermedia test (https://webrtc.github.io/samples/src/content/getusermedia/gum/) is capturing the correct dimensions. I'll try and play around with this a bit more. Unless you know why this would be the case. – Pineapple Joe Nov 13 '17 at 19:21
  • Oh yeah, sorry, it was cropping the sides off because the dimensions of the widget are 4x3. I updated it to use fitMode: 'contain' so that it letterboxes the video. Give it another try https://output.jsbin.com/fumezeg – Adam Ullman Nov 14 '17 at 02:41
  • That was it! It works now! BTW - I looked you up. I was going to ask how you knew so much. You are the source! Thanks for all the help. – Pineapple Joe Nov 14 '17 at 21:51
  • Glad to hear I could help! :) I updated my answer to include the fitMode. – Adam Ullman Nov 16 '17 at 04:17
  • Hey Adam. I am seeing that the incoming video stream is actually 1440x720. While the ration is correct I need the higher res. Any ideas? – Pineapple Joe Nov 30 '17 at 05:35
  • Hey again. I am asking for this as I am in incubation phase in a startup. Would love to fully build on your platform - love how you have put it together - but when I go to production I will need higher res or I will simply be forced to choose another provider. Happy to have a direct conversation if that would be preferable. – Pineapple Joe Dec 01 '17 at 19:09
  • Do you get the correct resolution in the stream locally? ie. when you go here do you get the right resolution? https://jsbin.com/wuhumoj – Adam Ullman Dec 04 '17 at 00:53
  • If not then it's just the browser that is unable to get that resolution, or perhaps the camera you are using. – Adam Ullman Dec 04 '17 at 00:57
  • Thanks! Good question! Your script shows 1920x1080. I had previously used this (https://webrtc.github.io/samples/src/content/getusermedia/resolution/) and it worked as I expected. The camera can handle 4K (which is where i'd love to be eventually but one step at a time :) ). – Pineapple Joe Dec 04 '17 at 20:15
  • Interesting so you're saying that when you publish into an OpenTok Session and subscribe at the other end you end up getting a lower resolution? – Adam Ullman Dec 05 '17 at 00:10
  • Yep. Unless I am missing something which is completely possible. fwiw the other end here is an iOS app with your SDK. Do you scale down for mobile by chance? And just to be clear this is with a custom video renderer (as taken from one of your samples). – Pineapple Joe Dec 05 '17 at 02:58
  • Have you tried using a relayed session instead of a routed one? Trying to determine whether our media server could be doing something. – Adam Ullman Dec 05 '17 at 04:26
  • I just tried. Relayed session is delivering the correct resolution. Interesting. I guess its not just a forward unit? – Pineapple Joe Dec 05 '17 at 05:48
  • There is now an official way to pass your own MediaStream to an OpenTok publisher. I'm going to edit my original answer. – Adam Ullman Feb 21 '18 at 00:18
  • Your resolution scales down automatically to fit with your bandwidth. You do still get 1920x1080 still though with a routed session if your connection is really good. – Adam Ullman Feb 21 '18 at 01:00
  • Thanks. Just seeing this now. Will check it out. – Pineapple Joe Mar 16 '18 at 20:48
  • Hi Adam. Is there a way for me to force the use of the VP9 encoder. I get that it will only work in Chrome (and im ok with this) but I need a crisper image. – Pineapple Joe Apr 06 '18 at 18:08
  • No, there is no way to officially do that with OpenTok at the moment. Right now we are focused on VP8 and H.264 support. I can add it as a feature request though. – Adam Ullman Apr 23 '18 at 21:47
  • Thanks. I'd like to show you a demo of what we are doing. I'll reach out on linkedin. – Pineapple Joe May 02 '18 at 15:51
  • What would the unofficial way be? – Pineapple Joe May 11 '18 at 02:59
  • The unofficial way would be to modify the PeerConnection SDP to put VP9 before VP8. You could "Hack" the JS to do this in theory. I think there is also a flag you can pass when you launch Chrome to tell it to prioritize VP9. All of this will only work with relayed sessions, because our media server will not do VP9 right now. – Adam Ullman May 14 '18 at 06:43
  • @AdamUllman sorry to hijack this thread, but is it possible to prevent downscaling based on bandwidth? I want to record session in a good quality, and that downscaling prevents me from doing that. Or in return I'll get a lot of frame drops instead? Also, is this documented anywhere? – Evk Jul 30 '19 at 13:22
  • The only thing that jumps to mind is you could try using the browser's MediaRecorder API to record locally. Not sure how well this will work for your use-case but you could even record the local video for each participant on their machine and then upload them somewhere afterwards. https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder – Adam Ullman Aug 01 '19 at 01:38
0

This is now supported. Please see https://tokbox.com/developer/guides/1080p/ for more!