ActionScript 2:无法将视频帧抓取到位图

时间:2012-10-07 14:58:23

标签: flash bitmap actionscript-2

我正试图从RTMP视频中获取视频帧。视频播放得很好,我可以在我的视频表面上看到它,但我无法抓住它到位图,位图是黑色.. :( 我需要使用 ActionScript 2

有什么想法吗?

这是我的代码:

import flash.media.Video;
import flash.net.*;
import flash.display.*;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.*;

var i = 0;
var kVIDEOW = 720;
var kVIDEOH = 576;
var vidBmpHolder:BitmapData;
var vidBmpDisplay:BitmapData;
var vidBmp = createEmptyMovieClip("bmp", 0);
var vidBmpRect:Rectangle;
var vidBmpPoint:Point;

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect("rtmp://tvserver.chaneladd.tv:1935/live");
var stream:NetStream = new NetStream(connection_nc);


vidBmpHolder = new BitmapData(kVIDEOW, kVIDEOH, false, 0x000000);
vidBmpDisplay = new BitmapData(kVIDEOW, kVIDEOH, false, 0x000000);
vidBmpRect = new Rectangle(0, 0, kVIDEOW, kVIDEOH);
vidBmpPoint = new Point(0, 0);
// Create the Bitmap display object
vidBmp.attachBitmap(vidBmpDisplay,0);
vidBmp.x = 0;
vidBmp.y = 0;

if (stream) 
{
    video.my_video.attachVideo(stream);
    stream.play("437.stream");

    onEnterFrame = function ()
    {
        video.my_video.attachVideo(null);
        vidBmpHolder.draw(video);
        video.my_video.attachVideo(stream);
        vidBmp.attachBitmap(vidBmpHolder,0);
        addChild(vidBmp);
    };
}
else
{
    trace("not connected");
}

1 个答案:

答案 0 :(得分:0)