Visual Studio 2012 を使用して FFmpeg dll を使用しようとしていますが、 を呼び出すとランタイム アクセス違反が発生しますavcodec_find_encoder
。コードは次のとおりです。
// TestFFmpeg.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
extern "C" {
#include "libavcodec\avcodec.h"
#include "libavformat\avformat.h"
}
#define INBUF_SIZE 4096
int _tmain(int argc, _TCHAR* argv[])
{
AVCodec *codec;
const char *videoFilename = "C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv";
av_register_all(); // This works; however, no parameters or return values.
codec = avcodec_find_encoder(CODEC_ID_WMV3); // Run time Access Violation HERE
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
return 0;
}
エラーメッセージは次のとおりです。
TestFFmpeg.exe の 0x75C18B60 (msvcrt.dll) で未処理の例外: 0xC0000005: アクセス違反の読み取り場所 0x00000049。
スタック トレースは次のとおりです。
msvcrt.dll!_strcmp() Unknown
avcodec-54.dll!6a56caac() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for avcodec-54.dll]
> TestFFmpeg.exe!wmain(int argc, wchar_t * * argv) Line 23 C++
TestFFmpeg.exe!__tmainCRTStartup() Line 533 C
TestFFmpeg.exe!wmainCRTStartup() Line 377 C
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!___RtlUserThreadStart@8() Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown
ポインターを返すことに問題があるcodec
と思いますが、私は C++ が初めてで、それを修正する方法がわかりません。cdecl、stdcall、および fastcall 呼び出し規約を試してみましたが、問題は解決しませんでした。Zeranoe の最新の 32 ビット DLL を使用しています。助言がありますか?
編集:DLLで他の関数を呼び出しましたが、それらは機能します。たとえば、avformat_open_input
正常に動作します。パラメーターを渡すことができ、関数は正常な戻り値 (0) を返し、フォーマット コンテキスト構造を設定します。 av_find_stream_info
同様に動作します。avcodec_find_decoder
アクセス違反が発生する理由はまだわかりません。