Giter VIP home page Giter VIP logo

Comments (3)

warren32 avatar warren32 commented on June 14, 2024 2

Did you ever figure out a solution to this?

from opentok-web-samples.

frankrod avatar frankrod commented on June 14, 2024

I had the same issue but it has nothing to do with the opentok publisher, the issue is when you do the video.captureStream()
the video by default uses the lowest resolution so when you do captureStream() your max resolution to use in the publisher would be the lowest of the video.
You could check this by logging your stream.videoTracks()[0].getSettings() you'll see the max resolution of the video.
What you can do is set the video player resolution to use the highest available by default so when you do captureStream() your stream.videoTracks()[0] would have the highest resolution and you can use same resolution in your publisher or downscale it.

from opentok-web-samples.

warren32 avatar warren32 commented on June 14, 2024

I managed to get a somewhat workable solution to this. The following solution will also work on ios. It needs more testing but the workflow is as follows:

  1. Draw the video to a canvas using requestAnimationFrame and context.drawImage() as outlined here https://mux.com/blog/canvas-adding-filters-and-more-to-video-using-just-a-browser/. Note that you can draw a canvas from a video element easily and adjust width, height and framerate using this technique.

  2. Publish the canvas video stream using canvas.captureStream(fps).getVideoTracks()[0] like this:

OT.initPublisher(null, {
    videoSource: this.canvasEl
        .captureStream(30)
        .getVideoTracks()[0],
    insertDefaultUI: false,
    audioSource: false,
})

This is also shown here: https://github.com/opentok/opentok-web-samples/blob/master/Publish-Canvas/js/app.js. Note that canvas.captureStream is supported by all recent browsers (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream)

from opentok-web-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.