Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda