0

I want to save time length of the video files having several extension(mp4, wav, flv etc) in to database while uploading to server when submitting the page. But I did not find the how to get the length of the uploading video? I tried this code but it only works for audio files.

      File f = new File(fileName);
      Bitstream m_bitstream = new Bitstream(inputStream);
      Header m_header = m_bitstream.readFrame();
      int mediaLength = (int)f.length();
      int nTotalMS = 0;
      if (mediaLength != AudioSystem.NOT_SPECIFIED) {
         nTotalMS = Math.round(m_header.total_ms(mediaLength));
      }

Can you please help me?

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
Rakesh S
  • 1
  • 1
  • 3

1 Answers1

0

Please refere to this post for "wav" files

How to learn .wav duration in Java media frame work?

For mp3 files please refere to:

How do I get a mp3 file's total time in Java?

For mp4 please refer to:

Is there a Java API for mp4 files?

Community
  • 1
  • 1
goroncy
  • 2,053
  • 1
  • 19
  • 16