diff --git a/README.md b/README.md index b410890..3c0ea5b 100644 --- a/README.md +++ b/README.md @@ -7,25 +7,25 @@ Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. ### Setup ``` c# - decoder = new H264Sharp.Decoder(); - - encoder = new H264Sharp.Encoder(); - encoder.Initialize(w, h, bps: 200_000_000, fps: 30, H264Sharp.Encoder.ConfigType.CameraBasic); + decoder = new H264Sharp.Decoder(); + + encoder = new H264Sharp.Encoder(); + encoder.Initialize(w, h, bps: 200_000_000, fps: 30, H264Sharp.Encoder.ConfigType.CameraBasic); ``` - Empty Constructor will look for 32 or 64 bit openh264 dll automatically on executable directory(i.e. Debug/Release folder of your project). - You can setup with a different dll name, constructor is overloaded. ### Encode ```C# - if(encoder.Encode(bitmap, out EncodedFrame[] frames)) - { - foreach (var frame in frames) - { - //byte[] b = frame.ToByteArray(); - //frame.CopyTo(buffer, 0); - Decode(frame.Data, frame.Length, frame.Type); - } - } + if(encoder.Encode(bitmap, out EncodedFrame[] frames)) + { + foreach (var frame in frames) + { + //byte[] b = frame.ToByteArray(); + //frame.CopyTo(buffer, 0); + Decode(frame.Data, frame.Length, frame.Type); + } + } ``` - You can encode rgb/rgba/bgr/bgra/yuv_i420 on as raw data format or System.Drawing.Bitmaps. - You have to determine startIndex, width height and stride values for your raw data images. @@ -34,16 +34,16 @@ Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. ### Decode ```C# - void Decode(IntPtr data, int length, FrameType type) - { - //if (decoder.Decode(data, length, noDelay:true, out DecodingState statusCode, out RgbImage rgb)) - //if (decoder.Decode(data, length, noDelay:true, out DecodingState statusCode, out Yuv420p yuv420)) - if (decoder.Decode(data, length, noDelay:true, out DecodingState statusCode, out Bitmap bmp)) - { - // Do stuff.. - // bmp.Save("t.bmp"); - } - } + void Decode(IntPtr data, int length, FrameType type) + { + //if (decoder.Decode(data, length, noDelay:true, out DecodingState statusCode, out RgbImage rgb)) + //if (decoder.Decode(data, length, noDelay:true, out DecodingState statusCode, out Yuv420p yuv420)) + if (decoder.Decode(data, length, noDelay:true, out DecodingState statusCode, out Bitmap bmp)) + { + // Do stuff.. + // bmp.Save("t.bmp"); + } + } ``` - You can decode with pointers or managed byte array as input. - You can decode into System.Drawing.Bitmaps or raw data format images (they are compatible with OpenCV Mats).