首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅在调试模式下的FFMPEG异常

仅在调试模式下的FFMPEG异常
EN

Stack Overflow用户
提问于 2015-09-28 09:20:38
回答 1查看 1K关注 0票数 1

所以我试图在c++中使用ffmpeg。我的代码是这样的:

代码语言:javascript
复制
#include <iostream>

extern "C"
{
#include "libavcodec\avcodec.h"
#include "libavformat\avformat.h"
#include "libswscale\swscale.h"

}

using namespace std;
#pragma comment(lib, "dev/lib/avcodec.lib")
#pragma comment(lib, "dev/lib/avformat.lib")
#pragma comment(lib, "dev/lib/swscale.lib")

int main()
{
    avcodec_register_all();
    av_register_all();
    char inputFile[] = "video.mp4";
    AVFormatContext *pFormatCtx;

    if (avformat_open_input(&pFormatCtx, inputFile, NULL, 0) != 0) // exception occurs here
    {
        cout << "could not open file"; 
        return -1;
    }

}

此代码在发布模式下运行,但在调试模式下,我在avformat_open_input获得异常。

ingrain.exe: 0xC0000005:访问冲突读取位置0xFFFFFFFFFFFFFFFFFF中0x000000000074BC3C35 (avformat-55.dll)处的未处理异常。

我直接从ffmpeg的网站下载了dll和lib,并将它们包含在我的visual studio 2012项目中。

谢谢已经提前了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-28 09:40:33

文档

代码语言:javascript
复制
int avformat_open_input ( AVFormatContext ** ps,
                          const char * filename,
                          AVInputFormat * fmt,
                          AVDictionary ** options 
                        )   

参数 ps:指向用户提供的AVFormatContext的指针(由avformat_alloc_context分配)。可能是指向NULL的指针,在这种情况下,AVFormatContext由该函数分配并写入ps。请注意,用户提供的AVFormatContext将在失败时释放.

您还没有初始化pFormatCtx,或者用avformat_alloc_context分配它,或者将它设置为由avformat_open_input自动分配给nullptr

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32819508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档