从流式图像创建视频c#

本文关键字:视频 创建 图像 | 更新日期: 2023-09-27 18:27:15

如何在C#中从流图像(只有没有声音的图像)构建视频?

以下是我的应用程序的一些代码:

static int ii = 1;
public void drawBitmap(byte[] data)
{
    MemoryStream ms = new MemoryStream(data);
    try
    {
        Bitmap b = new Bitmap(ms);
        b.Save(@"c:'test'" + (ii++) + ".jpg");
        Image i = (Image)b;
        pictureBox1.Image = i;
        ii++;
    }
    catch (Exception e)
    {
    }
}

从流式图像创建视频c#

我使用了上面提到的包装器,如下所示:

private static void hejHopp()
{
    //http://www.codeproject.com/Articles/7388/A-Simple-C-Wrapper-for-the-AviFile-Library
    //myReadyNAS device, got files via FTP from my webcam
    var jpgFileList = Directory.EnumerateFiles(sourcePath,"*.jpg");
    //load the first image
    Bitmap bitmap = (Bitmap)Image.FromFile(jpgFileList.First());
    //create a new AVI file
    AviManager aviManager = new AviManager(sourcePath + "''tada.avi", false);
    //add a new video stream and one frame to the new file
    //set IsCompressed = false
    VideoStream aviStream =  aviManager.AddVideoStream(false, 2, bitmap);
    jpgFileList.Skip(1).ToList().ForEach(file =>
    {
        bitmap = (Bitmap)Bitmap.FromFile(file);
        aviStream.AddFrame(bitmap);
        bitmap.Dispose();
    });
    aviManager.Close();
}

您可能想看看这个线程:

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/f23caf50-85a9-4074-8328-176c8bcc393e/

同样的问题。一些答案。

更多信息也可在此处获取:

http://www.codeproject.com/Articles/7388/A-Simple-C-Wrapper-for-the-AviFile-Library