我正在尝试从 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");
}