Recording/Streaming with H264 Produces bad MP4
I have installed FMS 4.5 and trying to use my flash recorder app to stream to the FMS to produce an MP4 file. An MP4 file gets generated on the FMS server but the file cannot be played with quicktime, VLC player, or windows media player. Can anyone kindly help me figure out what I am doing wrong or point me to right direction?
Here is my flash code:
private function init():void
{
_netConnection = new NetConnection();
_netConnection.client = this;
_netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_netConnection.connect("rtmp://127.0.0.1/test");
...
}
private function publishStream():void
{
_netStreamRecord = new NetStream(_netConnection);
_netStreamRecord.bufferTime = 360;
var h264Settings:H264VideoStreamSettings;
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_3_1);
h264Settings.setQuality(90000, 90);
h264Settings.setMode(640,480,12);
_camera.setQuality(90000, 90);
_camera.setMode(640,480,12,true);
_camera.setKeyFrameInterval(6);
_microphone.codec = SoundCodec.SPEEX;
_microphone.encodeQuality = 10;
_microphone.gain = 50;
_microphone.rate = 16;
_microphone.framesPerPacket = 2;
_microphone.setUseEchoSuppression(true);
_microphone.setSilenceLevel(0);
_netStreamRecord.attachCamera(_camera);
_netStreamRecord.videoStreamSettings = h264Settings;
_netStreamRecord.attachAudio(_microphone);
_netStreamRecord.publish("mp4:test.mp4", "record");
var metaData:Object = new Object();
metaData.codec = _netStreamRecord.videoStreamSettings.codec;
metaData.profile = h264Settings.profile;
metaData.level = h264Settings.level;
metaData.fps = _camera.fps;
metaData.bandwith = _camera.bandwidth;
metaData.height = _camera.height;
metaData.width = _camera.width;
metaData.keyFrameInterval = _camera.keyFrameInterval;
metaData.copyright = "VideoGenie Inc., 2012";
_netStreamRecord.send("@setDataFrame", "onMetaData", metaData);
}
Here is a sample video file that gets recorded: http://23.20.6.183/vod/test.mp4 (while none of my video players can play this file, I have found out that Chrome on Mac can play this file but it still doesn't play the audio)
Thanks in advance for your help ![]()
-Chris
