Solved

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

Posted on 2007-11-20
9
1,250 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
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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now