我試圖將一個給定目錄中的所有PNG圖像轉換爲一個AVI文件,但我內存不足。目前我的目錄中沒有超過20張圖像,即4GB的內存。但我仍然收到這個錯誤。我錯過了什麼?將PNG圖像轉換爲視頻
這裏是我當前的代碼:
using (var writer = new VideoFileWriter())
{
writer.Open(Path.Combine(dest_path, "output.avi"), width, height, frameRate, VideoCodec.Raw);
foreach (string file in Directory.EnumerateFiles(dest_path))
{
var img = (Bitmap) Image.FromFile(file);
writer.WriteVideoFrame(img);
}
writer.Close();
}