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 bc6f684 commit 894fcaf
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# H264Sharp
Cisco's OpenH264 C++/CLI wrapper in C# comes with optimised image format conversion library.

- Compatible with OpenCV.
Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions.
- Tested on .NetFramework and Net6.
- Compatible with OpenCV.(i.e. OpenCVsharp)
- Tested on WPF application with camera and screen capture (P2P Videocall).
- Very Simple console application example is provided on repo.

Setup
### Setup
``` c#
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

### Encode
```C#
if(encoder.Encode(bitmap, out EncodedFrame[] frames))
{
Expand All @@ -26,23 +27,39 @@ Encode
}
}
```

Decode
- 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.
- Raw data is compatible with OpenCV Mats.
- EncodedFrame represents h264 encoded bytes(NALs etc).

### 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");
}
}
```
.Net Core and .Net Framework releases are provided.
Tested on .Net6 and .NetFramework 4.7.2.
- 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).
# Converter dll
A separate dll is provided for rgb <-> yub conversions. Its compiled with clang and has AVX2 Vectorsation.
You can optionally include it on your executable path just like Openh264 dll. If wrapper could not find the Converter32/64 dll it will fall back to use C++Cli versions.
External dll 2x faster than C++Cli convertors.

Reference the wrapper DLL on your project.
Make sure Cisco`s DLL is on your executable path.
# TLDR how to install
- Go to my releases find lates version.
- Reference/Include H264Sharp dll on your project.
- Add `openh264-2.3.1-win32.dll` or `openh264-2.3.1-win64.dll` or both to your executable directory. (keep the original names if you want to use default Ctor)
- Optionally Add Converter64/32 dlls to your executable directory.
# Remarks
.Net Core and .Net Framework releases are provided.
Use at least 2.3.1 version of openh264.

- Include Cisco's `openh264-2.1.1-win32` for 32 bit projects.
- include Cisco's `openh264-2.1.1-win64` for 64.
- Download Cisco's [`openh264-2.3.1-win32.dll`](http://ciscobinary.openh264.org/openh264-2.3.1-win32.dll.bz2)
- Download Cisco's [`openh264-2.3.1-win64.dll`](http://ciscobinary.openh264.org/openh264-2.3.1-win64.dll.bz2).

0 comments on commit 894fcaf

Please sign in to comment.