我刚刚下载了ffmpeg的开发包并设置了头文件和库以供使用。我正在使用Visual C++ 2013,并添加了ffmpeg头文件和库的路径。我链接了ffmpeg
以下是尝试构建时的输出:
这是我的代码:
我不知道我缺少什么。非常感谢任何帮助。谢谢。
lib
文件夹中的每个库文件,但显然没有一个匹配av_register_all
和avformat_open_input
。以下是尝试构建时的输出:
1>------ Build started: Project: ffmpeg_learning, Configuration: Debug Win32 ------
1> ffmpeg_learning.cpp
1>ffmpeg_learning.obj : error LNK2019: unresolved external symbol _av_register_all referenced in function _main
1>ffmpeg_learning.obj : error LNK2019: unresolved external symbol _avformat_open_input referenced in function _main
1>c:\users\edward severinsen\documents\visual studio 2013\Projects\ffmpeg_learning\Debug\ffmpeg_learning.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
这是我的代码:
#include "stdafx.h"
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "avdevice.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "avfilter.lib")
#pragma comment(lib, "postproc.lib")
#pragma comment(lib, "swresample.lib")
int main(int argc, char* argv[])
{
av_register_all();
AVFormatContext* pFormatCtx = NULL;
//Open video file
if (avformat_open_input(&pFormatCtx, argv[1], NULL, 0))
{
//Couldn't open the file
return -1;
}
return 0;
}
我不知道我缺少什么。非常感谢任何帮助。谢谢。
avformat-58.dll
以及其他依赖项没有包含在开发包中。所以我还必须下载共享包以获取额外的库。将这些库添加到程序的 bin 目录后,它开始正常工作。 - Edward Severinsen