Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
¿Cómo puedo obtener la tasa de bits de video con javascript?

Quiero obtener la tasa de bits del video que subió, porque el backend lo necesita.

 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 answers
Answer question

0

Puede obtener la duración del video y luego simplemente dividir el tamaño del archivo para obtener una aproximación (los subtítulos, el audio y los metadatos también se incluirían en este valor), que yo sepa, no existe una API estándar para obtener la tasa de bits directamente.

Ejemplo (créditos 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!