I use Kinect SDK 2, C#. I want to save color stream with .AVI format. I get every frame and save them in .jpeg format with a serial number. I am not sure is it better to do it with .png or .jpeg. I need to turn these images into .AVI file in my code.
Here is how I save the images of the color stream. Could you please give me any advice about it?
private void Reader_ColorFrameArrived(object sender,
ColorFrameArrivedEventArgs e)
{
// ColorFrame is IDisposable
using (ColorFrame colorFrame = e.FrameReference.AcquireFrame())
{
if (colorFrame != null)
{
var bytesPerPixel = (PixelFormats.Bgr32.BitsPerPixel) / 8;
var stride = bytesPerPixel *
colorFrame.FrameDescription.Width;
if (colorRecord == 1)
{
colorFrame.CopyConvertedFrameDataToArray(colorData, format);
var fd = colorFrame.FrameDescription;
// Creating BitmapSource
bmpSource = BitmapSource.Create(fd.Width, fd.Height, 96.0, 96.0, PixelFormats.Bgr32, null, colorData, stride);
// WritableBitmap to show on UI
kinectImage.Source = bmpSource;
kinectImage.Source = colorBitmap;
// JpegBitmapEncoder to save BitmapSource to file
// imageSerial is the serial of the sequential image
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmpSource));
using (var fs = new FileStream("img" + (imageSerial++) + ".jpeg", FileMode.Create, FileAccess.Write))
{
encoder.Save(fs);
}
}
}
I found some info about ffmpeg on one of the posts but I couldn't understand how to use it in c#.