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

159
Visualizações
How can I get video bitrate with javascript

I want to get the bitrate of video that uploader, because the backend need it.

var video = document.createElement('video');
video.preload = 'metadata';
video.src = URL.createObjectURL(document.getElementById('fileUp').files[0]);
window.URL.revokeObjectURL(video.src);
console.log(video.bitrate);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can get the video duration then simply divide the file size by it to get an approximation (subtitles, audio and metadata would also be included in this value), as far as i know there is no standard api for getting the bitrate directly.

Example (credits https://stackoverflow.com/a/67899188/6072029 ) :

<div>
    <script>
        const getVideoInfos = (file) =>
            new Promise((resolve, reject) => {
                const reader = new FileReader();
                reader.onload = () => {
                    const media = new Audio(reader.result);
                    media.onloadedmetadata = () => resolve({
                        duration: media.duration,
                        file_size: file.size,
                        bitrate: file.size / media.duration,
                    });
                };
                reader.readAsDataURL(file);
                reader.onerror = (error) => reject(error);
            });

        const handleChange = async (e) => {
            const infos = await getVideoInfos(e.target.files[0]);
            document.querySelector("#infos").innerText = `Infos : ${JSON.stringify(infos, null, 4)}`;
        };


    </script>
    <input type="file" onchange="handleChange(event)" />
    <p id="infos">infos: </p>
</div>
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