HD Recording with HDFVR and Red5 Media Server

HD Recording with HDFVR (build 505) and Red5 v0.8.0 on Windows XP

This article details the issue of trying to get HD recordings to work with HDFVR and Red5 Media Server v0.8.0. HDFVR is being served by an IIS 7.5 web server running on Windows 2008. Red5 v0.8.0 is running on a Windows XP machine that is also being used as a Kiosk client with a Logitech HD Pro Webcam C920.

Audience:
This post is meant for HDFVR + Red5 administrators and/or installers that have done the basic installs of HDFVR and Red5, but can’t seem to get Video & Audio to record properly in HD. This solution was used in a Kiosk machine for recording on a LAN with the web server serving the HDFVR front end code. So, all traffic is on a LAN, even the Red5 server is inside the LAN (actually it’s running on the Kiosk machine).

Problem Description:
We purchased and HDFVR HD license, but couldn’t get the video codec Sorenson to record with synchronized audio & video, we tried the h264 (h264_r for Red5) and the FLA files produced were near perfect but they wouldn’t playback in the HDFVR frontend (not being able to review the video before posting it was a stopper on our project). Much research, Googling, and some back-and-forth with the HDFVR team made it sound like Red5 v0.8 wasn’t going to be able to handle the HD stream (NOTE: Red5 v1 rc 1 or 2 wouldn’t install and record on our XP or a Win7 box). However, after seeing that the h264 was recording properly, it just wouldn’t playback in the HDFVR SWF, I became dubious that it “couldn’t” be done. During my research I noticed several posts about the SWF/Flash Player having a throughput barrier around 1MBps, so I crunched some numbers and got the stream down under that at 1/2 the video size (480×270) and voila! it recorded without anomalies.

Research:
http://avchat.net/support/documentation/avchat3-bandwidth
In short, what happens is once the video starts buffering on the SWF then Red5 v0.8 doesn’t know how to properly put the audio and video back together. The SWF keeps sending the audio thinking that the other end of the stream will still want audio even if the video is being held up. We were seeing choppiness, skipping and then fast forward and catch up in the last couple seconds of a video, which I assume was Red5 trying to re-synchronize the Video to the Audio.

Environment:

  • Web Server
    • IIS v7.5 on Windows 2008 Server
    • HDFVR build 505
  • Kiosk Machine
    • Logitech HD Pro Webcam C920
    • Java 1.6
    • Red 5 v0.8.0 Final on Windows XP
    • Firefox v13.0.1

Solution:
I played with the recording video sizes, did some sample recordings, and then looked at the screen shot image info. From the SS image info I got the file size (45 – 75kB @ 640×480) and multiplied it by the number of frames per second (FPS).

480×270: 25kB * 30fps = 768 KBps
640×360: 75kB * 15fps = ~1.15 MBps

I tried 640×360@24fps, but it would bog down, especially with movement or busy visuals. We just couldn’t rely on it. I then tried 480×270 and had it expand to fit the specified SWF display size of 640×480, but the stretching degraded/pixelized the image enough that we were thinking of going back to SD.

I also found information on the embed element’s quality attribute on Adobe’s site (link below). I started at “low” and worked up to “autohigh” and this seems to help keep the image size down to a useable size.

My math may be off, and I may be wrong on some of these things, but it works. Depending on the quality of your video camera you may have to adjust the numbers differently for it to work for you. I am not sure exactly what the cut-off is, or if it is the SWF/Flash Player or our LAN speed between the machines, but this solution is up and running in a high traffic museum exhibit

Web page SWF embed code:

NOTE: you may need the object code. Since our solution is being run on a Kiosk we had the bonus of being able to choose a fixed client browser (Firefox v13.x).

<embed src="VideoRecorder.swf?userId=Anonymous&recorderId=123" quality="autohigh" bgcolor="#98AEB5" name="VideoRecorder" play="true" loop="false" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" height="420" width="692">

See: http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html#main_Optional_attributes

avc_settings.php:
$config['qualityurl']='audio_video_quality_profiles/wide/640x360x15x90.xml';

Note: the quality profile name is arbitrary, but I made a couple dozen by the end and it was nice to be able to flip around while adjusting embed and camera settings.

audio_video_quality_profiles/wide/640x360x15x90.xml:

<?xml version="1.0" encoding="utf-8"?>
<bandwidth>
<item>
<nm>640x360@15fps</nm>
<df>0</df>
<bytes>0</bytes>
<q>90</q>
<fps>15</fps>
<kfps>5</kfps>
<w>640</w>
<h>360</h>
<snd>22</snd>
<sndSilencelevel>10</sndSilencelevel>
<vcodec>sorenson</vcodec>
</item>
</bandwidth>

Details:

  • fps – 15 frames per second, still looks good, our subjects are sitting and talked, moderately animated, multiple faces/bodies in the shot.
  • w – width of 640 pixels
  • h – height of 360 pixels (half of 720p *shrug*)
  • snd – sound setting of 44kbits/s Nelly Moser medium quality
  • sndSilenceLevel – Takes values from 0 to 100. Flash Player will consider any sound that is lower than the value of this tag as “silence” and thus will not send any data to the media server. Use 100 if you want to never send audio to the FMS server. Use 0 if you always want to send to the FMS server whatever the mic captures (even noise). – http://avchat.net/support/documentation/avchat3-bandwidth

Links:
http://www.red5.org/
http://hdfvr.com/
http://avchat.net/support/documentation/avchat3-bandwidth
http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html#main_Optional_attributes