The Flash Guru: Synchronizing Flash Videos, Reading FLV Metadata, Working with Icecast
Got a Flash video question? Let Stefan Richter, the Flash guru, help you out. In this monthly series, Richter will answer Flash questions sent in by StreamingMedia.com readers or from the Streaming Media forums.
Richter is the founding director of Muchosmedia, a UK-based software firm specializing in rich Internet applications. The company works for an international client base that includes ITV, Unilever, and the Tate Modern, and recently launched its first product, Scribblar, an online collaboration tool which is proving popular in the eLearning community. Richter also maintains his personal blog, the popular FlashComGuru.
Stefan's first question this month comes from
Hi all. Are there any tricks available to have two FLVs play synchronized? I've done it before with SMIL/QT/Real but can't find any good solution for Flash.
The short answer: No. Sorry, Stefan says, but there's nothing in the Flash build that allows you to do that. Creating a synchronization system is hard and not all that reliable. If the FLVs need perfectly accurate synching, "then I would say don't even bother," is Stefan's answer.
If your video files are short and you only need them to be roughly aligned, you can use progressive downloads. Have the browser pre-load both videos and then start them at the same time. "In that case, they will be fairly well synchronized," Stefan says.
But pre-loading files isn't always practical, especially for longer files. If you need to use streaming files, the answer becomes messy. During playback, one video might pause to buffer, requiring the other to stop, as well. That would create a noticeable break to the viewer. You'd also have to remove controls that let the viewer skip ahead.
Stefan says he's never seen a good example of synchronized FLV files, and he's seen a lot of Flash. This is a question that comes up often, he says, but to really work it would need to be a built-in feature. There would need to be something on the server that keeps the two videos synchronized. He's pretty sure that feature request has come up before at Adobe, so perhaps one day they'll implement it.
Our second question comes from jgarniss:
I would prefer to use Java if possible, but what is the best way to read the metadata contained in the FLV files being streamed?
This is a bit of a strange question, says Stefan, because he's not sure if you want to do the reading on the client side or the server side.
On the client side, reading metadata is easy using ActionScript. When a video starts up, it fires an event called onMetaData which contains all the metadata available for that video. This is normally used for laying out the video player.
If you want to do a server-side action, you'll need to use Java. Stefan isn't as well versed in Java, but he suggests you take a look at this Python code and rewrite it in Java.
Our third and final question for the month also comes from jgarniss:
Total newbie here, but I am trying to understand the best way to stream Flash encapsulated streams in conjunction with Icecast. If I sound clueless, I'm not far from it!
Is someone willing to explain a) what this truly is and b) how to actually do it so that the Flash video is streamed? I am looking to use FLV as the format for audio data but still be able to send out data to the player so that we can trigger specific data on the client.
If I'm not clear, that's one of the reasons I am asking these questions, so that I can get some clarity.
A little clarity would be welcome. What's missing from the question, says Stefan, is what the poster is trying to accomplish. If he's trying to stream Flash video, he could use one of the Flash streaming video providers. However, it's hard to tell what the goal is. Write in again, jgarniss, and tell some more about your project. What kind of data are you streaming and what kind of triggers are you trying to create?
Submit your Flash video questions to Streaming Media’s Formats, Codecs, and Players forum, or send them directly to the author at email@example.com
In this month's installment, Stefan Richter tackles questions on publishing a stream with DVR options, using HTTP Live Streaming, and creating a virtual video capture device.