I use ffmpeg.autogen for receiving a frame from a video and want to continue to keep this frame in the picture. But I only get a pointer to the frame, how can I save it using Magic.Net? Bitmap was overloading the receive pointer to raw.
Example with Bitmap:
ffmpeg.sws_scale(
this.pSwsContext,
(byte*[])this.pDecodedFrame->data,
(int[])this.pDecodedFrame->linesize,
0,
this.Height,
(byte*[])this.scaledData,
(int[])this.scaledLinesize);
var data = new byte_ptrArray8();
data.UpdateFrom(this.scaledData);
var linesize = new int_array8();
linesize.UpdateFrom(this.scaledLinesize);
var bitmapFrame = new Bitmap(this.Width, this.Height, linesize[0], PixelFormat.Format24bppRgb, (IntPtr)data[0]);
The API only supports managed types. And it looks like this.scaledData is a byte[]? Can you not pass that in instead?
I try copy and load that:
var length = sourceFrame.linesize[0] * sourceFrame.height;
var buff = new byte[length];
Marshal.Copy((IntPtr)data[0], buff, 0, length);
var i = new MagickImage(buff);
but catch next error:
ImageMagick.MagickMissingDelegateErrorException: no decode delegate for this image format `' @ error/blob.c/BlobToImage/458
at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result)
at ImageMagick.MagickImage.NativeMagickImage.ReadBlob(MagickSettings settings, Byte[] data, Int32 offset, Int32 length)
at ImageMagick.MagickImage.Read(Byte[] data, Int32 offset, Int32 length, MagickReadSettings readSettings, Boolean ping)
at ImageMagick.MagickImage.Read(Byte[] data, MagickReadSettings readSettings)
maybe I need to specify some settings?
I think you need to call the ReadPixels method of MagickImage instead.
And what I need to specify StorageType and Pixel Mapping?
Possible AVPixelFormat values in attached file, by Bitmap I set AV_PIX_FMT_BGR24.
AVPixelFormat.txt
The storage type should be Char and the pixel mapping BGR.
@dlemstra Thank you, again!