Bitmap 通过rtmp的nreco包装位图流

Bitmap 通过rtmp的nreco包装位图流,bitmap,ffmpeg,Bitmap,Ffmpeg,我正在开发一个实时流媒体应用程序。 从视频设备捕获帧,并使用名为nreco的ffmpeg包装进行编码 问题是,如果我试图通过red5服务器上的rtmp将编码视频流传输到red5,连接会立即关闭 这是我用来配置输出流的代码: ffMpegTask = videoConv.ConvertLiveMedia( Format.raw_video, outstream, Format.flv, new ConvertSettings() {

我正在开发一个实时流媒体应用程序。 从视频设备捕获帧,并使用名为nreco的ffmpeg包装进行编码

问题是,如果我试图通过red5服务器上的rtmp将编码视频流传输到red5,连接会立即关闭

这是我用来配置输出流的代码:

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();
以这种方式添加框架:

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);
}  

有什么帮助吗?

如果需要对原始位图帧中的视频进行编码,并将结果提供给red5服务器,则应使用另一个ConvertLiveMedia重载(该重载接受基于字符串的标识符,而不是C#Stream):

ffMpegTask = videoConv.ConvertLiveMedia(
     null, // no input stream if data is provided with Write method
     Format.raw_video,
     "rtmp://127.0.0.1/live/stream",
     Format.flv,
     new ConvertSettings()
     {
         CustomInputArgs = " -re -pix_fmt bgr24 -video_size 800x600 ", 
         CustomOutputArgs = " -acodec copy -vcodec libx264 -pix_fmt yuv420p ",   
     });

      ffMpegTask.Start();