将帧序列保存为BMP而不是PNG

时间:2013-12-25 13:36:39

标签: c# image video ffmpeg bmp

我从视频文件中提取100帧并将每个帧保存为(.bmp)但我发现每个帧格式都是PNG而不是BMP,如何保存帧序列(格式为BMP而不是PNG,如图所示)在C#?

string name;            
for ( int i = 0; i < 100; i++ )
{
    Bitmap videoFrame = video.ReadVideoFrame( );  
    name = (i).ToString().PadLeft(5, '0');
    videoFrame.Save(@"D:\frames\" + name  + ".bmp");
    videoFrame.Dispose( );
}

video.Close( );
MessageBox.Show(" Complete Convert video to sequence of image","Convert");

enter image description here

1 个答案:

答案 0 :(得分:4)

使用System.Drawing.Imaging.ImageFormat定义格式。

使用此:

videoFrame.Save(@"D:\frames\" + name  + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);

而不是:

videoFrame.Save(@"D:\frames\" + name  + ".bmp");