简体   繁体   English

使用Flash和Red5 Media Server录制高质量的视频

[英]Recording high quality video using Flash and Red5 Media Server

I'm running a Video Recorder application (written in ActionScript 3.0) from my local machine. 我正在从本地计算机运行Video Recorder应用程序(用ActionScript 3.0编写)。 It records using a Red5 server which is installed on a remote Amazon EC2 server. 它使用安装在远程Amazon EC2服务器上的Red5服务器进行记录。

To record, I'm using the following settings 要记录,我使用以下设置

  • Width, height and FPS (for Camera.setMode() ) - 1920 x 1080 and 10 宽度,高度和FPS(适用于Camera.setMode() )-1920 x 1080和10
  • Bandwidth and Quality (for Camera.setQuality() ) - 0 and 80 带宽和质量(对于Camera.setQuality() )-0和80
  • Buffer time (for NetStream.setQuality() ) - 3600 缓冲时间(对于NetStream.setQuality() )-3600

I'm able to record video till the buffer gets filled (I'm monitoring the NetStream.BufferLength constantly) 我可以录制视频直到缓冲区被填满(我一直在监视NetStream.BufferLength

Once, the recording is stopped - the data in the buffer is sent to the server. 一旦记录停止,缓冲区中的数据将发送到服务器。 And now, when I try to playback with ( bufferTime = 1 ) The video doesn't appear. 现在,当我尝试使用( bufferTime = 1 )播放视频时,该视频没有出现。

I have ssh 'ed into the EC2 server and have seen that the file does get created in the red5/webapps/vod/streams folder, but I'm am unsure about its quality or whether it has recorded correctly or not. 我已经将ssh插入EC2服务器,并且看到确实在red5/webapps/vod/streams文件夹中创建了该文件,但是我不确定其质量或是否已正确记录。 I've even used the command line based movie player mplayer to try and play the file, but it doesn't play because I'm guessing the Ec2 server Ubuntu lacks the playback plugins (not sure of this though.) 我什至已经使用基于命令行的电影播放器mplayer尝试播放该文件,但由于我猜测Ubuntu 2缺少Ec2服务器缺少播放插件(因此不确定),它无法播放。

However, when it's a low quality recording with 640 x 480 instead of 1920 x 1080, the buffer doesn't get filled beyond 0.1 or 0.2, and the video plays back smoothly. 但是,当它是640 x 480而不是1920 x 1080的低质量记录时,缓冲区不会被填充超过0.1或0.2,视频会流畅播放。

My Internet upload speed is around 300 kbps. 我的Internet上传速度约为300 kbps。

How can I (if it is possible), record and then playback high quality video? 我如何(如果可能)录制和播放高质量视频?

You need to use 您需要使用

// Ensure that no more than 43690.6(43K/second) is used to send video. camera.setQuality(43690.6,0);

This works for me. 这对我有用。 I used Amazon EC2 extra large instance. 我使用了Amazon EC2超大型实例。

Your issue stems from these 3 causes happening simultaneously: 您的问题源于同时发生的以下3个原因:

  • recording high quality video which results in the data having to be buffered locally 录制高质量的视频,导致数据必须在本地缓存
  • Flash Player buffering just the video data (good for when doing live streaming) Flash Player仅缓冲视频数据(适合进行实时流传输时使用)
  • Red5's buggy mechanism for dealing with video data coming at the end of the recording Red5的错误处理机制,用于处理录制结束时出现的视频数据

Red5 has been plagued by many recording issues. Red5受到许多录制问题的困扰。 This HDFVR documentation article covers Red5's various recording issues and the mechanism for coping with the FP buffer when recording over slow connections. 该HDFVR文档文章介绍了Red5的各种记录问题,以及在通过慢速连接进行记录时应对FP缓冲区的机制。

The media server needs to account for this by waiting more for the video packets and sort them together with the audio packets before writing the data to disk (.flv file). 媒体服务器需要通过等待更多视频文件并将其与音频数据包一起排序来解决此问题,然后再将数据写入磁盘(.flv文件)。

Red5 0.8 had no such mechanism thus recording high quality video over slow connections resulted in low quality/scrambled video files (just audio, all video at the end). Red5 0.8没有这种机制,因此通过慢速连接录制高质量的视频会导致质量低下/加扰的视频文件(只是音频,最后是所有视频)。

Red5 0.9 had audio video recording totally broken. Red5 0.9的音频视频记录完全损坏。

Red5 1.0 RC1 had a new delayed write mechanism - controlled by in Red5/conf/red5-common.xml - that waits for the audio and video data and rearranges the packets before writing them to disk. Red5 1.0 RC1有一个新的延迟写入机制-在Red5 / conf / red5-common.xml中由控制-等待音频和视频数据并重新排列数据包,然后再将其写入磁盘。 The queueThreshold value measures rtmp messages/packets. queueThreshold值测量rtmp消息/数据包。

Red5 1.0 final, 1.0.1 and 1.0.2 had the delayed write mechanism totally broken. Red5 1.0 final,1.0.1和1.0.2的延迟写入机制被完全破坏。 With it turned on, over slow connections, Red5 was producing .flv files with only 1 or 2 video keyframes. 启用它后,通过慢速连接,Red5只能生成仅具有1个或2个视频关键帧的.flv文件。 When playing back such .flv files the video would get stuck from the 1st second and playback would continue only with audio. 播放此类.flv文件时,视频将从1秒开始停滞,并且仅以音频继续播放。 Using yamdi to extract the keyframe data confirmed that the .flv files were lacking video keyframes. 使用yamdi提取关键帧数据可确认.flv文件缺少视频关键帧。

However, thanks to HDFVR 's code contributions to Red5, Red5 1.0.3 and later has video recording over slow connections fixed . 但是,由于HDFVR对Red5的代码贡献, Red5 1.0.3及更高版本已修复了慢速连接上的视频记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM