繁体   English   中英

需要帮助纠正使用FFmpeg DLL的访问冲突

[英]Need help correcting Access Violation with FFmpeg DLL

我正在尝试使用FFmpeg dll使用Visual Studio 2012,当我调用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会创建访问冲突。

最后,修复它。 我做了两个步骤,我不确定哪个工作(呵呵):

  1. 添加了“.lib”文件作为链接器输入依赖项
  2. 我选择了9月7日版本,并确保我拥有dll,库和包含文件的所有相同构建日期。

现在一切似乎都很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM