Dear all, I have a song say about 5.1 mb ,i want to calculate total duration of song before being played on media player the file format is wave file.
+1
A:
It isn't really possible based on size. For example, an average MP3 is roughly 1 meg per minute, but if it has been encoded at the full 320 bit rate it can be a lot bigger than that. Your best bet would be to tell your script the size AND duration of the music file.
Sohnee
2010-06-01 08:10:02
My problem is that i have only size available of a particular song.i want total duration may be it can be bit roughly .please suggest
angelina
2010-06-01 08:12:57
You could (roughly) divide the duration by 10 for a wav, and use the file size as the duration for mp3. i.e. wavTime = fileSize / 10;
Sohnee
2010-06-02 06:45:52
A:
maybe this will help you http://www.schillmania.com/content/projects/soundmanager2/
vlad
2010-06-01 08:12:37
+1
A:
you can try this page : http://www.sounddevices.com/calculator/
for an uncompressed wav - 16 bit, 44.1kHz, stereo, you're looking at 172.2 KB/second, so around 10.332 MB/second. so your file is approx 0.5 minutes
oedo
2010-06-01 08:13:07
+2
A:
You need to decode the song in order to know the length of it:
URL url = new URL("foo.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
clip.open(ais);
System.out.println(clip.getMicrosecondLength());
Samuel Yung
2010-06-01 08:19:06
Hello Samuel, I used this code and got following exception.javax.sound.sampled.LineUnavailableException: line with format ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, not supported. Please resolve
angelina
2010-06-01 10:05:01