I'm developing an application for real time streaming. capture frames from video devices and encoding with a ffmpeg wrapper called nreco.
the problerm is that if i try to stream encoded video to red5 via rtmp on red5 server, connection is immediatily closed.
this is the code i use to configure the output streaming:
ffMpegTask = videoConv.ConvertLiveMedia(
Format.raw_video,
outstream,
Format.flv,
new ConvertSettings()
{
CustomInputArgs = " -re -pix_fmt bgr24 -video_size 800x600 ",
CustomOutputArgs = " -acodec copy -vcodec libx264 -pix_fmt yuv420p rtmp://127.0.0.1/live/stream ",
});
ffMpegTask.Start();
adding frame this way:
void camera_Frame(object sender, FrameEventArgs e)
{
Bitmap item = e.Frame;
BitmapData bd = item.LockBits(new Rectangle(0, 0, item.Width, item.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
byte[] buf = new byte[bd.Stride * item.Height];
Marshal.Copy(bd.Scan0, buf, 0, buf.Length);
ffMpegTask.Write(buf, 0, buf.Length);
item.UnlockBits(bd);
}
any help?