?
Solved

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

Posted on 2007-11-20
9
Medium Priority
?
1,257 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
8 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 1000 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 1000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

839 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