by January 5, 2004 0 comments



With Flash player 7 the video quality has improved greatly. It supports higher frame rate and there are additional goodies to be used at runtime. 

When video files are imported to the Flash authoring environment, they’re encoded as ‘Flash for Video’ or FLV files. Any video file can be encoded to FLV using either external tools like Sorenson squeeze or the Flash Video Exporter plugin (available only with Flash MX 2004 Pro). After these video clips have been imported, they can be converted to standard movie clip objects and manipulated using Flash action script. You can also optimize these encoded A/V streams further by using the Sorenson Spark codec. In order to keep things simple and Flash player size small, there is only one video-rendering format. 

Once you’ve made your video Flash compatible, it can be presented in various ways. The delivery mechanism depends on factors such as type of video content, bandwidth, length, the level of user interaction required, and whether the video features Britney SpearsJ! We’ll talk about how this can be done using Flash 7. There are three approaches to deploying video content. 

Flash provides the user with various pre made media components

Embedded FLV
Embedding FLV is the simplest way of deploying video in Flash. Video files are imported and encoded directly into the Flash authoring environment. This delivery method is good for small files. The limitations of using this approach are: you have to download the whole file on your machine before playback can start; any video that’s longer than two minutes makes the audio sync go haywire; the frame rate of movie and video file has to necessarily be the same; and every time you need a preview the whole file has to be published, which can lead to lengthy authoring sessions.

External FLV
Using this option, the FLV files are remotely played from the Flash player. The files can be played externally by using either progressive or streaming FLV downloads to the Flash player. 

Progressive FLV
In this approach, external FLV files are cached on a host machine and played at runtime without considering the file size and media length. There is no two minute limitation as audio and video remain in sync and this also allows you to create various versions of FLV files for different audiences using different download speeds. As FLV files are published separately, authoring time is more efficient. 

The Flash MX Professional 2004 comes with the set of media components that can be used to quickly add the video/audio control to our Flash projects. Media components provide support for both progressive and streaming FLV files. 

Streaming FLV 
A Flash communication server serves streaming FLVs remotely. Also, files are not cached on your system, saving precious disk space. However, this approach may not be practical for smaller projects, as cost can be a major factor for setting up this solution. For media projects using live video streams and for setting up audio/video stations, this is still the best choice of delivery. 

Exported FLV
Using this option, content created in Flash is exported to QuickTime, AVI, or sequences of still frames for playback by other software. 

The media player componet can be used to play video in Flash

Performance is the crucial factor here. For instance, the best approach for using small clips is to embed them directly into Flash; but the same should not be done while dealing with large videos. Optimization has a direct impact on quality and file size, which are directly proportional. Don’t knock on Einstein’s grave yet; here is what it means: optimization reduces file size, but reduces quality as well. Also, higher quality may lead to poor performance, and vice-a-versa. To strike a balance, we need to test our media at different optimization settings to achieve that ‘optimal optimization’ setting. You must consider these factors and decide what tradeoffs are acceptable while selecting a method for delivering video within the Flash player. Let’s see how we can actually do that.

Let’s Code! 
Let’s get our hands dirty with some code to play our FLVs externally. You will require Flash MX 2004 professional for this.
First create a FLV using Flash’s FLV export option. Make a new Flash file and import a video file into its Library using the File>Import>Import to Library command. 

Right click on the file in the Library and choose properties. Click on the export button on the properties window. This will export the file in FLV format. Name the file as test.flv 

Create a new Flash document and save it in the same folder as test.flv     

As we want to load an external .flv at runtime, we’ll require one holder object in Flash. From the Library panel’s option, select New Video. Drag the video object on to the stage and give it an instance name as ‘holder_video’
Add the following code listing on a new layer in Flash.

test_nc = new NetConnection(); 
test_nc.connect(null); 
test_ns = new NetStream(test_nc); 
holder_video.attachVideo(test_ns); 
test_ns.play(“test.flv”); 

The above code first creates an instance (test_nc) of the NetConnection object and is used while creating test_ns, the NetStream instance. Later the attachVideo command associates holder_video with any media that streams through the test_ns NetStream. Finally, play() starts the video. 

Using the Media Components 
Flash MX 2004 Professional, comes with some pre-made media components that make implanting video a breeze. These consist of three sub components: MediaDisplay, MediaPlayback, and MediaController. They are very sophisticated and useful in deploying video very quickly on the Net. We would deploy the MediaPlayback component as an example.

  1. Create a new Flash document and save it in the same folder as test.flv 

  2. Drag an instance of MediaPlayback component. Select the component on stage and press Alt+F7 to open Component Inspector Panel.

  3. Type the name of our flv file, test.flv into the URL field. 

That’s it! Test the movie and you are ready to deploy the video for the Web. 

Owas Bhat, Manager, GE, e-learning division

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

<