I\'m currently looking to access libavutil, libavformat and libavcodec (all part of FFMpeg) from .NET.
Currently, I\'m getting the libraries from the automated build
SharpFFmpeg imports c++ libraries. C++ code is an unmanaged code. It needs pointers to the unmanaged memory. "Marshal" class provides some method to allocate unmanaged memory. For example:
IntPtr buffer = Marshal.AllocHGlobal(buf.Length + FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE); //buf is a byte array
Also, if you want to send a managed variable (any C# variable) to the function, you have to marshal (copy) this variable to the unmanaged memory.
for (int i = 0; i < buf.Length; i++)
Marshal.StructureToPtr(buf[i], buffer + i, true);
Now you can send a pointer to the function.
FFmpeg.avcodec_decode_video(codecContextUnmanaged, frame, ref success, buffer, buf.Length);
It's possible that you'll need to modify some unmanaged structures. To do this you have to copy structure to a managed memory (Marshal.PtrToStructure method), then modify it, and copy it to an unmanaged memory again.
I was tormented by the same problem a lot. I solved it, but I can't decode video anyway)) I hope my solution will help anybody.