|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Get length of WAV file
Hi all,Dave Phillips 06/01/08 09:17 P As a follow up, I installed the CFX tag and it is returning 0 seconds on my .WAV files, so it doesn't seem to work anyway. I really need to find a way to identify the length in time of a .WAV file. Please let me know if you know how.Dave Phillips 06/01/08 09:26 P You may look out there at some java classes and see if you can findBurns, John D 06/02/08 09:20 A >You may look out there at some java classes and see if you can findDave Phillips 06/02/08 06:13 P John,Gert Franz 06/02/08 09:54 P ok that right there is kinda slick :)Charlie Griefer 06/02/08 10:36 P Hi all, What is the best (easiest) way to get the length of a wav file. I don't want the file size, I can get that with CFDIRECTORY. I want the length of the audio in time. I found a tax called cfx_audioinf here on the HOF, but it became obsolete in 2003. I don't know why it's obsolete, but I'm wondering if it's because there is a better way to retrieve that info now. I'd like to avoid having to install a CFX if at all possible. Please let me know. And yes, the file is located on the server. Thanks! Dave As a follow up, I installed the CFX tag and it is returning 0 seconds on my .WAV files, so it doesn't seem to work anyway. I really need to find a way to identify the length in time of a .WAV file. Please let me know if you know how. Thanks! Dave You may look out there at some java classes and see if you can find something that can read the attributes of the wav file or even load the whole wav into memory and then pull the length or something. I don't know of any specific classes that do it for wav but I know I've used some for mp3s and ID3 tagging and such. If you can find one, anything you can do in java you can do in CF. Hope that gets you going in the right direction. John Burns As a follow up, I installed the CFX tag and it is returning 0 seconds on my .WAV files, so it doesn't seem to work anyway. I really need to find a way to identify the length in time of a .WAV file. Please let me know if you know how. Thanks! Dave ----- Excess quoted text cut - see Original Post for more ----- John, I've been looking and although I found something called javax.sound.sampled.AudioSystem class (and other classes from Java Sound API) but so far I have not been able to implement them in ColdFusion as indicated in Java. Some of the methods are 'not found'. I'm at a loss here and really need some help. I wanted to share with you all the solution I found. After some more digging for java solutions, I found an example that was 'playing' a wave file, and that had enough information in it for me to formulate a 'getWaveLength()' function that will return to me the number of seconds that a wave file is in length. Basically, it turns out it is the Frame Length divided by the Frame Rate (makes sense actually). It just takes a bit of 'finagling' (sp?) to get it. Here is the function I ended up using. Seems to work great for both small and large WAV files, and I would think would work fine for other file types such as MP3, AU and others, although I have not tried those. <cfscript> function getWaveLength(sFileName) { var oAudioFile = createObject("java","java.io.File").init(arguments.sFileName); var oAudioSystem = createObject("java","javax.sound.sampled.AudioSystem"); var oAudioFileFormat = oAudioSystem.getAudioFileFormat(oAudioFile); var oAudioInputStream = oAudioSystem.getAudioInputStream(oAudioFile); var oAudioFormat = oAudioInputStream.getFormat(); var nFrameLength = oAudioFileFormat.getFrameLength(); var nFrameRate = oAudioFormat.getFrameRate(); return round(nFrameLength / nFrameRate); } </cfscript> John, Railo is capable of reading information from a multimedia file. This can be done with the new CFVIDEO tag: <cfvideo action="info" result="info" source="myFile.wav"> the resulting struct contains several different information strings, including a key called "duration". -- Greetings from Switzerland Gert Franz Railo Technologies GmbH gert.franz@railo.ch www.railo.ch Join our Mailing List german: http://de.groups.yahoo.com/group/railo/ english: http://groups.yahoo.com/group/railo_talk/ linked in: http://www.linkedin.com/e/gis/71368/0CF7D323BBC1 Burns, John D schrieb: ----- Excess quoted text cut - see Original Post for more ----- ok that right there is kinda slick :) On Mon, Jun 2, 2008 at 6:52 PM, Gert Franz <gert.franz@railo.ch> wrote: ----- Excess quoted text cut - see Original Post for more -----
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||