官网:https://ffmpeg.zeranoe.com/builds/
包含三个版本: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文件
一般我们用到的是Shared(*.dll)和Dev(*.lib;*.h)。
1、打开 Visual Studio 2013,新建项目,选择 Visual C++ 中的 Win32 控制台应用程序,确定,完成。
2、进入 FFmpeg 源码文件夹下的 doc/examples 文件夹,找到 metadata.c 文件,该文件是一个独立 demo,运行结果为打印音视频媒体文件基本信息。打开将其中的内容复制并粘贴到 ffmpeg-test.cpp 中,稍微修改如下。
3、在 Visual Studio 中的项目名上右击,打开属性,分别设置 配置属性 -> C/C++ -> 附加包含目录 和 配置属性 -> 链接器 -> 附加库目录 为第二步解压好的 32-bit Dev 文件夹下的 include 文件夹和 lib 文件夹,同时在 配置属性 -> 链接器 -> 输入 -> 附加依赖项 添加 avformat.lib 和 avutil.lib。
4、再将第二步解压的 32-bit Shared 文件夹下的 bin 文件夹中的 avcodec-56.dll、avformat-56.dll、avutil-54.dll 和 swresample-1.dll 拷贝到与解决方案同名的项目文件夹中。最终的文件结构如下图。
在VS2013环境下编译出现:
这是由于该函数被标记为attribute_deprecated,意味着该函数在不久的将来会被淘汰。
解决:1、将SDL检查关闭(暂时的方法)
2、更改为新的函数(参考ffplay.c)
5、编译执行成功得到结果如下。
命令行下编译:
E:MyDocumentDesktopFFmpeg>tree /F 文件夹 PATH 列表 卷序列号为 32D1-7CF3 E:. │ avcodec-55.dll │ avcodec.lib │ avdevice-55.dll │ avdevice.lib │ avfilter-4.dll │ avfilter.lib │ avformat-55.dll │ avformat.lib │ avutil-52.dll │ avutil.lib │ ffmpeg.cpp │ ffmpeg.exe │ ffmpeg.obj │ inttypes.h │ postproc-52.dll │ postproc.lib │ stdint.h │ swresample-0.dll │ swresample.lib │ swscale-2.dll │ swscale.lib │ _mingw.h │ ├─libavcodec │ avcodec.h │ avfft.h │ dxva2.h │ old_codec_ids.h │ vaapi.h │ vda.h │ vdpau.h │ version.h │ xvmc.h │ ├─libavdevice │ avdevice.h │ version.h │ ├─libavfilter │ asrc_abuffer.h │ avcodec.h │ avfilter.h │ avfiltergraph.h │ buffersink.h │ buffersrc.h │ version.h │ ├─libavformat │ avformat.h │ avio.h │ version.h │ ├─libavutil │ adler32.h │ aes.h │ attributes.h │ audioconvert.h │ audio_fifo.h │ avassert.h │ avconfig.h │ avstring.h │ avutil.h │ base64.h │ blowfish.h │ bprint.h │ bswap.h │ buffer.h │ channel_layout.h │ common.h │ cpu.h │ crc.h │ dict.h │ downmix_info.h │ error.h │ eval.h │ ffversion.h │ fifo.h │ file.h │ frame.h │ hmac.h │ imgutils.h │ intfloat.h │ intfloat_readwrite.h │ intreadwrite.h │ lfg.h │ log.h │ lzo.h │ macros.h │ mathematics.h │ md5.h │ mem.h │ murmur3.h │ old_pix_fmts.h │ opt.h │ parseutils.h │ pixdesc.h │ pixfmt.h │ random_seed.h │ rational.h │ replaygain.h │ ripemd.h │ samplefmt.h │ sha.h │ sha512.h │ stereo3d.h │ time.h │ timecode.h │ timestamp.h │ version.h │ xtea.h │ ├─libpostproc │ postprocess.h │ version.h │ ├─libswresample │ swresample.h │ version.h │ └─libswscale swscale.h version.h E:MyDocumentDesktopFFmpeg> |