Tuesday, June 12, 2007

flash.media.Microphone.rate What are the acceptable bit rates (bitrates)?


Adobe appears to have forgotten to publish the acceptable values for the flash.media.Microphone.rate property in the ActionScript 3.0 edition of their documentation.

The Adobe documentation on the rate (bitrate) property is limited to the following,
“The rate at which the microphone is capturing sound, in kHz. The default value is 8 kHz if your sound capture device supports this value. Otherwise, the default value is the next available capture level above 8 kHz that your sound capture device supports, usually 11 kHz. “

But, what If you want a rate (bitrate) other than 8 or 11 kHz ? If you are looking for the acceptable bit rates look no further. I dug this out of a tech note.

Sampling rate

Approximate data rate

5

5.512 kHz

1378 bytes/sec, or 11.025 K bits/sec

8

8.000 kHz

2,000 bytes/sec, or 16 K bits/sec

11

11.025 kHz

2756 bytes/sec, or 22.05 K bits/sec

22

22.050 kHz

5,513 bytes/sec, or 44.1 K bits/sec

44

44.100 kHz

11,025 bytes/sec, or 88.2 K bits/sec

Labels: ,

Monday, June 11, 2007

Adobe Flash Player Settings Dialog Box Does Not Appear

I was creating a flash mp3 recorder application today and the Adobe Flash Player Settings dialog box, which gives the user the option to allow his microphone to be streamed back to the server, would not appear. It turns out that my SWF was too small for the settings box to show up. A SWF size of no less than 214 x 137 pixels is required for the settings dialog box to appear.

I got no warning and no error. It would be nice if the window would show up at any size. A warning would also have been fine. Even just shading the window as normal would have indicated that the setting dialog box was just off screen. Instead I got nothing.


Labels:

Tuesday, May 22, 2007

Recording Audio with Flash Player to MP3, WAV, AVI, etc.

My team is currently developing a series of interactive speech recognition application. One of the applications requires us to create a web front end that allows us to record audio from a user microphone and return it to the server. To be able to process the file it must be in WAV format. (Microsoft provides a plug-in that can transfer the audio from a web browser to our server, but it is 60MB and thus would render our application useless.)

We decided to use Flash and quickly found that we could not extract the audio from our recorded FLV files. We had no trouble extracting audio from FLV files that we had generated through our own conversion but we simply could not get the audio out of the files that were being streamed to our Flash Media Server. We discovered that all files converted from another format to FLV store audio in an embedded MP3. Unfortunately, all FLV files recorded from the user’s microphone in by the Flash Player use the Nellymoser audio format. Nellymoser is a highly proprietary mono audio format designed solely for streaming speech. When we looked for a program to decompress this converter we found that Nellymoser offered a converter for $7,500.

We did some more digging and found people claiming that that there was one other converter that would do our decoding, the Total Video Converter. We also found that for only $50.00 we could get our hands on the registered version which includes a command line interface that we could use on our web server. As there was no documentation on how to use the command line features of Total Video Converter I created to following tutorial.

How to Extract Audio from FLV Files Recorded by the Flash Player

Download and install Total Video Converter http://www.effectmatrix.com/total-video-converter/

Use GUI to convert an FLV file.
To convert an FLV that contains video or video and audio, but not audio only, you may use the GUI which is self explanatory. Audio only clips can not be converted with the GUI at this time. (The application simply locks up when we try to convert Nellymoser audio only FLV files).

How to Use the Command Line to Convert a Video (or Audio only FLV) File to another Format
First, obtain the pro version of the software (this is just a registered version).
Now open your command prompt and cd to the directory of the total video converter.
Then enter the command:

“tvc /f inPath.flv /o outPath.wav /pi ini\wav.ini /pn Wav Audio normal quality

Note : You can convert the flv to many different audio or video formats.


In the above example, /f goes before the file to be converted and /o goes before the output file. Following parameters are the /pi and /pn parameters. Warning: If you leave out either the pi or pn parameter you will get the following error: “Error! The option /pi must be set”

The pi parameter is the path to the ini preference file you want to use. In the Total Video Converter application folder there is a subdirectory called ini in that directory is an .ini file for each format supported. In the example above, we want to use the wav.ini file so we use the parameter /pi ini\wav.ini

To set the pn parameter we must go into the ini folder and open the wav.ini file with our text editor. At the top of the wav.ini text document we see “[Wav Audio normal quality].” Farther down we see the line “[Wav Audio high quality].” The text in between the “[ ]” is used as for pn parameter. In the above example we choose “Wav Audio normal quality” and hence used: /pn Wav Audio normal.

Finally, you can write a PHP, ASP.NET, etc server script to launch this command line application to perform the conversion upon user request from your server.

Labels: