使用 NetStream 类如何检测是否附加了工作视频?

发布于 2024-11-27 08:26:15 字数 891 浏览 4 评论 0原文

我正在 Flash 中构建视频聊天,除了我试图检测其他用户是否正在发送工作视频流的部分之外,一切都运行良好。

其他用户不发送视频的原因有多种。

  1. 其他用户没有摄像头
  2. 其他用户有摄像头,但该摄像头当前被另一个应用程序占用(Skype、Photo Booth、Google Talk 等)
  3. 其他用户有摄像头,但不允许使用他的摄像头/她的相机。
  4. (我猜是其他意外问题...)

那么,如何使用 NetStream 类检测从其他用户收到的流是否是黑流(由于上述原因)?

我想出的最接近的方法是添加一个计时器,该计时器从我从其他用户收到的流中轮询 currentFps() 函数。但到目前为止,这似乎相当不可靠,因为我可能会得到 currentFps() == 0 并因此显示错误,即使在某些情况下我实际上从流中获取了视频。这样做的原因是因为我每 4 秒轮询一次 API 的 currentFPS 函数,假设在 00:00:04 根据轮询我得到“无视频”,但在 00:00:05 视频开始播放,因此我需要等到下一个刻度线,直到错误消息消失

这就是我当前的民意调查的样子

function subscribingStatusPoll(e:TimerEvent):void {
  if (subscribingStream.currentFPS == 0){
    error.text = "No video found from the other user..."
  } else {
    error.text = "";
  }
}

这是我可以想出的唯一黑客来检测此问题,但是这个是不可靠的,实际上我更喜欢一种方法来立即检测我收到的流是否附加了工作视频,而无需进行这种丑陋的民意调查。

I'm building a video chat in flash and everything works really well, except for the part where I'm trying to detect if the other user is sending a working video stream.

There's a couple of reasons why the other user isn't sending video.

  1. The other user got no camera
  2. The other user got a camera, but the camera is currently being occupied by another application(Skype, Photo Booth, Google Talk, etc.)
  3. The other user got a camera but hasn't allowed the use of his/hers camera.
  4. (Other unexpected problems I guess...)

So how do I detect if the stream I receive from the other user is a black stream(because of the reasons above) using the NetStream class?

The closest thing I have came up with is by adding a timer that polls the currentFps() function from the stream I receive from the other user. But so far this seems pretty unreliable because I might get currentFps() == 0 and show an error because of this even though I actually got video from the stream in some cases. The reason for this is because I poll the API every 4 seconds for the currentFPS function and let's say at 00:00:04 I get "no video" according to the poll but at 00:00:05 the video kicks in, and therefor I need to wait until the next tick until the error message disappears

This is what my current poll looks like

function subscribingStatusPoll(e:TimerEvent):void {
  if (subscribingStream.currentFPS == 0){
    error.text = "No video found from the other user..."
  } else {
    error.text = "";
  }
}

This is the only hack I that I can come up with to detect this, but this is unreliable and I actually would prefer a way to instantly detect if the stream I receive got a working video attached to it without this ugly poll.

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

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

发布评论

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

评论(2

离去的眼神 2024-12-04 08:26:15

虽然我同意不从服务器端发送“空白”流,但您可能无权访问服务器端,因此它不适用于您的情况。在客户端,您可以按一定时间间隔从流中抓取一帧并检查更改或仅查看时间戳(查找随时间的推移而增加的情况)。这些选项可能看起来很麻烦,但它们绝对应该在 Flash 中工作。

如果我必须自己开发这个,我会从这个边缘检测代码开始,并将网络摄像头抓取替换为播放流中的帧抓取。

http://www.laserpirate.com/as3edgeandmotion/

While I would agree with not sending a "blank" stream from the server-side, you may not have access to the server-side and thus it would not apply to your situation. On the client-side you could grab a frame from the stream at an interval and check for changes or just look at the timestamps (look for an increase over time). These options may seem hack-ish but they should definitely work in Flash.

If I had to develop this myself, I would start with this edge detection code and replace the webcam grab with a frame grab from the playing stream.

http://www.laserpirate.com/as3edgeandmotion/

稀香 2024-12-04 08:26:15

错误的方法。
尽管在接收端验证数据是一个好主意,但无法检测流是否是真实数据。
在您的情况下,正在发送的流不是真正的相机流,但它仍然是一个流。
没有检测到这一点。
为什么不在发送客户端上处理验证呢?

Wrong approach.
As much as validating the data on the receiving end is a great idea there is no way to detect if a stream is real data or not.
In your case the stream that is being sent is not a true camera stream but it is a stream none-the-less.
There is no detection for this.
Why not just handle validating on the sending client?

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