Solved

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

Posted on 2007-11-20
9
1,252 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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 would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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