framework icon indicating copy to clipboard operation
framework copied to clipboard

How to record 16-bit grayscale video?

Open mpalladinru opened this issue 8 years ago • 0 comments

  • [X] question
  • [x] bug report
  • [X] feature request

How to record 16-bit grayscale video Hello. I have an scientific camera which output raw 16-bit grayscaled images and I want to record them. Is there a way to record a video in 16-bit grayscale format? Losless or lossy (I can compensate it with high bitrate). I tried many combinations of formats and codecs, closest thing I can get to work is:

static void Main(string[] args)
{
	var b=new Bitmap(640,480,System.Drawing.Imaging.PixelFormat.Format16bppGrayScale);
	VideoFileWriter fw=new VideoFileWriter() { FrameRate=25, BitRate=1024, PixelFormat=AVPixelFormat.
		FormatGrayscale16bppBigEndian
		, Width=640, Height=480, 
		VideoCodec=VideoCodec.Apng, 
		AudioCodec=AudioCodec.None };
	fw.Open("d:\\accordtest.avi");
	fw.WriteVideoFrame(b);
	fw.Close();
}

It gaves me:

Output #0, avi, to 'd:\accordtest.avi': Metadata: ISFT : Lavf57.56.100 Stream #0:0: Video: apng, 1 reference frame, gray16be, 640x480 (0x0), q=2-31, 1 kb/s, 25 tbn VideoStream->time_base: 1/25

Unhandled Exception: System.ArgumentException: The provided bitmap must be 32 bpp color or 8 bpp grayscale image. at Accord.Video.FFMPEG.VideoFileWriter.WriteVideoFrame(BitmapData frame, TimeSpan timestamp) at Accord.Video.FFMPEG.VideoFileWriter.WriteVideoFrame(Bitmap frame) at ConsoleApp1.Program.Main(String[] args) in G:\Docs\AccordVideoTest\ConsoleApp1\Program.cs:line 24

From #762 I understand that such limit was set intentionally? I recompiled Accord.Video.FFMPEG and commented out that check at line 736 in file VideoFileWrite.cpp, but still got an error somewhere at another library.

mpalladinru avatar Sep 07 '18 11:09 mpalladinru