From 7fc27497f4ca292b5399c7d9ffb50587050dbb3c Mon Sep 17 00:00:00 2001 From: ReferenceType <109621184+ReferenceType@users.noreply.github.com> Date: Sun, 3 Sep 2023 14:51:17 +0200 Subject: [PATCH 1/3] Update README.md --- README.md | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0658ab8..8414f42 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,27 @@ # H264Sharp Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. It is very suitable for realtime streaming. -- Offers managed and unmanaged API. -- Tested on .NetFramework and Net6. +- Offers managed and unmanaged intuitive API. +- Tested on .NetFramework and NetCore(upto 7). - Compatible with OpenCV.(i.e. OpenCVsharp) - Tested on WPF application with camera and screen capture (P2P Videocall). +- No memory leaks or GC pressure with bitmaps. - Simple console application example is provided on repo as an example. ### Setup +- Empty Constructor will look for 32 or 64 bit openh264 dll with its default name automatically on executable directory(i.e. Debug/Release folder of your project). +- You can setup with a different dll name, constructor is overloaded. + ``` c# decoder = new H264Sharp.Decoder(); encoder = new H264Sharp.Encoder(); encoder.Initialize(width, height, bps: 3_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 +- You can encode from rgb/rgba/bgr/bgra/yuv_i420 on as raw data format, or System.Drawing.Bitmaps. +- Raw data is compatible with OpenCV Mats or any other standard image container. +- EncodedFrame represents h264 encoded bytes(NALs etc). ```C# if(encoder.Encode(bitmap, out EncodedFrame[] frames)) { @@ -28,12 +33,11 @@ Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. } } ``` -- 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 +- 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 and any other standard image containers.). ```C# void Decode(IntPtr data, int length, FrameType type) { @@ -46,14 +50,13 @@ Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. } } ``` -- 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 <-> YUV conversions. Its compiled with clang LLVM and has AVX2 intrinsics.
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. +
If wrapper cannot find the Converter32/64 dll it will fall back to use C++/Cli versions. +
External dll 2x+ faster than C++/Cli versions. # TLDR how to install - Go to my releases find lates version. @@ -61,8 +64,10 @@ A separate dll is provided for RGB <-> YUV conversions. Its compiled with clang - 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 constructor) - 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.(cisco has updated some data types, older versions might lead to stack buffer overflow). +- Decode callbacks with raw image formats use cached backed buffer, if you wont consume them immediately, make a copy or sync your system. +- Encoder output "EncodedFrame" uses cached back buffer if you wont consume them immediately, make a copy or sync your system. +- .Net Core and .Net Framework releases are provided. +- Use at least 2.3.1 version of openh264.(cisco has updated some data types, older versions might lead to stack buffer overflow). - 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). From 50acdd6ba76d52ab69a60f1162e0a1a45298b1a2 Mon Sep 17 00:00:00 2001 From: ReferenceType <109621184+ReferenceType@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:01:50 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8414f42..88fe593 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # H264Sharp -Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. It is very suitable for realtime streaming. +Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. It is very suitable for realtime streaming over network. - Offers managed and unmanaged intuitive API. - Tested on .NetFramework and NetCore(upto 7). - Compatible with OpenCV.(i.e. OpenCVsharp) @@ -8,9 +8,8 @@ Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. - Simple console application example is provided on repo as an example. ### Setup -- Empty Constructor will look for 32 or 64 bit openh264 dll with its default name automatically on executable directory(i.e. Debug/Release folder of your project). +- Default Constructor will look for `openh264-2.3.1-win32.dll` or `openh264-2.3.1-win64.dll` automatically on executable directory depending on process type. - You can setup with a different dll name, constructor is overloaded. - ``` c# decoder = new H264Sharp.Decoder(); @@ -27,6 +26,7 @@ Cisco's OpenH264 C++/CLI wrapper in C# with optimised image format conversions. { foreach (var frame in frames) { + //hints.. //byte[] b = frame.ToByteArray(); //frame.CopyTo(buffer, 0); Decode(frame.Data, frame.Length, frame.Type); @@ -60,9 +60,11 @@ A separate dll is provided for RGB <-> YUV conversions. Its compiled with clang # 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 constructor) -- Optionally Add Converter64/32 dlls to your executable directory. +- Reference 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(Or include on your project and ckeck copy to output-> copy if newer). +- Keep the original names if you want to use default constructors. +- Optionally Add Converter64/32 dlls to your executable directory same way as openh264 dll. +- # Remarks - Decode callbacks with raw image formats use cached backed buffer, if you wont consume them immediately, make a copy or sync your system. - Encoder output "EncodedFrame" uses cached back buffer if you wont consume them immediately, make a copy or sync your system. From b21493e256bcb3cbc8653bd92865a6c0eaf9c9b3 Mon Sep 17 00:00:00 2001 From: ReferenceType <109621184+ReferenceType@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:03:51 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88fe593..92bfcdc 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ A separate dll is provided for RGB <-> YUV conversions. Its compiled with clang - Add `openh264-2.3.1-win32.dll` or `openh264-2.3.1-win64.dll` or both to your executable directory(Or include on your project and ckeck copy to output-> copy if newer). - Keep the original names if you want to use default constructors. - Optionally Add Converter64/32 dlls to your executable directory same way as openh264 dll. -- +- Enjoy # Remarks - Decode callbacks with raw image formats use cached backed buffer, if you wont consume them immediately, make a copy or sync your system. - Encoder output "EncodedFrame" uses cached back buffer if you wont consume them immediately, make a copy or sync your system.