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

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

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 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