The Blog

Dec 1, 2007

Flex and Flash Media Server 

by Maxim Porges @ 2:36 AM | Link | Feedback (0)

I was playing around with Flex and the Flash Media Server tonight. It seems that things have changed a few times over versions, since a lot of the code samples I found just didn't work. The best ones I found are linked below.

1) Creating Connections
2) Using the VideoDisplay control

I have a copy of FMS running in VMWare Fusion (it's Linux- and Windows-only) which I had no issue connecting to from my Flex 2 installation running in my JBoss server on my Mac. I was able to hook in to the webcam on my MacBook Pro and record some video. I was also able to pull that video back out easily enough as a stream using Flex. Finally, I took the raw .flv file created from the recording and called it directly from the Flex app without streaming. All worked like a charm.

I also downloaded ffmpegX and converted the .flv to .avi. I had a weird issue, though; the final movie was about 4 times faster than the original. After messing around with frame rates and other parameters without success, I converted the base .flv file to .flv format again using ffmpegX, and used the output .flv file from ffmpegX as an input file to convert to AVI. This time, the rate of the movie was correct. Not sure why I had to "clean" the file this way, but at least I have a workaround.

If you're wondering why I've been doing this, we had a question from the business about whether or not we could make recordings. I figured we could record using a Flex app and then either store the files as .flvs, or convert them to MP3 using ffmpeg and store them elsewhere. Not sure if we'll be using this solution or not, but at least I now have a good understanding of how the media capabilities of Flex and FMS work!