Using OpenH264 DLL in C# Project - c#

I'm receiving an H264 stream over UDP. I'd like to decode the stream so I can send frames to OpenCV or whatever. I came across Cisco's open sourced H264 decoder here: https://github.com/cisco/openh264
With a little effort I got the decoder solution to build in Visual Studio 2019 and tested it from the command line with a file I created from the raw UDP datagrams. It works.
Now I want to figure out how to use the decoder DLL (welsdec.dll) in a C# project. The last time I did anything serious with C++ in Windows was back in the DirectShow and Delphi 5 days, so I'm completely lost.
Nothing in the H264 project is explicitly exported with __declspec(dllexport). Is that normal? Adding the DLL as a project reference to the C# project doesn't work ("the reference is invalid or unsupported").
I'm guessing the DLL is unmanaged. Can I consume that directly in C#? Am I going to have to rewrite the DLL as, or maybe or wrap it, in a C++ CX library to get this working?

You can consume an unmanaged DLL in C# explicitly using PInvoke.
You can also write an intermediary DLL in C++/CLI to ease the invocations between your managed C# application and the native DLL. This is the approach taken by secile/OpenH264Lib.NET per stuartd's comment.
It looks like the H264 project uses module definition files (.def) in lieu of decorating exports with declspec. You should still be able to access these publicly exported functions using the above methods.

Related

Merge Audio and Video on Uno Platform

I am trying to merge an audio stream and a video stream into a single file, on the Uno Platform, particularly for WebAssembly.
I already know that the normal, desktop-only way is by calling ffmpeg, and I also found a C# only way for UWP here.
However, the code used Windows.Media.Editing which is not implemented in Uno.
I know there is a ffmpeg library port for WASM here, but I don't know how to call it from my Uno web application.
So are there any ways to merge an audio stream and a video stream to a single file, on the Uno platform for WASM?
Unfortunately, this API is not yet implemented in Uno Platform, so in this case you need to write platform-specific implementation.
If you have a JavaScript library available, which can provide the functionality you need, you can still call it from the C# code. There is a three-part tutorial in the Uno Platform docs on implementing C# - JS interop, so that may be helpful to get started.
Alternatively, in case you find an alternative implementation in C# on NuGet, you can install it for the supported platforms and use it in your code as well. To write platform-specific code, you can use #if conditionals like #if __WASM__ etc. - for full information see this documentation page.

How to access Image sequence in a HEIC file ( using C#)?

I want to access Image sequence contained in a Heic Container using C#.
In windows 10, the HEIF Image Extensions enables reading (HEIF) files. It is supposed to be extended to WIC to be used by developers if the previously mentioned extension is installed on the device.
Other libraries I found about this topic:
- Magick.NET Can only handle a Single image in a HEIC Container.
- HEIF-Utility-Native-DLL and HEIF.NET Have the same issue as the one before.
- libheif is a C++ Library. I don't know how to use PInvoke even tho i have been trying extensively to understand how it works (I cant read C++)
How can I use my code to check if the extension is Installed?
How can I use C# to access Image sequence from a HEIC container?
And how can I do the reverce by packing Image sequences into a Heic Container?
As an alternative, how could I port this JavaScript to C#, or use it with C# in a project to access Images?

Issues extracting Digital Multimeter Data readings from interface library via Python

Being a novice in Python and C#, and having reached a point with no significant progress, I'd like to ask for some suggestions.
Here is the issue I find:
I am trying to read the data from a Digital Multimeter through its C# library and targeting to export it into Python (being the only supported language of the target application).
The meter and communication interface libraries come from Lcrrsearch.
Referring to the instructions provided, I have run the C# project file and have succeeded in getting the readings (through FTD2XX_NET.dll, LCR_CIL.dll).
However, separately, when trying to use the .dll files in Python, I have failed to do so.
The solution paths I sought after were:
Calling the LCR_CIL.dll in Python via Ctypes
Trying IronPython via Visual Studio for .NET
Using FTDI library to read the data from memory
Therefore, I would like to have some hints or ideas as to which path is the most straightforward one to import the data in Python and/or any similar example you could propose I would gladly welcome.

Is there a .NET library to Normalize PCM WAV

I want to normalize PCM WAV files from client side(Silverlight). I am using ASP.NET MVC on the server side. And I found a C program here
https://neon1.net/prog/normalizer.html
Does anyone know that if there are similar C# libraries that I can use directly?
"Normalizing" audio files is generally not a great idea, since if there is just one sample at full volume, then it will have no effect. A better approach would be to run a dynamic range compressor on the audio.
In Skype Voice Changer I have written sample code that uses NAudio and passes audio through dynamic range compressors. However, as others have said, NAudio isn't directly usable in Silverlight due to interop. But you should be able to copy WaveFileReader, WaveFormat and WaveFileWriter out and compile them without needing to make too many code changes. Also, you won't be able to use the WaveBuffer mechanism for casting between arrays of bytes and shorts/floats, so you need to do the conversion the slow way (e.g. using BitConverter).
Some ideas (aside of trying NAudio or Bass.NET)
Call the compiled c executable
Compile it as a dll and use P/Invoke
Convert the C code to c#

Real-time wmv video encoding in C#

How to encode video on the fly and send it trough the network from C#?
Can't find a suitable library. I need to encode in WMV and don't mind if the actual encoding is made in C++ as long as the library has a .NET assembly available.
Thanks
I'm aware of ffmpeg, but it is native C code only. If you're ok with interoperability this may be your ticket.
Edit: It turns out someone already wrapped this in a .NET assembly. It's called FFlib.NET.
I use the Windows Media Format SDK, although I admit I use it directly in C++ native code. I believe it can be called from managed code.
This is now included as part of the Windows SDK here:
http://msdn.microsoft.com/en-us/windows/bb190307.aspx
(or you can download it separately - see the list in the left-hand panel)
Be warned, it is a fair bit to get your head around. However, there are sample code resources which should assist.
Depending on what you are encoding (size, framerate, hardware, etc) real-time encoding may not even be possible. Video encoding is VERY CPU intensive.

Categories

Resources