日期:2016.09.28
作者:isshe
github:https://github.com/isshe
邮箱:i.sshe@outlook.com
安装ffmpeg:
需要先安装相关工具以及库:
yasm,libx264,libx265,libfdk-aac, libmp3lame,libopus,libvpx
cmake mercurial(源码安装libx265需要用到)
用apt-get安装:
- yasm/nasm
- libx264-dev
- libx265-dev
- libmp3lame
- libopus-dev
libfdk-aac-dev 「源里面可能没有」
可以用apt-get安装的推荐用apt-get安装,简单,默认的头文件以及库的路径是:
/usr/local/include and /usr/local/lib
源码下载:
- yasm : wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
- x264: wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
- x265: hg clone https://bitbucket.org/multicoreware/x265
- fdk-aac: wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master
- mp3lame: wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
- libopus: wget http://downloads.xiph.org/releases/opus/opus-1.1.2.tar.gz
- vpx(可能需要翻墙): wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.5.0.tar.bz2
- ffmpeg: wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
源码安装:
- 安装x265:
sudo apt-get install cmake mercurial
hg clone https://bitbucket.org/multicoreware/x265
cd x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
#如果默认路径安装使用:cmake -G "Unix Makefiles" -DENABLE_SHARED:bool=off ../../source
make
make install
make distclean
其他(除了ffmpeg)的操作基本都是:
- 解压
- cd 进目录
- ./configure (如果不是默认路径则使用–prefix=”pathname”, –bindir=”pathname”指定相关路径)
- make
- sudo make install
- make clean / distclean [全部装好再clean,否则如果出现什么状况又要重新make,耗时间]
ffmpeg源码安装(默认路径):
tar xjvf ffmpeg-snapshot.tar.bz2 cd ffmpeg ./configure \ --pkg-config-flags="--static" \ --enable-gpl \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libtheora \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree make install make distclean hash -r
非默认路径:
tar xjvf ffmpeg-snapshot.tar.bz2 cd ffmpeg PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ --prefix="$HOME/ffmpeg_build" \ --pkg-config-flags="--static" \ --extra-cflags="-I$HOME/ffmpeg_build/include" \ --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --bindir="$HOME/bin" \ --enable-gpl \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libtheora \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree PATH="$HOME/bin:$PATH" make make install make distclean hash -r
测试代码:test_ffmpeg.c
#include <stdio.h>
#include <libavcodec/avcodec.h>
#include <string.h>
int main(void)
{
printf("%s", avcodec_configuration());
getchar();
return 0;
}
编译:
```
gcc test_configure.c -o test_configure -lavcodec -lavutil -m -lpthread
```
示例结果:
安装sdl1.2 和 sdl2
- sudo apt-get install libsdl2 libsdl1.2
测试代码:
(需要下载一个yuv文件,并把下面的参数改改)
#include <stdio.h>
#include <SDL2/SDL.h>
//#include <SDL2/SDL2main.h>
int main(void)
{
if (SDL_Init(SDL_INIT_VIDEO))
{
printf("Couldn't initialize SDL - %s\n", SDL_GetError());
}
else
{
printf("Success init SDL\n");
}
return 0;
}
编译:
- gcc ffmpeg_sdl.c -lSDL2 -lSDL2main
示例结果:
相关资料下载:
http://download.csdn.net/detail/i_scream_/9643410