How to write image to ffmpeg with multi thread

Viewed 33

I'was trying to encode video from opencvSharp mat to ffmpeg. Now,It's.done. But,It has low speed encoding problem.

for (int  StartFrame = 0; StartFrame < EndFrame; StartFrame ++)
{                  
    using (var ms = new MemoryStream())
    {     
        //read mat from videocapture
        Mat mat =CreateRenderingMat(StartFrame)
        BitmapConverter.ToBitmap(mat).Save(ms, ImageFormat.Bmp);
        ms.WriteTo(proc.StandardInput.BaseStream);
        Cv2.WaitKey();
        mat.Dispose();
        ms.Dispose();
        ms.Close();
        Debug.WriteLine(movePos.ToString());
     }
 }

Now, I wanna manage it with multi threading. But,I don't make sence. Tell me some advice. Thank you.

0 Answers
Related