下面是我搭建FFmpeg学习环境的步骤。

一、在Ubuntu下

http://www.ffmpeg.org/download.html下载最新的FFmpeg版本,我的版本是ffmpeg-2.7.2。

编译:

tar -xf ffmpeg-2.7..tar.bz2
mkdir build
cd build/
../ffmpeg-2.7./configure --enable-shared
make
sudo make install

在build/config.mak中可以看到将动态库和静态库安装到什么位置了:

# Automatically generated by configure - do not modify!
ifndef FFMPEG_CONFIG_MAK
FFMPEG_CONFIG_MAK=
FFMPEG_CONFIGURATION= --enable-shared
prefix=/usr/local
LIBDIR=$(DESTDIR)${prefix}/lib
SHLIBDIR=$(DESTDIR)${prefix}/lib
INCDIR=$(DESTDIR)${prefix}/include
BINDIR=$(DESTDIR)${prefix}/bin
DATADIR=$(DESTDIR)${prefix}/share/ffmpeg
DOCDIR=$(DESTDIR)${prefix}/share/doc/ffmpeg
MANDIR=$(DESTDIR)${prefix}/share/man
PKGCONFIGDIR=$(DESTDIR)${prefix}/lib/pkgconfig
SRC_PATH=/home/pengdl/work/study/FFmpeg/ffmpeg-2.7.
... ...

可以看到,拷贝到了/usr/local/lib下。

ls /usr/local/lib
icu libavdevice.a libavfilter.so. libavutil.a libswresample.so. ocaml tmp
lib64OpenglRender.so libavdevice.so libavfilter.so.5.16. libavutil.so libswresample.so.1.2. openssl
libavcodec.a libavdevice.so. libavformat.a libavutil.so. libswscale.a p4v
libavcodec.so libavdevice.so.56.4. libavformat.so libavutil.so.54.27. libswscale.so pkgconfig
libavcodec.so. libavfilter.a libavformat.so. libswresample.a libswscale.so. python2.
libavcodec.so.56.41. libavfilter.so libavformat.so.56.36. libswresample.so libswscale.so.3.1. python3.

下面写个简单的测试程序,分别用静态库和动态库测试,二者的区别主要在Makefile上。

测试文件 demo.c

#include <stdio.h>
#include <libavcodec/avcodec.h> int main(int argc, const char *argv[])
{
printf("%s\n", avcodec_configuration());
return ;
}

1、动态库

Makefile的内容如下:

LIBS_DIR=-L/usr/local/lib

LIBS=-lavcodec
LIBS+=-lavfilter
LIBS+=-lavdevice
LIBS+=-lswresample
LIBS+=-lswscale
LIBS+=-lavformat
LIBS+=-lavutil INC=-I/usr/local/include
INC+=-I/usr/local/include/libavcodec
INC+=-I/usr/local/include/libavdevice
INC+=-I/usr/local/include/libavfilter
INC+=-I/usr/local/include/libavformat
INC+=-I/usr/local/include/libavutil
INC+=-I/usr/local/include/libswresample
INC+=-I/usr/local/include/libswscale demo:demo.o
gcc demo.o -o $@ $(LIBS_DIR) $(LIBS) demo.o:demo.c
gcc $(INC) -c $^ -o $@ clean:
rm demo

运行:

ls -lh demo
-rwxrwxr-x pengdl pengdl .5K 12月 : demo
./demo
--arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:11-1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --disable-avserver --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-swscale --enable-libcdio --enable-x11grab --enable-libx264 --enable-libxvid --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static

2、静态库

现将/usr/local/lib下的动态库移动到其他位置,Makefile的内容如下:

LIBS_DIR=-L/usr/local/lib

LIBS=-lavcodec
LIBS+=-lavfilter
LIBS+=-lavdevice
LIBS+=-lswresample
LIBS+=-lswscale
LIBS+=-lavformat
LIBS+=-lavutil LIBS+=-lpthread
LIBS+=-lm INC=-I/usr/local/include
INC+=-I/usr/local/include/libavcodec
INC+=-I/usr/local/include/libavdevice
INC+=-I/usr/local/include/libavfilter
INC+=-I/usr/local/include/libavformat
INC+=-I/usr/local/include/libavutil
INC+=-I/usr/local/include/libswresample
INC+=-I/usr/local/include/libswscale demo:demo.o
gcc demo.o -o $@ $(LIBS_DIR) $(LIBS) demo.o:demo.c
gcc $(INC) -c $^ -o $@ clean:
rm demo

注意,其中静态库的顺序如果排列有问题,会导致编译错误,如将libavutil放在libavcodec的前面,就会导致编译错误。

运行:

ls -lh demo
-rwxrwxr-x pengdl pengdl 3.8M 12月 : demo
pengdl@pengdl-HP:~/work/study/FFmpeg/FFmpeg/demo$ ./demo
--enable-shared

二、在wind7下

在win7下使用的开发工具VS2013,我的win7是64位的。

可以从http://ffmpeg.zeranoe.com/builds/下载需要的动态库和静态库,这里需要注意的是32位和64位要搞清楚。

1、32位

下载如果所示的两个,shared的下载包里有ffmpeg的动态库,dev的下载包里有静态库。

ffmpeg-20151231-git-4160900-win32-dev.7z

ffmpeg-20151231-git-4160900-win32-shared.7z

打开vs2013,新建一个控制台应用程序,将shared包里bin目录下的动态库拷贝到C:\Windows\system下,如下图:

将dev下的lib和include拷贝到工程目录下,如下图:

右击工程名,选择属性,作如下设置:

1. C/C++ --> 附加包含目录 ---> 设置为include 或者设置为include的绝对路径 E:\VC++\FFmpeg\testFFmpeg_32\testFFmpeg\include

2. 链接器 --> 常规 ---> 附加库目录 ---> 设置为lib 或者 设置为lib的绝对路径 E:\VC++\FFmpeg\testFFmpeg_32\testFFmpeg\lib

3. 链接器 --> 输入 ---> 附加依赖项 --->  设置为刚才添加的静态库

点击确定。

测试程序 testFFmpeg.cpp :

#include "stdafx.h"

//Windows
extern "C"
{
#include "libavcodec/avcodec.h"
}; int _tmain(int argc, _TCHAR* argv[])
{
printf("\n<<Configuration>>\n%s", avcodec_configuration()); return ;
}

运行

点击 调试 ---> 开始执行(不调试) 或者 Ctrl + F5

2、64位

下面是用到的两个下载包:

ffmpeg-20151231-git-4160900-win64-dev.7z

ffmpeg-20151231-git-4160900-win64-shared.7z

配置方法与32位类似,不同的是建立的工程需要是x64位的,同时再将用到的动态库拷贝到 C:\Windows\system 下。

完。

FFmpeg学习起步 —— 环境搭建的更多相关文章

  1. hive_学习_01_hive环境搭建(单机)

    一.前言 本文承接上一篇:hbase_学习_01_HBase环境搭建(单机),主要是搭建 hive 的单机环境 二.环境准备 1.说明 hive 的下载来源有: 官方版本:http://archive ...

  2. hbase_学习_01_HBase环境搭建(单机)

    一.前言 本文承接上一篇:hadoop_学习_02_Hadoop环境搭建(单机)  ,主要是搭建HBase的单机环境 二.环境准备 1.说明 hbase 的下载来源有: 官方版本:http://arc ...

  3. hadoop_学习_02_Hadoop环境搭建(单机)

    一.环境准备 1.说明 hadoop的下载来源有: 官方版本:http://archive.apache.org/dist/hadoop/ CDH版本:http://archive.cloudera. ...

  4. 从0开始学爬虫9之requests库的学习之环境搭建

    从0开始学爬虫9之requests库的学习之环境搭建 Requests库的环境搭建 环境:python2.7.9版本 参考文档:http://2.python-requests.org/zh_CN/l ...

  5. Ubuntu16.04深度学习基本环境搭建,tensorflow , keras , pytorch , cuda

    Ubuntu16.04深度学习基本环境搭建,tensorflow , keras , pytorch , cuda Ubuntu16.04安装 参考https://blog.csdn.net/flyy ...

  6. ubuntu 深度学习cuda环境搭建,docker-nvidia 2019-02

    ubuntu 深度学习cuda环境搭建 ubuntu系统版本 18.04 查看GPU型号(NVS 315 性能很差,比没有强) 首先最好有ssh服务,以下操作都是远程ssh执行 lspci | gre ...

  7. Python基础学习之环境搭建

    Python如今成为零基础编程爱好者的首选学习语言,这和Python语言自身的强大功能和简单易学是分不开的.今天我们将带领Python零基础的初学者完成入门的第一步——环境搭建.本文会先来区分几个在P ...

  8. 001-深度学习Pytorch环境搭建(Anaconda , PyCharm导入)

    001-深度学习Pytorch环境搭建(Anaconda , PyCharm导入) 在开始搭建之前我们先说一下本次主要安装的东西有哪些. anaconda 3:第三方包管理软件. 这个玩意可以看作是一 ...

  9. 人工智能之深度学习-初始环境搭建(安装Anaconda3和TensorFlow2步骤详解)

    前言: 本篇文章主要讲解的是在学习人工智能之深度学习时所学到的知识和需要的环境配置(安装Anaconda3和TensorFlow2步骤详解),以及个人的心得体会,汇集成本篇文章,作为自己深度学习的总结 ...

随机推荐

  1. 2017南宁现场赛E The Champion

    Bob is attending a chess competition. Now the competition is in the knockout phase. There are 2^r2r  ...

  2. shell 灵活设置定时任务

    #!/bin/bash step=30 #间隔的秒数,不能大于60 for (( i = 0; i < 60; i=(i+step) )); do curl #调用链接 sleep $step ...

  3. Spring - IoC(1): Spring 容器

    BeanFactory & ApplicationContext org.springframework.beans.factory.BeanFactory 是最基本的 Spring 容器接口 ...

  4. arm SecurCore 处理器【转】

    转自:http://www.arm.com/zh/products/processors/securcore/index.php SecurCore 处理器 (View Larger SecurCor ...

  5. JS计算两个日期之间的天数

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 【 APACHE 】 Apache2.4.x版本虚拟主机配置

    今天准备使用apache搭建一个目录浏览的服务,折腾了一下. apache2.4.x以后的版本: Require all granted 代替了apache2.4.x以前版本: Order Allow ...

  7. k8s的Health Check(健康检查)

    强大的自愈能力是 Kubernetes 这类容器编排引擎的一个重要特性.自愈的默认实现方式是自动重启发生故障的容器.除此之外,用户还可以利用 Liveness 和 Readiness 探测机制设置更精 ...

  8. Verilog的IDE Quartus II

    Quartus II  主要用于Verilog的开发,他是开发FPGA的利器,但他需要和modelsim相互配合,才能实现它的编写和仿真.modelsim是第三方的EDA,需要另外安装,对于Quart ...

  9. 51nod 1344 走格子【贪心/前缀和】

    1344 走格子 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 有编号1-n的n个格子,机器人从1号格子顺序向后走,一直走到n号格子,并需要从n号格 ...

  10. hdu6191(树上启发式合并)

    hdu6191 题意 给你一棵带点权的树,每次查询 \(u\) 和 \(x\) ,求以 \(u\) 为根结点的子树上的结点与 \(x\) 异或后最大的结果. 分析 看到子树,直接上树上启发式合并,看到 ...