Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ReferenceType authored Sep 2, 2023
1 parent 894fcaf commit c8fcab7
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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).
Expand Down

0 comments on commit c8fcab7

Please sign in to comment.