FFmpeg菜鸡互啄#第2篇#配置VS开发环境

下载FFmpeg

首先是下载FFmpeg的win32库,我用的版本是2.5.2(和其他2.x.x版本应该不会有太大差别)。FFmpeg的官网上好像已经找不到旧版本的下载了,可以在我的代码地址下载2.5.2版本。

创建工程

打开Visual Studio 2013,创建一个空的控制台项目。
这里写图片描述

配置FFmpeg目录

在上面一步创建的工程目录下,创建一个FFmpeg文件夹。FFmpeg文件夹下新建inc和lib目录。把ffmpeg-2.5.2-win32-dev.7z压缩包里的include文件夹的所有内容复制到FFmpeg\inc目录下,ffmpeg-2.5.2-win32-dev.7z压缩包里的lib文件夹的所有.lib文件复制到FFmpeg\lib目录下。
这里写图片描述
在项目属性里设置输出路径..\bin。并在工程文件夹里新建一个bin文件夹,把ffmpeg-2.5.2-win32-shared.7z压缩包里的bin文件夹的所有.dll文件复制到bin目录下。
这里写图片描述
附加包含目录添加..\FFmpeg\inc(从ffmpeg-2.5.2-win32-dev.7z里复制include文件夹的路径)。
这里写图片描述
附加库目录添加..\FFmpeg\lib(从ffmpeg-2.5.2-win32-dev.7z里复制lib文件夹的路径)。
这里写图片描述

测试代码

向项目添加一个main.c源文件,并输入测试代码:

#include <stdio.h>

/*
#define __STDC_CONSTANT_MACROS
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
*/

extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavdevice/avdevice.h"
}

#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avdevice.lib")
#pragma comment(lib, "avfilter.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "postproc.lib")
#pragma comment(lib, "swresample.lib")
#pragma comment(lib, "swscale.lib")

int main()
{
    //初始化FFMPEG  调用了这个才能正常适用编码器和解码器
    av_register_all();
    printf("FFmpeg's version is: %d\n", avcodec_version());

    system("pause");
    return 0;
}

FFmpeg一共包含8个库:
▫ avcodec:编解码(最重要的库)。
▫ avformat:封装格式处理。
▫ avfilter:滤镜特效处理。
▫ avdevice:各种设备的输入输出。
▫ avutil:工具库(大部分库都需要这个库的支持)。
▫ postproc:后加工。
▫ swresample:音频采样数据格式转换。
▫ swscale:视频像素数据格式转换

#define __STDC_CONSTANT_MACROS
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif

之前遇到过在Qt或者VS2008里要添加上面这个被注释的宏定义,但是在VS2013的话却不需要。
测试结果:这里写图片描述

github

https://github.com/gongluck/FFmpegTest.git

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This is a FFmpeg Win64 shared build by Kyle Schwarz. Zeranoe&#39;s FFmpeg Builds Home Page: This build was compiled on: Dec 30 2014, at: 17:29:04 FFmpeg version: 2.5.2 libavutil 54. 15.100 / 54. 15.100 libavcodec 56. 13.100 / 56. 13.100 libavformat 56. 15.102 / 56. 15.102 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 2.103 / 5. 2.103 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 This FFmpeg build was configured with: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib This build was compiled with the following external libraries: bzip2 1.0.6 Fontconfig 2.11.91 Frei0r 20130909-git-10d8360 GnuTLS 3.2.20 libiconv 1.14 libass 0.12.0 libbluray 0.6.2 libbs2b 3.1.0 libcaca 0.99.beta18 FreeType 2.5.4 Game Music Emu 0.6.0 GSM 1.0.13-4 iLBC 20141214-git-ef04ebe Modplug-XMMS 0.8.8.5 LAME 3.99.5 OpenCORE AMR 0.1.3 OpenJPEG 1.5.2 Opus 1.1 RTMPDump 20140707-git-a1900c3 Schroedinger 1.0.11 libsoxr 0.1.1 Speex 1.2rc2 Theora 1.1.1 TwoLAME 0.3.13 vid.stab 0.98 VisualOn AAC 0.1.3 VisualOn AMR-WB 0.1.2 Vorbis 1.3.4 vpx 1.3.0 WavPack 4.70.0 WebP 0.4.2 x264 20141220-git-40bb568 x265 1.4 XAVS svn-r55 Xvid 1.3.3 XZ Utils 5.2.0 zlib 1.2.8 The source code for this FFmpeg build can be found at: This build was compiled on Debian 8.0 (64-bit): GCC 4.9.2 was used to compile this FFmpeg build: This build was compiled using the MinGW-w64 toolchain: Licenses for each library can be found in the &#39;licenses&#39; folder.
配置Qt和FFmpeg开发环境,你需要按照以下步骤进行操作: 1. 下载和安装Qt:访问Qt官方网站(https://www.qt.io/)并下载适合你操作系统的Qt安装程序。安装过程中,选择包含Qt Creator的完整安装包,以便获取Qt的集成开发环境。 2. 下载FFmpeg:访问FFmpeg官方网站(https://ffmpeg.org/)并下载最新的稳定版本。解压缩下载的文件到你选择的目录。 3. 配置Qt Creator:打开Qt Creator,点击"工具"单,选择"选项"。在弹出的对话框中,选择"Kits"选项卡。点击"添加"按钮,选择你的编译器,并填写相关信息。然后点击"添加"按钮,选择你的Qt版本,并填写相关信息。点击"应用"和"确定"按钮保存设置。 4. 配置FFmpeg:打开Qt Creator,点击"文件"单,选择"新建文件或项目"。在弹出的对话框中,选择"C++库",然后点击"选择"按钮。在弹出的对话框中,选择"导入外部库"选项卡。点击"添加"按钮,选择FFmpeg库所在的目录,并填写相关信息。点击"下一步"按钮,选择需要导入的库,并填写相关信息。点击"完成"按钮完成配置。 5. 编写代码:在Qt Creator中创建一个新的Qt项目。在项目文件中,添加FFmpeg库的头文件和链接库。然后编写你的代码,使用FFmpeg提供的功能。 6. 构建和运行:点击Qt Creator工具栏上的"构建"按钮,编译你的项目。如果没有错误,点击"运行"按钮,运行你的项目。 希望以上步骤能帮助你成功配置Qt和FFmpeg开发环境。如果你有任何进一步的问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值