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

140
Visualizações
Change getusermedia stream resolution after it is already created

I have a React app that records the user's webcam I'm implementing a feature to allow the user to change the video resolution. When I create the Media Stream for the first time passing a default video's width and height it works fine, however when I change the resolution nothing happens I'm still able to record the webcam but the resolution does not change. The following code is used to get the Media Stream, the width and height variables could be 1280x720 or 640x360. The default value mentioned above is 1280x720 and I can't change it to 640x360 after I the stream is created, if I create the stream using the 640x360 it works though.

const stream = await navigator.mediaDevices.getUserMedia({
        video: {
          width: {
            ideal: width
          },
          height: {
            ideal: height
          },
          frameRate: 25,
          deviceId: { exact: videoInputId || cameraDeviceId },
          aspectRatio: {
            exact: width / height,
          },
        },
        audio: audio,
});
cameraVideoRef.current.srcObject = stream;
setCameraStream(stream);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to call getUsermedia() again, with new constraints, to get a new stream object with a new resolution from a browser's camera. For best results close the old stream object first, by stopping all its tracks.

about 4 years ago · Juan Pablo Isaza 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