|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Get length of WAV file
Author: Charlie Griefer
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306682
ok that right there is kinda slick :)
----- Excess quoted text cut - see Original Post for more -----
Author: Gert Franz
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306677
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 -----
Author: Dave Phillips
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306669
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>
Author: Dave Phillips
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306651
----- 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.
Author: Burns, John D
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306556
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
Author: Dave Phillips
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306549
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
Author: Dave Phillips
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56581#306548
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
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||