8bits greyscale

Oct 9, 2014 at 8:22 PM
Is there's any reason why you don't support 8bits greyscale video ? I know it is somehow exotic, but it would be useful for one of my use case.

Thanks for a nice library :)
Coordinator
Oct 12, 2014 at 4:04 PM
Hi
I was almost sure nobody uses bitmaps with palettes anymore :) And simply did not bother to support that. What's your case?
I think I'll have time to add this in late October - early November. If you cannot wait and want to make necessary changes yourself, I can provide you some directions.
Oct 14, 2014 at 12:38 PM
My case is this camera :

http://www.sentechamerica.com/cameras-cameralink/STC-CMB2MCL.aspx

It's outputing 2040*1088 8bits images at 340fps. I've been trying different things to save videos from it, within a existing .net app, but the best results I get is with your library :)

At the moment, I'm converting to 24bits to have readability everywhere. I'll try the 16bits version when I can, but so far I was unlucky with the other libraries I tried.

For a few seconds of video, it can save me a few GB :)

If I manage to deal with the other issues I have with this camera, I hope I can get to work on this at some point.

Maybe I'm not the only one in this situation, so it would be a good addition to SharpAvi.
Oct 15, 2014 at 8:40 PM
Edited Oct 15, 2014 at 8:57 PM
For uncompressed, it works with only adding in BitsPerPixel.cs / enum BitsPerPixel :
        /// <summary>8 bits per pixel.</summary>
        Bpp8 = 8,
What else would be needed to make it work with everything else ?
Coordinator
Oct 16, 2014 at 8:12 AM
Edited Oct 16, 2014 at 8:12 AM
thieum22 wrote:
For uncompressed, it works with only adding in BitsPerPixel.cs / enum BitsPerPixel :
Really? Great. I thought it is needed to write a grayscale palette to the stream header explicitly.

However, writing uncompressed 8-bit frames gives you only 3 times less file size than 24 bits. To get more considerable decrease in size, better use some real compression like M-JPEG or MPEG-4. AFAIK, all these compression algorithms need full-color bitmaps on input.

Have you tried to convert grayscale to 32 bits and then use bundled M-JPEG video encoder?
Oct 16, 2014 at 1:17 PM
baSSiLL wrote:
Really? Great. I thought it is needed to write a grayscale palette to the stream header explicitly
8bits seems to work without an explicit palette. On the other hand, 16bits grayscale is not supported by directshow natively, and would require more work based on the few tests I've been doing.
baSSiLL wrote:
However, writing uncompressed 8-bit frames gives you only 3 times less file size than 24 bits. To get more considerable decrease in size, better use some real compression like M-JPEG or MPEG-4. AFAIK, all these compression algorithms need full-color bitmaps on input.

Have you tried to convert grayscale to 32 bits and then use bundled M-JPEG video encoder?
My use case requires that I use a lossless format, and I'm not sure I can guarantee lossless with M-JPEG or MPEG-4.
Oct 16, 2014 at 1:27 PM
Oct 16, 2014 at 6:18 PM
I think you were right. The video is playable in vlc, but the avi doesn't seem to be well formed for other readers, and especially not the one I've coded. I'll do my research for the grayscale palette. But if you have any idea, it would be greatly appreciated :)
Oct 16, 2014 at 8:03 PM
I think I got the basic idea, in AviWriter / Write Stream Format :
            fileWriter.Write(256U); // palette colors used
            fileWriter.Write(256U); // palette colors important
            for (int i = 0; i < 256; i++)
            {
                fileWriter.Write(i);
                fileWriter.Write(i);
                fileWriter.Write(i);
            }
I'll work on a cleaner implementation considering the value of videoStream.BitsPerPixel.

based on https://github.com/umlaeute/Gem/blob/master/plugins/filmAVI/filmAVI.cpp
Oct 21, 2014 at 2:17 PM
see https://github.com/baSSiLL/SharpAvi/pull/2

it's a basic solution for 8bits greyscale. The idea can be extended to support other scenarii (16 bits greyscale, custom palettes), but I wanted the simplest solution first.