1.11M Members

Getting Audio File Length in C#

 
0
 

Hi All

I am looking to be able to get the length of any audio file in seconds. Formats are WAV, MP3 and DSS. Is there anything like this...

int seconds = myFile.AudioLength();

Any help would be appreciated

Mike

 
0
 

Hey hi !

I'm trying to do the same thing to try to see the lenght of an audio file. Did you ever knew how to do it. All I know is how to get the bytes size of the file but don't know how to get the time thanks.

Jose


Hi All

I am looking to be able to get the length of any audio file in seconds. Formats are WAV, MP3 and DSS. Is there anything like this...

int seconds = myFile.AudioLength();

Any help would be appreciated

Mike

 
-1
 

please help to find duration of audio file which is in .dss format. I am able to find duration of .mp3 format file but not able to find .dss file's duration. For Mp3 format m using wmp.dll, but this is not able to find .dss file duration.

pls help me ..... its urgent

 
0
 

well, I don't remember the exact details, but maybe you can use windows properties for this?
I know there is a way to access the properties of a file under windows. If you were to access the time detail form the soundfile... that might work. Not sure if it would help for .dss files since I'm not sure windows will know what to do with those.

Hope this helps at least a little.

 
0
 

thanks ctrl+alt+del for help,
please help me to explore your idea(if possible pls provide an example).

i am using wmp.dll for duration of voice file. this dll has property(durationstring). but it is useful for only .mp3 file. i need .dss file duration. if posibble pls help me.

 
0
 

I saw on this calculation on the web, but I don't have a .dss file to test it with...

public static long GetDSSDuration(string fileName)
        {
            FileInfo fi = new FileInfo(fileName);
            long size = fi.Length;

            long length = (long)(((size * 1.1869) - ((size / 1054) * 210)) / 1054);

            if (length > 1000)
            {
                length = (long)(length * (0.61 + ((length / 100) * 0.0005)));
            }
            else
            {
                length = (long)(length * (0.61 + ((length / 100) * 0.0015)));
            }

            return length;
        }
 
0
 

hello doubleD, really thanks for ur code, i all most reached to result but not accurate. its showing length in second, when m converting into minutes (divide by 60) its not showing accurate time. me trying to understand these formula. if there is any others solution pls help me.

thanks again

 
0
 

Assuming that the formula outputs time in seconds, all you would have to do is put "length = length / 60;" just before "return length" and that should work fine. (his/her solution is far better then mine since it actually calculates the value for the audiofile, I don't think windows recognizes .dss files, so it won't have any detailed info on it either)

 
0
 

thanks ctrl_alt+del, i did same as u telling. its all most correct, but it not showing accurate duration of .dss file. difference is in 10 to 30 second.

 
0
 

How many seconds duration is the dss file(s) that is off by 10 - 30 seconds? Also, do you have many dss files of varying durations? If you do, and the calculation varies proportionately to an increase in duration, you could adjust the calculation to accommodate a better approximation.

EDIT: Also, be sure you are not truncating/rounding the time when calculating minutes in the divide by 60 division...

 
0
 

Hello Every Body
I am back, this time I am facing same problem. according to the formula given by DdoubleD i resolve DSS audio file duration problem, but this time some dss file is more compressed and duration of these file different according to size of file.
IS there is any technique in .net 2005 so that i can include any third party's player and find duration and other thing

I tried to include DLL of these player but not compatible with .net.
.DSS file is basically dictation by doctor(olympus recorder is use to record dictation and it save these file in .dss format)

I allready included WMP.dll for MP3. But .dss is creating problem.

Any idea or technique will be appreciable.

thanks

 
0
 

sayjay092, I don't know if you noticed, but you have been asking questions to a thread going back to 2006? I didn't realize this when I first responded to a more recent question, or I would have said then what I say here...

Please create your own thread (new post/thread) with your question as this is the appropriate use of the forum and it is not appropriate to ask/piggyback questions in someone else's thread.

Cheers!

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article