开发者

FFMPeg Windows C# H264

I am trying to use SharpFFMpeg

http://sourceforge.net/projects/sharpffmpeg/

I found avcodec-52.dll and avformat-52.dll somewhere on the Net...

When I use SharpFFMpeg and make calls like av_init_packet

I get PInvoke errors like so

PInvokeStackImbalance was detected Message: A call to PInvoke function 'WpfApplicationFFMpegTest!FFmpegSharp.Interop.FFmpeg::av_init_packet' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Che开发者_StackOverflow中文版ck that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

In a nutshell I am trying to decode H264 and display the incoming stream from a camera...

Just wondering if anyone has been able to do this succesfully in C#?

Thanks


What Benjamin wants to say is that you should try to open the SharpFFmpeg sources and change inside AVFormat.cs the lines

[DllImport("avformat.dll"), SuppressUnmanagedCodeSecurity]
public static extern void av_init_packet(IntPtr pAVPacket);

into

[DllImport("avformat.dll", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static extern void av_init_packet(IntPtr pAVPacket);

and recompile the SharpFFmpeg project. I didn't test that, since I haven't the DLLs.

When this helps (av_init_packet disappears in the exception message), try to add CallingConvention.Cdecl on every PInvoke method.


Sounds like invoke is trying to use the wrong calling convention. Needs to use __stdcall or __cdecl should work.


Depending on whether your OS is 64 or 32 bit, you'll need to ensure that the stack is aligned to sufficiently large byte amounts to make this work.

On my 64bit Windows 7 computer, I can only use FFMpeg libraries in 64bit applications, which ensures the stack stays aligned to 16byte increments, resolving many of those problems.

I'm not sure how to solve your particular problem, but I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜