ffmpeg开发环境搭建

  VS2013+ffmpeg开发环境搭建。

下载

  https://ffmpeg.zeranoe.com/builds/

  • Static版本包含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文件。

这里选择下载Shared版本和Dev版本。(ffmpeg.exe 、ffplay.exe 、ffprobe.exe可以直接通过命令行运行使用)

或者直接下载我打包好的环境配置文件: http://download.csdn.net/download/hubojing/10254452 (csdn现在没免费的了,就勾了最低的2分)

配置

  1. 将dev版本文件夹中的Include和lib目录复制到所需工程项目目录下,并在工程属性中设置附加包含目录$(ProjectDir)\include和附加库目录$(ProjectDir)\lib
  2. 将share版本文件夹中bin目录下对应的所有dll复制到项目路径下。
  3. 附加依赖项填入(根据所需) avcodec.lib avdevice.lib avfilter.lib avformat.lib avutil.lib postproc.lib swresample.lib swscale.lib

  由于ffmpeg是C语言所写,include头文件时需使用extern “C"标明。

测试

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
extern "C"
{
#include <libavformat/avformat.h>
#include <libavutil/dict.h>
};

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]);
		system("pause");
		return 1;
	}

	if ((ret = avformat_open_input(&fmt_ctx, argv[1], 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);
}

测试结果: test

至此,开发环境已就位。

参考:vs2013+ffmpeg开发环境搭建

资料:FFMPEG视音频编解码零基础学习方法 ffmpeg官方文档

Licensed under CC BY-NC-SA 4.0
最后更新于 0001-01-01 00:00 UTC
使用 Hugo 构建
主题 StackJimmy 设计