在流式传输到 Flash 中的 NetStream 之前裁剪相机

发布于 2024-10-26 00:06:14 字数 1139 浏览 5 评论 0原文

我正在为 Flash 中的网络摄像头构建一个非常简单的发布器。我想选择一个摄像机并将流发送到 RTMP URL,基本上:

Camera camera = Camera.getCamera();
NetStream ns = new NetStream(connection);
ns.attachCamera(camera);
ns.publish("stream name");

现在,我知道我可以在摄像机上设置一个模式,如下所示:

camera.setMode(320, 240, 25);

但我真正想做的是设置一个模式,例如 360 x 480(与相机录制的宽高比不同)并让闪光灯为我裁剪图像。有办法做到这一点吗?

编辑:我知道Flash Media Live Encoder可以做到这一点,但我想在浏览器中做到这一点。

根据 ActionScript 文档对于Camera.setMode,有一个可选的第四个参数,听起来很有趣,favorArea。来自文档:

favorArea:Boolean(默认 = true) - 指定在相机不操作的情况下是否操作宽度、高度和帧速率具有满足指定要求的本机模式。默认值为true,这意味着维持捕获大小是有利的;使用此参数会选择与宽度和高度值最匹配的模式,即使这样做会降低帧速率,从而对性能产生不利影响。要以相机高度和宽度为代价最大化帧速率,请为 favorArea 参数传递 false

但它默认为 true 并且它似乎没有达到我想要的效果(我想裁剪每帧的图像,扔掉一些数据,然后传输其余数据)。

I'm building a very simple publisher for the webcam in Flash. I want to select a camera and send the stream to a RTMP URL, basically:

Camera camera = Camera.getCamera();
NetStream ns = new NetStream(connection);
ns.attachCamera(camera);
ns.publish("stream name");

Now, I know I can set a mode on the camera, like this:

camera.setMode(320, 240, 25);

But what I really would like to do is to set a mode such as 360 x 480 (not the same aspect ratio as the camera is recording) and have Flash crop the image for me. Is there a way to do that?

Edit: I know Flash Media Live Encoder can do this, but I would like to do it in the browser.

According to the ActionScript docs for Camera.setMode, there is an optional fourth parameter that sounds interesting, favorArea. From the docs:

favorArea:Boolean (default = true) — Specifies whether to manipulate the width, height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default value is true, which means that maintaining capture size is favored; using this parameter selects the mode that most closely matches width and height values, even if doing so adversely affects performance by reducing the frame rate. To maximize frame rate at the expense of camera height and width, pass false for the favorArea parameter.

But it defaults to true and it doesn't seem to make what I want (I want to crop the image of each frame, throw away some data, and stream the rest).

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

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

发布评论

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

评论(1

缪败 2024-11-02 00:06:14

据我所知,你不能。

要裁剪或以其他方式进行转换,您需要获取原始视频。存在 Camera.setKeyInterval Camera.setQuality 带有带宽参数和只读 NetStream.videoSetting 在连接相机之前为空,表明所有压缩均由 Camera 对象内部处理,而 NetStream 仅按原样传输。
同样,Adobe Flash 平台 - 处理视频 没有有关转换或压缩/解压缩视频流作为数据的信息 (flash.media.VideoCodec 只是一个枚举)。

与此不同的是,Media Live Encoder 的作用是:解码来自摄像机的流(需要采用受支持的格式之一),可选择进行转换,然后重新编码。

最后,我认为浏览器有点放错了全功能流媒体服务器的位置!这是守护进程的工作!

From what I can see, you cannot.

To crop or otherwise transform, you need to get raw video. Presence of Camera.setKeyInterval, Camera.setQuality with bandwidth parameter and a read-only NetStream.videoSetting that is null until a camera is connected suggests that all the compression is handled by Camera object internally while NetStream only transfers it as-is.
Similarly, Adobe Flash Platform - Working with video has no word about either transformations or compressing/decompressing video streams as data (flash.media.VideoCodec is a mere enumeration).

Unlike this, Media Live Encoder does just that: decode the stream from camera (which needs to be in one of supported formats), optionally transform and then re-encode it.

And finally, I see browser as somewhat misplaced a location for a full-featured streaming server! It's a job for a daemon!

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