简体   繁体   中英

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. It records using a Red5 server which is installed on a remote Amazon EC2 server.

To record, I'm using the following settings

  • Width, height and FPS (for Camera.setMode() ) - 1920 x 1080 and 10
  • Bandwidth and Quality (for Camera.setQuality() ) - 0 and 80
  • Buffer time (for NetStream.setQuality() ) - 3600

I'm able to record video till the buffer gets filled (I'm monitoring the NetStream.BufferLength constantly)

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.

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. 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.)

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.

My Internet upload speed is around 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.

Your issue stems from these 3 causes happening simultaneously:

  • 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)
  • Red5's buggy mechanism for dealing with video data coming at the end of the recording

Red5 has been plagued by many recording issues. This HDFVR documentation article covers Red5's various recording issues and the mechanism for coping with the FP buffer when recording over slow connections.

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).

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.9 had audio video recording totally broken.

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. The queueThreshold value measures rtmp messages/packets.

Red5 1.0 final, 1.0.1 and 1.0.2 had the delayed write mechanism totally broken. With it turned on, over slow connections, Red5 was producing .flv files with only 1 or 2 video keyframes. When playing back such .flv files the video would get stuck from the 1st second and playback would continue only with audio. Using yamdi to extract the keyframe data confirmed that the .flv files were lacking video keyframes.

However, thanks to HDFVR 's code contributions to Red5, Red5 1.0.3 and later has video recording over slow connections fixed .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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