Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
greenline when rendering video on canvas

I am rendering a video stream on a canvas, sometime a greenline appears on the side of the rendered video, why ? and how to fix this ?

It happens when the canvas size is smaller than the video resolution!!

The Code is very simple

    let videoConstraints: MediaTrackConstraints;
    if (options) {
      if (!CameraResolutions[options.resolution]) options.resolution = CameraQuality.Auto;
      videoConstraints = {
        deviceId: options.deviceId,
        frameRate: { ideal: 30 },
        // facingMode: options.facingMode,
        width: { ideal: CameraResolutions[options.resolution][0] }, // 720
        height: { ideal: CameraResolutions[options.resolution][1] }, // 720
      };
    }
    const constraints: MediaStreamConstraints = {
      video: videoConstraints ?? true,
      audio: false,
    };

navigator.mediaDevices.getUserMedia(options.constraints);
...
this.ctx.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);

this.video is a MediaStream received from a webcam.

I am testing on chrome

UPDATE : Based on coralee's comment updated to this and it worked :) Most of the time :( But I need a better solution

      const w = this.canvas.width - 10;
      const h = this.canvas.height - 10;
      const x = 5; // to center the video on canvas
      const y = 5;
      this.ctx.drawImage(this.video, x, y, w, h);

UPDATE 2 : The real problem : Our WebRTC SDK is enabling simulcast and its using vp8 codec https://en.wikipedia.org/wiki/VP8 and therefore the canvas size should be dividable by 4, 8 or 16 The Solution : Math.round(Math.min(videoWidth, maxSize) / 16) * 16;

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Depends on the file format.

I used to be a video editor and I remember this being a common problem with video exports.

The best way to fix it was to scale the video up a pixel. So if your video was 100%, you make it 101%.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!