Solved

Determining the length of an Audio File (mp3, wav, etc) via ASP

Posted on 2007-11-20
9
1,253 Views
Last Modified: 2012-05-05
Don't know if this is possible or not, but I need to find out the length of an audio file on the server.  I can get size and dimension of a JPEG, so maybe there is something out there that will do the same for an audio file.  Any thoughts?
0
Comment
Question by:mopar003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 9

Expert Comment

by:CCongdon
ID: 20322169
<%
dim filesys, filename, f
Set filesys = CreateObject("Scripting.FileSystemObject")
filename = Server.MapPath("filename.mp3")
Set f = filesys.GetFile(filename)
Response.Write(f.size & " bytes")
%>
0
 
LVL 9

Expert Comment

by:CCongdon
ID: 20322177
Woops, that's won't work in ASP.  Try this instead:

<%
dim filesys, filename, f
Set filesys = Server.CreateObject("Scripting.FileSystemObject")
filename = Server.MapPath("filename.mp3")
Set f = filesys.GetFile(filename)
Response.Write(f.size & " bytes")
%>

0
 
LVL 1

Author Comment

by:mopar003
ID: 20322194
I need to find the actual audio length in Minutes, seconds.  Not the file size itself.

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 18

Expert Comment

by:Morcalavin
ID: 20322198
@CCongdon

That will get the size of the file, but not the length(ie 2:27 seconds of audio).
0
 
LVL 9

Accepted Solution

by:
CCongdon earned 250 total points
ID: 20322283
Woops, sorry. My brain started thinking size. I re-read the question and I see it clearly says length.

Are you adverse to installing a DLL or application on your system?

I came across these two articles on the 'net.

http://www.g6ftpserver.com/forum/index.php?showtopic=1161&pid=7076&mode=threaded&start=

This one on microsoft's page is a little more extensive (and requires iTunes!)

http://www.microsoft.com/technet/scriptcenter/funzone/tunes.mspx
0
 
LVL 9

Expert Comment

by:CCongdon
ID: 20322297
It's possible to not add the actual iTunes application, but merely an SDK to your system.

http://developer.apple.com/sdk/itunescomsdk.html
0
 
LVL 18

Assisted Solution

by:Morcalavin
Morcalavin earned 250 total points
ID: 20411569
You can use SoX windows binary to do the wavs.  You would have to run a  wshell in asp to run the .exe.



Unfortunately, you the windows version doesn't support mp3 in the binary(you'd have to compile it yourself to enable mp3 support).  However, http://www.nabble.com/Getting-SoX-to-See-Lame-in-Windows-t4305851.html details converting mp3 -> wav in order to get the length.
C:\Documents and Settings\My Documents>sox file.wav -e stat
Samples read:             50400
Length (seconds):      2.285714
Scaled by:         2147483647.0
Maximum amplitude:     0.847046
Minimum amplitude:    -0.889740
Midline amplitude:    -0.021347
Mean    norm:          0.096549
Mean    amplitude:    -0.000049
RMS     amplitude:     0.182658
Maximum delta:         1.250366
Minimum delta:         0.000000
Mean    delta:         0.107366
RMS     delta:         0.199797
Rough   frequency:         1919
Volume adjustment:        1.124

Open in new window

0
 
LVL 1

Expert Comment

by:Computer101
ID: 21135895
Forced accept.

Computer101
EE Admin
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question