Ming Video Integration
For more information about Macromedia's FLV format see Macromedia's Video TechNote.
To convert avi/mpeg files to Macromedia's FLV format is using ffmpeg.The following example creates an FLV file with 12 fps and 100 kbps.
ffmpeg -i test.mpg -r 12 -b 100 test.flv
Since SWF 7 Macromedia supports another video codec called Screen Video Bitstream. For infomation on creating videos with this codec see here.
Related Hosting Alternatives
- A2 Hosting Alternatives With Windows
- HostGator Alternatives
- Bluehost Alternatives
- Cheap VPS with cPanel
- WPEngine Alternative
- HostGator Renewal Coupon
- Bluehost Renewal Coupon
2. Embeding FLV files in SWF movies
This example creates one SWF file with video information included.
... /* open videofile from local filesystem */ videoFile = fopen("test.flv", "r"); if(!videoFile) return -1; /* be sure to have the same framerate as the flv-file */ SWFMovie_setRate(movie, 8); /* insert videofile */ stream = newSWFVideoStream_fromFile(videoFile); SWFMovie_add(movie, stream); /* be sure to add enough frames */ for(i = 0; i < numFrames; i++) SWFMovie_nextFrame(movie); ...
3. Pseudostreaming (progressive Download)
Unlike the last example, this time the FLV file is stored separately from the SWF file. The download of the FLV data is triggered by an ActionScript. Works only with FlashPlayer >= 7.
... const char *script = " \ stop(); \ nc=new NetConnection(); \ nc.connect(null); \ NewStream=new NetStream(nc); \ video1.attachVideo(NewStream); \ NewStream.setBufferTime(10); \ NewStream.play(\"test.flv\"); \ "; action = compileSWFActionCode(script); /* place empty video-strea-character */ stream = newSWFVideoStream(); item = SWFMovie_add(movie, stream); /* name it, to be able to reference it by AS */ SWFDisplayItem_setName(item, "video1"); SWFMovie_add(movie, action); ...
Note: for this example only one movie-frame is needed to play the video
4. Streaming Video
For this example you need to install the Macromedia Communication Server. For testing purposes there is a developer version available at Macromedia's website.
After installation you need to create a directory for your project in /opt/macromedia/fcs/applications/ (or similar) and a streams/video directory in your project directory. Your project should look like this:
/opt/macromedia/fcs/applications/ test/streams test/streams/video test/streams/video/test.flv
This code is similar to the one above. Only the ActionScript code has changed. Works with FlashPlayer >= 6.
... const char *script = " \ stop(); \ nc=new NetConnection(); \ nc.connect(\"rtmp://localhost/test/video\"); \ NewStream=new NetStream(nc); \ video1.attachVideo(NewStream); \ NewStream.setBufferTime(10); \ NewStream.play(\"test\"); \ ";
5. MP3 Streaming
For MP3 streaming with the Macromedia Communication Server you need to setup your project first. See above examples for details. Create a new subdir called audio in your streams directory and copy your MP3 file to the new directory. Works with FlashPlayer >=7
Your first option is to attach the sound-stream to a VideoStream-character.
... const char *script = "\ stop(); stop(); \ nc=new NetConnection(); \ nc.connect(\"rtmp://localhost/test/audio\"); \ NewStream=new NetStream(nc); \ video1.attachVideo(NewStream); \ NewStream.setBufferTime(10); \ NewStream.play(\"mp3:test\"); \ "; ...
You can also attach the sound-stream to a MovieClip-character.