1. 下载
可以直接访问FFmpeg官网的下载页面http://www.ffmpeg.org/download.html,直接下载源码压缩包或者是git直接下载。
这里直接git拉下来:
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
以后直接git pull更新,能随时体验最新的代码。
2. 编译环境准备
需要安装SDL库,否则编译不出来ffplay。
sudo apt-get install libsdl1.2-dev
3. 编译
cd ~/ffmpeg //刚才下载的源码目录
./configure --prefix=~/mpeg
make
make install
4. 编译结果
mpeg$ tree . -L 2
.
├── bin
│ ├── ffmpeg
│ ├── ffplay
│ ├── ffprobe
│ └── ffserver
├── include
│ ├── libavcodec
│ ├── libavdevice
│ ├── libavfilter
│ ├── libavformat
│ ├── libavutil
│ ├── libswresample
│ └── libswscale
├── lib
│ ├── libavcodec.a
│ ├── libavdevice.a
│ ├── libavfilter.a
│ ├── libavformat.a
│ ├── libavutil.a
│ ├── libswresample.a
│ ├── libswscale.a
│ └── pkgconfig
└── share
├── ffmpeg
└── man
Libavutil
The libavutil library is a utility library to aid portablemultimedia programming. It contains safe portable string functions,random number generators, data structures, additional mathematicsfunctions, cryptography and multimedia related functionality (likeenumerations for pixel and sample formats). It is not a library forcode needed by both libavcodec and libavformat.
The goals for this library is to be:
-
Modular
-
It should have few interdependencies and the possibility of disabling individualparts during
./configure
.
Small
-
Both sources and objects should be small.
Efficient
-
It should have low CPU and memory usage.
Useful
-
It should avoid useless features that almost no one needs.
Libswscale
The libswscale library performs highly optimized image scaling andcolorspace and pixel format conversion operations.
Specifically, this library performs the following conversions:
- Rescaling: is the process of changing the video size. Severalrescaling options and algorithms are available. This is usually alossy process.
- Pixel format conversion: is the process of converting the imageformat and colorspace of the image, for example from planar YUV420P toRGB24 packed. It also handles packing conversion, that is convertsfrom packed layout (all pixels belonging to distinct planesinterleaved in the same buffer), to planar layout (all samplesbelonging to the same plane stored in a dedicated buffer or "plane").
This is usually a lossy process in case the source and destinationcolorspaces differ.
Libswresample
The libswresample library performs highly optimized audio resampling,rematrixing and sample format conversion operations.
Specifically, this library performs the following conversions:
- Resampling: is the process of changing the audio rate, forexample from a high sample rate of 44100Hz to 8000Hz. Audioconversion from high to low sample rate is a lossy process. Severalresampling options and algorithms are available.
- Format conversion: is the process of converting the type ofsamples, for example from 16-bit signed samples to unsigned 8-bit orfloat samples. It also handles packing conversion, when passing frompacked layout (all samples belonging to distinct channels interleavedin the same buffer), to planar layout (all samples belonging to thesame channel stored in a dedicated buffer or "plane").
- Rematrixing: is the process of changing the channel layout, forexample from stereo to mono. When the input channels cannot be mappedto the output streams, the process is lossy, since it involvesdifferent gain factors and mixing.
Various other audio conversions (e.g. stretching and padding) areenabled through dedicated options.
Libavcodec
The libavcodec library provides a generic encoding/decoding frameworkand contains multiple decoders and encoders for audio, video andsubtitle streams, and several bitstream filters.
The shared architecture provides various services ranging from bitstream I/O to DSP optimizations, and makes it suitable forimplementing robust and fast codecs as well as for experimentation.
Libavformat
The libavformat library provides a generic framework for multiplexingand demultiplexing (muxing and demuxing) audio, video and subtitlestreams. It encompasses multiple muxers and demuxers for multimediacontainer formats.
It also supports several input and output protocols to access a mediaresource.
Libavdevice
The libavdevice library provides a generic framework for grabbing fromand rendering to many common multimedia input/output devices, andsupports several input and output devices, including Video4Linux2,VfW, DShow, and ALSA.
Libavfilter
The libavfilter library provides a generic audio/video filteringframework containing several filters, sources and sinks.