FFMPEG异常仅在调试模式下
FFMPEG exception in debug mode only
所以我试图在c++中使用ffmpeg。我的代码是这样的:
#include <iostream>
extern "C"
{
#include "libavcodecavcodec.h"
#include "libavformatavformat.h"
#include "libswscaleswscale.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
处得到异常:
在0x0000000074BC3C35 (avformat-55.dll)中未处理的异常0xC0000005:访问冲突读取位置0 xffffffffffffffff。
我直接从ffmpeg的网站下载了dll和lib,并将它们包含在我的visual studio 2012的项目中。
提前感谢。
阅读文档。
int avformat_open_input ( AVFormatContext ** ps,
const char * filename,
AVInputFormat * fmt,
AVDictionary ** options
)
参数
ps
:指向用户提供的AVFormatContext的指针(由avformat_alloc_context
)。可能是指向NULL
的指针,在这种情况下anAVFormatContext
由该函数分配并写入ps
。注意,用户提供的AVFormatContext
将在失败时被释放。
您还没有初始化pFormatCtx
,要么用avformat_alloc_context
分配它,要么设置为nullptr
,由avformat_open_input
自动分配它。
相关文章:
- 为什么使用__LINE_的代码在发布模式下在MSVC下编译,而不是在调试模式下
- 小字符串优化(调试与发布模式)
- 在调试模式下引发C++ "deque iterator not dereferencable"异常
- _mm256_load_ps调试模式下导致谷歌/基准测试的分段错误
- Visual Studio 发布模式阻止在调试模式下执行的代码.使用 WinHTTP 和多线程
- 自定义内存管理器在发布模式下工作正常,但在调试模式下则不然
- 使用Qt Creator在调试模式下编译一段代码
- 在调试模式下,所有程序都运行良好,但在发布模式下,我在cudaMalloc操作中出错
- 在类声明中初始化 const 成员变量时在调试模式下出现异常
- 在调试模式下编译时qrc_resource.cpp错误
- 如何在调试模式下通过终端运行可执行的 c++?
- 在Visual Studio 2017上无法使用调试模式x64进行OpenCV3.2编译
- 在调试模式下使用英特尔 TBB
- 我的代码在发布模式下不起作用,而在Qt的调试模式下工作
- SCANF 在 Eclipse 中不接受调试模式下的输入?
- 为什么我的 UWP 游戏在发布时比在调试模式下慢
- 在发布模式下崩溃,但如果可调试为 true - 不是..什么是可能的问题
- Visual Studio混合模式调试是否可以附加到Jupyter笔记本以同时调试C++和Python
- Windows 用户模式调试器传输 Visual Studio 2012
- VS2010 中使用 .NET 3.5 的混合模式调试