1

I want to extract the size of the video file in megabytes, If there is a way, just inspiration is enough

<video id="myVideo" width="200"  controls>
  <source src="https://www.w3schools.com/JSREF/movie.mp4" type="video/mp4">

</video>



<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myVideo").filesSize;
  document.getElementById("demo").innerHTML = x + "MB";
}
</script>
SHVFG
  • 11
  • 3

1 Answers1

0

May be the MediaStream Recording API could do the job (https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Recording_API):

The MediaStream Recording API, sometimes simply referred to as the Media Recording API or the MediaRecorder API, is closely affiliated with the Media Capture and Streams API and the WebRTC API. The MediaStream Recording API makes it possible to capture the data generated by a MediaStream or HTMLMediaElement object for analysis, processing, or saving to disk. It's also surprisingly easy to work with.

For a working example with audio media (the example demonstrates exporting an audio stream as a BLOB), see https://stackoverflow.com/a/63763971/4151043.

Danny Apostolov
  • 479
  • 3
  • 8