本站首页    管理页面    写新日志    退出


«September 2025»
123456
78910111213
14151617181920
21222324252627
282930


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7618833
建立时间:2006年5月29日




[视频处理]Ming video/streaming examples
软件技术

lhwork 发表于 2007/2/5 12:36:11

1. Creating FLV filesFor 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 a 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. 2. Embeding FLV files in SWF moviesThis 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 video4. Streaming VideoFor 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 StreamingFor 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. Example Files 500)this.width=500'>test.php 1 k 500)this.width=500'>test.pl 1 k 500)this.width=500'>test-embeded.swf 543 k 500)this.width=500'>test.flv 542 k 500)this.width=500'>test-embeded.c 1 k 500)this.width=500'>test-streams.c 1 k The original mpeg file can be found at http://www.informatik.uni-freiburg.de/~kiro/videos/KiRoPaderborn2.mpeg


阅读全文(2220) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.063 second(s), page refreshed 144804059 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号