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");
}
4

1 回答 1

0

检查此链接:如何在 Flex Builder 3 中捕获流式视频显示并将其保存到磁盘?

简而言之,它不能完成,因为它违反了安全限制。解释它的文档位于第 49 页:http: //wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/flashplayer/pdfs/flash_player_10_security.pdf

于 2012-10-12T17:44:23.080 回答