Flex 4,图像从视频显示创建快照?

发布于 2024-10-14 12:57:00 字数 1805 浏览 4 评论 0原文

我的代码可以在本地主机上运行,​​但不能在服务器上运行,这可能是什么问题?我也想从 php 返回一些字符串到 Flex 应用程序,但我无法解决这个问题。 这是我的代码:

        [Bindable]
        public var encodedString:String;
        [Bindable]
        public var img_name:String;
        [Bindable]
        public var pid:int;         
        [Bindable]
        public var url_string:String;                   

        protected function btn_save_clickHandler(event:MouseEvent):void
        {
            var bmpData:BitmapData = new BitmapData(videoDisplay.width,videoDisplay.height-25);             
            bmpData.draw(videoDisplay);

            var bm:Bitmap = new Bitmap(bmpData);  
            img.source = bm;  

            var jpg_e:JPEGEncoder = new JPEGEncoder();
            var bytes:ByteArray = new ByteArray();
            bytes = jpg_e.encode(bmpData);

            var b64e:Base64Encoder = new Base64Encoder()
            b64e.encodeBytes(bytes);

            encodedString = b64e.flush();

        }


        protected function btn_save_image_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub      
            save_img.send();
        }                       

        <mx:request xmlns="">
            <img_data>                  
                {encodedString}
            </img_data>
            <image_name>
                {img_name}
            </image_name>
            <post_id>
                {pid}
            </post_id>
        </mx:request>

    </mx:HTTPService>

单击“保存”时,我想将快照从视频显示保存到 img。此外,我将图像发送到 php,并希望获得已完成的简单文本答案,但我总是返回对象。

我用 php 保存图像,然后打印消息,如下所示:

打印“这是消息!”;

我认为问题是当我需要将图像从控件(视频显示)保存到图像控件时,但此问题仅发生在服务器上而不是本地主机上

my code works on localhost,but not on the server,what could be the problem?I also want to return some string back from php to flex app but I can't solve that.
Here is my code :

        [Bindable]
        public var encodedString:String;
        [Bindable]
        public var img_name:String;
        [Bindable]
        public var pid:int;         
        [Bindable]
        public var url_string:String;                   

        protected function btn_save_clickHandler(event:MouseEvent):void
        {
            var bmpData:BitmapData = new BitmapData(videoDisplay.width,videoDisplay.height-25);             
            bmpData.draw(videoDisplay);

            var bm:Bitmap = new Bitmap(bmpData);  
            img.source = bm;  

            var jpg_e:JPEGEncoder = new JPEGEncoder();
            var bytes:ByteArray = new ByteArray();
            bytes = jpg_e.encode(bmpData);

            var b64e:Base64Encoder = new Base64Encoder()
            b64e.encodeBytes(bytes);

            encodedString = b64e.flush();

        }


        protected function btn_save_image_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub      
            save_img.send();
        }                       

        <mx:request xmlns="">
            <img_data>                  
                {encodedString}
            </img_data>
            <image_name>
                {img_name}
            </image_name>
            <post_id>
                {pid}
            </post_id>
        </mx:request>

    </mx:HTTPService>

When click save,I want to save snapshoot from videodisplay to img.Also I send image to php,and want to get simple text answer that is done,but I always get object returned.

and I save image with php,and just print message,like this :

print "this is message!";

I think the problem is when I need to save image from control(video display) to image control,but this problem only occure on server but not on localhost

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹏半生如梦愿梦如真 2024-10-21 12:57:00

您需要将最后一行从: 更改

str = b64e; 

为:

str = b64e.toString(); 

请注意,调用 toString() 将清除 b64e 对象。

更新:

让我们尝试将视频放入容器中,然后对其执行 .draw() ,我们将向其中添加一些附加内容,以便在视频没有显示时我们可以获取该内容出现。

<s:Group id="videoContainer">
  <mx:Label text="Hello" />
  <mx:VideoDisplay id="videoDisplay" />
</s:Group>

希望您已经完成了其中的 VideoDisplay 部分,并且可以更新代码以添加包含组。

当您执行 .draw() 时,请使用 videoContainer 而不是 videoDisplay 即。 :

 bmpData.draw(videoContainer);

这只是为了测试,如果存在沙盒问题(看起来肯定是这样),位图中只会显示“Hello”,并且视频仍然看不到。

You need to change the last line from:

str = b64e; 

To:

str = b64e.toString(); 

Note that calling toString() will clear the b64e object.

Update:

Let's try placing the video in a container, and then doing the .draw() on that, we'll add some additional content to it so that we can get that if the video doesn't show up.

<s:Group id="videoContainer">
  <mx:Label text="Hello" />
  <mx:VideoDisplay id="videoDisplay" />
</s:Group>

Hopefully you are already doing the VideoDisplay part of this, and you can update your code to add the containing group.

When you do the .draw() use videoContainer instead of videoDisplay ie. :

 bmpData.draw(videoContainer);

This is just to test, if there is a sandbox issue, which it defintely seems to be, only "Hello" will show up in the bitmap, and the video will still not be seen.

薄荷→糖丶微凉 2024-10-21 12:57:00

该视频来自哪里?相机?飞行管理系统?

这可能是跨域问题或与 FMS(或其他流媒体服务器)相关的问题。

这篇文章可以帮助您:如何指定跨域策略文件以允许 Flash 从 RTMP (Wowza) 视频流中抓取位图?

Where does that video come from? Camera? FMS?

It might be either a crossdomain issue or something related to FMS (or another streaming server).

This post could help you : How do I specify a crossdomain policy file to allow Flash to grab a bitmap from an RTMP (Wowza) video stream?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文