Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda