zl程序教程

您现在的位置是:首页 >  后端

当前栏目

VS2013+ffmpeg开发环境搭建

开发 环境 搭建 FFMPEG vs2013
2023-09-27 14:19:37 时间

VS2013+ffmpeg开发环境搭建

一、准备ffmpeg相对应开发dll、include、lib

包含三个版本:Static、Shared以及Dev

  • Static — 包含3个应用程序:ffmpeg.exe , ffplay.exe , ffprobe.exe,体积都很大,相关的DLL已经被编译到exe里面去了。
  • Shared — 除了ffmpeg.exe , ffplay.exe , ffprobe.exe之外还有一些DLL,exe体积很小,在运行时到相应的DLL中调用功能。
  • Dev — 开发者(developer)版本,里面包含了库文件xxx.lib以及头文件xxx.h,这个版本不含exe文件
    在这里插入图片描述

二、开发者版本配置相关环境

1.新建工程
在这里插入图片描述

2.把一中ffmpeg准备的dll、include、lib拷贝到工程目录下
在这里插入图片描述
3.右击工程“属性”
在这里插入图片描述
4.“C/C++”——>“附加包含目录”——>添加3中拷贝到工程“include”文件
在这里插入图片描述
注意:平台会默认选择win32,我们下载的是Windows 64-bit的ffmpeg,因此要把平台改成活动(x64)!

5.“链接器”——>“常规”——>附加库目录”——>添加3中拷贝到工程“lib”文件
在这里插入图片描述
6.“链接器”——>“输入”——>附加依赖项”——>添加“avcodec.lib;avformat.lib;avutil.lib;avdevice.lib;avfilter.lib;postproc.lib;swresample.lib;swscale.lib;”
在这里插入图片描述
7.将文件夹内的dll文件拷贝到ffavmuxer里
在这里插入图片描述
8.测试

#include "stdafx.h"
#include <stdio.h>
#include"stdlib.h"
//#include <rational.h>

extern "C"
{
#include <libavformat/avformat.h>
#include <libavutil/dict.h>
};
#pragma comment (lib,"avformat.lib")
#pragma comment (lib,"avutil.lib")

int main(int argc, char **argv)
{
	AVFormatContext *fmt_ctx = NULL;
	AVDictionaryEntry *tag = NULL;
	int ret;

	//if (argc != 2) {
	//	printf("usage: %s <input_file>\n"
	//		"example program to demonstrate the use of the libavformat metadata API.\n"
	//		"\n", argv[0]);
	//	return 1;
	//}

	if ((ret = avformat_open_input(&fmt_ctx, "la.mp3", NULL, NULL)))

	{
		
		return ret;
	}

	while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
		printf("%s=%s\n", tag->key, tag->value);

	avformat_close_input(&fmt_ctx);
	
	return 0;
}

在这里插入图片描述
运行成功!环境配置完成!如果还有其他问题,请留言。