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

284
Views
How can i get the Video duration of a selected video from input in ReactJs?

//selectedFileData is array of selected video file from input

const data = new FormData();
for (let i = 0; i < selectedFileData.length; i++) {
  data.append("file", selectedFileData[i]);
  data.append("fileSize", convertSize(selectedFileData[i].size, "MB"))
  data.append("videoDuration",(i want to append video duration of video from here));
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use the modern browser's URL API's URL.createObjectURL() with an non appended video element to load the content of your file.

const data = new FormData();
for (let i = 0; i < selectedFileData.length; i++) {
  let videoElem = document.createElement('video');
  videoElm.preload = `metadata`;
  
   video.onloadedmetadata = function() {
    window.URL.revokeObjectURL(video.src);
    let duration = video.duration;

    data.append("videoDuration", duration);
  }

  video.src = URL.createObjectURL(files[0]);;
  
}
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!