FFmpeg学习起步 —— 环境搭建
下面是我搭建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学习起步 —— 环境搭建的更多相关文章
- hive_学习_01_hive环境搭建(单机)
一.前言 本文承接上一篇:hbase_学习_01_HBase环境搭建(单机),主要是搭建 hive 的单机环境 二.环境准备 1.说明 hive 的下载来源有: 官方版本:http://archive ...
- hbase_学习_01_HBase环境搭建(单机)
一.前言 本文承接上一篇:hadoop_学习_02_Hadoop环境搭建(单机) ,主要是搭建HBase的单机环境 二.环境准备 1.说明 hbase 的下载来源有: 官方版本:http://arc ...
- hadoop_学习_02_Hadoop环境搭建(单机)
一.环境准备 1.说明 hadoop的下载来源有: 官方版本:http://archive.apache.org/dist/hadoop/ CDH版本:http://archive.cloudera. ...
- 从0开始学爬虫9之requests库的学习之环境搭建
从0开始学爬虫9之requests库的学习之环境搭建 Requests库的环境搭建 环境:python2.7.9版本 参考文档:http://2.python-requests.org/zh_CN/l ...
- Ubuntu16.04深度学习基本环境搭建,tensorflow , keras , pytorch , cuda
Ubuntu16.04深度学习基本环境搭建,tensorflow , keras , pytorch , cuda Ubuntu16.04安装 参考https://blog.csdn.net/flyy ...
- ubuntu 深度学习cuda环境搭建,docker-nvidia 2019-02
ubuntu 深度学习cuda环境搭建 ubuntu系统版本 18.04 查看GPU型号(NVS 315 性能很差,比没有强) 首先最好有ssh服务,以下操作都是远程ssh执行 lspci | gre ...
- Python基础学习之环境搭建
Python如今成为零基础编程爱好者的首选学习语言,这和Python语言自身的强大功能和简单易学是分不开的.今天我们将带领Python零基础的初学者完成入门的第一步——环境搭建.本文会先来区分几个在P ...
- 001-深度学习Pytorch环境搭建(Anaconda , PyCharm导入)
001-深度学习Pytorch环境搭建(Anaconda , PyCharm导入) 在开始搭建之前我们先说一下本次主要安装的东西有哪些. anaconda 3:第三方包管理软件. 这个玩意可以看作是一 ...
- 人工智能之深度学习-初始环境搭建(安装Anaconda3和TensorFlow2步骤详解)
前言: 本篇文章主要讲解的是在学习人工智能之深度学习时所学到的知识和需要的环境配置(安装Anaconda3和TensorFlow2步骤详解),以及个人的心得体会,汇集成本篇文章,作为自己深度学习的总结 ...
随机推荐
- 最短路径算法 SP
dijkstra求最短路径长度 dijkstra求最短路并记录路径 #include<stdio.h> #include<string.h> #include<stack ...
- shell正则表达式(1)
一.什么是正则 正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描述一类事物的规则. 二.grep 1.参数 -n :显示行号 -o : ...
- 【BZOJ4657】tower [网络流]
炮塔 Time Limit: 10 Sec Memory Limit: 256 MB Description Input Output 一行一个整数表示答案. Sample Input 4 5 0 ...
- 【BZOJ2049】【SDOI2008】洞穴勘测 [LCT]
洞穴勘测 Time Limit: 10 Sec Memory Limit: 259 MB[Submit][Status][Discuss] Description 辉辉热衷于洞穴勘测.某天,他按照地 ...
- 「6月雅礼集训 2017 Day1」说无可说
[题目大意] 给出n个字符串,求有多少组字符串之间编辑距离为1~8. n<=200,∑|S| <= 10^6 [题解] 首先找编辑距离有一个n^2的dp,由于发现只找小于等于8的,所以搜旁 ...
- [POJ2774]Long Long Message 解题报告
Long Long Message Description The little cat is majoring in physics in the capital of Byterland. A p ...
- NYOJ 349 Sorting It All Out (拓扑排序 )
题目链接 描述 An ascending sorted sequence of distinct values is one in which some form of a less-than ope ...
- [bzoj3676][Apio2014]回文串——Manacher+后缀自动机+倍增
Brief Description 一个回文串的value定义为这个回文串的长度乘以出现次数.给定一个字符串,求\(value_{max}\). Algorithm Design 我们使用Manach ...
- Linux下的Backlight子系统(一)【转】
转自:http://blog.csdn.net/weiqing1981127/article/details/8511676 版权所有,转载必须说明转自 http://my.csdn.net/weiq ...
- PHP定时执行
参考一 test.bat D:\myamp\php\php.exe -q D:\myamp\Apache\htdocs\dingshi.php dingshi.php <?php ignore_ ...