使用 MP4 编码在 Flash 中流式传输网络摄像头视频 [英] Streaming webcam video in Flash using MP4 encoding

查看:43
本文介绍了使用 MP4 编码在 Flash 中流式传输网络摄像头视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发的 Flash 应用程序的功能之一是能够将网络摄像头流式传输给其他人.我们只是使用 Flash 中的内置网络摄像头支持并通过 FMS 发送.

One of the features of the Flash app I'm working on is to be able to stream a webcam to others. We're just using the built-in webcam support in Flash and sending it through FMS.

有些人要求获得更高质量的视频,但我们已经在 Flash 中使用了最高质量设置(将质量设置为 100%).

We've had some people ask for higher quality video, but we're already using the highest quality setting we can in Flash (setting quality to 100%).

我的理解是,在较新的 Flash 播放器中,他们为视频添加了对 MPEG-4 编码的支持.我创建了一个简单的测试 Flex 应用程序来尝试比较 MP4 与 FLV 编码的视频质量.但是,我似乎根本无法使用 MP4.

My understanding is that in the newer flash players they added support for MPEG-4 encoding for the videos. I created a simple test Flex app to try and compare the video quality of the MP4 vs FLV encodings. However, I can't seem to get MP4 to work at all.

根据 Flex 文档 要使用 MP4 而不是 FLV,我唯一需要做的就是在调用发布时在流的名称前加上mp4:":

According to the Flex documentation the only thing I need to do to use MP4 instead of FLV is prepend "mp4:" to the name of the stream when calling publish:

将流名称指定为字符串带有前缀 mp4:有或没有文件扩展名.前缀向服务器表明该文件包含 H.264 编码的视频和MPEG-4 中的 AAC 编码音频第 14 部分容器格式.

Specify the stream name as a string with the prefix mp4: with or without the filename extension. The prefix indicates to the server that the file contains H.264-encoded video and AAC-encoded audio within the MPEG-4 Part 14 container format.

当我尝试这样做时,什么也没有发生.我没有在客户端引发任何事件,没有抛出异常,而且我在服务器端的日志记录没有显示任何流开始.

When I try this nothing happens. I don't get any events raised on the client side, no exceptions thrown, and my logging on the server side doesn't show any streams starting.

相关代码如下:

// These are all defined and created within the class.
private var nc:NetConnection;
private var sharing:Boolean;
private var pubStream:NetStream;
private var format:String;
private var streamName:String;
private var camera:Camera;

// called when the user clicks the start button
private function startSharing():void {
  if (!nc.connected) {
    return;
  }

  if (sharing) { return; }

  if(pubStream == null) {
    pubStream = new NetStream(nc);
    pubStream.attachCamera(camera);
  }
  startPublish();

  sharing = true;
}

private function startPublish():void {
  var name:String;

  if (this.format == "mp4") {
    name = "mp4:" + streamName;
  } else {
    name = streamName;
  }

  //pubStream.publish(name, "live");
  pubStream.publish(name, "record");
}

推荐答案

了解您正在运行的 FMS 版本会有所帮助吗?看来您至少需要 FMS 3.0.2.

Would be helpful to know the version of FMS you are running? It seems like you need at least FMS 3.0.2.

这篇关于使用 MP4 编码在 Flash 中流式传输网络摄像头视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆