Introduction to FFmpeg
来源:互联网 发布:nmap软件功能 编辑:程序博客网 时间:2024/05/21 21:40
http://www.osxexperts.net/ffmpeg/ffmpegexperts.html
Introduction to FFmpeg
What is FFmpeg?
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.
FFmpeg is free software licensed under the LGPL or GPL depending on your choice of configuration options.
In its simplest form, FFmpeg is a decoder and also an encoder, enabling it to convert files from one container or codec to a another one. For example, a VOB file from a DVD with MPEG video and AC3 sound can be converted to an AVI file featuring H263 video with MP3 audio, or a QuickTime file with SVQ3 video and MP3 audio can turn into 3GP file with H263 video and AMR wideband sound. FFmpeg is the most used converter engine for Windows, Mac OSX and Linux. Almost every de/encoding utility uses FFmpeg to decode and encode media files. Portions of FFmpeg can also be found in well-known projects such as Google Chrome, Handbrake and VLC Player.
FFmpeg is an open source project, it will convert most popular file formats. It’s only downside is that it requires more developer effort to reach usable solutions. If you persevere with FFmpeg, you can easily create a good cross platform application for hosting on Windows or Linux servers, and there is no fee.
Why we need FFmpeg.
How websites differ is often down to the content they feature. Video is an important feature of most popular sites these days, to varying degrees. What is certain is that obviously lacking the capability to host video makes a site seem out of date.
FFmpeg allows you to convert video files from one format to another, which is crucial today. It allows you to host programs related to software and programs. It enables you to perform Encoding and decoding processes on video and audio files. Lastly it allows for the running of an effective video sharing website.
Given that many more people now want to be able to add video to their sites, there's been a demand for the technology that perhaps didn't take into account the difficulties involved in accomplishing the task at hand. You can now take video, easily, and there plenty of places online to feature it, so it must be easy to put it there, right?
Compiling a fresh FFmpeg binary.
Installing/compiling FFmpeg can be painful. There are so many libraries to hunt and juggle to get everything to work that many people do not even think about compiling their own FFmpeg binary.
Fortunately, OSXExperts will tell you step-by-step how to compile your own FFmpeg binary. So take some time and patience and follow our expert tutorial to compile your own FFmpeg binary for Mac OS X.
STEP 1 - Preparations
Lets start with the FFmpeg source code (off-course)
But before we do this I have to explain one or two things.
In the past you could download a source code with a single download file. For large projects this would mean you had to download the whole source code.
Lately most developers are using GIT. Git is a ‘distribution version control system’ designed to handle especially large coding projects like FFmpeg.
We need to install this tool first. It is needed for the FFmpeg source code.
- Download GIT installer at http://git-scm.com/
- Install the package
Another compiler tool is Yasm. You also need this.
- Go to http://www.tortall.net/projects/yasm/wiki/Download
- Now download the source .tar.gz (latest version is 1.1.0)
- Uncompressed the .tar file by double clicking on the archive.
Off-course we need X-Code too.
- Go to http://developer.apple.com
- Download the latest X-code package
- Install X-code
STEP 2 - Downloading all necessary source codes
To make things easy copy every downloaded file into a folder named ‘ffmpegsource’ on the desktop.
Terminal
This is an application you can find in the Application/Utilities Folder.
FFmpeg source code
- Open the Terminal
- write the following in the Terminal : git clone git://git.videolan.org/ffmpeg.git ffmpeg
Because FFmpeg needs several extra codecs you need some other source codes too.
MP3lame source code
- Go to http://lame.sourceforge.net/download.php
- Download lame source
Ogg, Vorbis and Theora source code
- Go to http://xiph.org/downloads/
- Download the following sources: libogg source , libvorbis source and libtheora source.
X264 source code (for H264 support)
- Open the Terminal
- write the following in the Terminal : git clone git://git.videolan.org/x264.git
VP8 source code
- Open the terminal
- write the following in the Terminal : git clone git://review.webmproject.org/libvpx.git
Xvid source code
- Go to http://www.xvid.org/Downloads.43.0.html
- Download Xvid source code
Though you can add some more codecs I mostly only include the above mentioned sources. It should be enough for most converting needs and it also does not use any heavy patented codecs (for example: including FAAC -for AAC support- would mean it is illegal to distribute your compile FFmpeg binary).
This is how the folder ffmpegsources should look
STEP 3 - Compiling all source codes
Now we are set to start compiling all sources. I will not go into details of all the compile commands we are going to use. But make sure you copy/paste them exactly as shown. Here we go ..
- Open the Terminal and copy paste every line below marked BOLD.
DISK_ID=$(hdid -nomount ram://26214400) && newfs_hfs -v tempdisk ${DISK_ID} && diskutil mount ${DISK_ID} && SOURCE="/Volumes/tempdisk/sw" && COMPILED="/Volumes/tempdisk/compile" && mkdir ${SOURCE} && mkdir ${COMPILED} && export PATH=${SOURCE}/bin:$PATH
Now copy all folders from the ffmpegsource folder to the created tempdisk/compile folder.
Finished? Lets compile some code!
// when using Xcode 4.3 and OSX 10.7.x
export CC=clang
// when using Xcode 4.3 and OSX 10.7.x
Compiling YASM:
cd ${COMPILED} || exit 1
cd yasm-1.2.0
./configure --prefix=${SOURCE} && make -j 4 && make install
Compiling LIBVPX
// when using Xcode 4.3 and OSX 10.7.x
export CFLAGS=-I/usr/include
export LDFLAGS=-L/usr/lib
// when using Xcode 4.3 and OSX 10.7.x
cd ${COMPILED}
cd libvpx
./configure --prefix=${SOURCE} --disable-shared && make -j 4 && make install
// when using Xcode 4.3 and OSX 10.7.x
unset CFLAGS
unset LDFLAGS
// when using Xcode 4.3 and OSX 10.7.x
Compiling LAME
cd ${COMPILED}
cd lame-3.99
./configure --prefix=${SOURCE} --disable-shared --enable-static && make -j 4 && make install
Compiling XVIDCORE
cd ${COMPILED}
cd xvidcore
cd build/generic
./configure --prefix=${SOURCE} --disable-shared --enable-static --disable-assembly && make -j 4 && make install
rm ${SOURCE}/lib/libxvidcore.4.dylib
Compiling X264
cd ${COMPILED}
cd x264
./configure --prefix=${SOURCE} --disable-shared --enable-static && make -j 4 && make install && make install-lib-static
Compiling LIBOGG
cd ${COMPILED}
cd libogg-1.3.0
./configure --prefix=${SOURCE} --disable-shared --enable-static && make -j 4 && make install
Compiling LIBVORBIS
cd ${COMPILED}
cd libvorbis-1.3.2
./configure --prefix=${SOURCE} --with-ogg-libraries=${SOURCE}/lib --with-ogg-includes=/Volumes/tempdisk/sw/include/ --enable-static --disable-shared && make -j 4 && make install
Compiling LIBTHEORA
cd ${COMPILED}
cd libtheora-1.1.1
./configure --prefix=${SOURCE} --with-ogg-libraries=${SOURCE}/lib --with-ogg-includes=${SOURCE}/include/ --with-vorbis-libraries=${SOURCE}/lib --with-vorbis-includes=${SOURCE}/include/ --enable-static --disable-shared && make -j 4 && make install
Compiling ZLIB
cd ${COMPILED}
cd zlib
./configure --prefix=${SOURCE} && make -j 4 && make install
rm ${SOURCE}/lib/libz*dylib
rm ${SOURCE}/lib/libz.so*
Compiling FFMPEG
cd ${COMPILED}
cd ffmpeg
export LDFLAGS="-L${SOURCE}/lib"
export CFLAGS="-I${SOURCE}/include"
./configure --prefix=${SOURCE} --enable-gpl --enable-pthreads --disable-ffplay --disable-ffserver --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-avfilter --enable-zlib --enable-filters --arch=x86 --enable-runtime-cpudetect && make -j 4 && make install
// when using Xcode 4.3 and OSX 10.7.x
Add --disable-asm in the above configure
// when using Xcode 4.3 and OSX 10.7.x
After doing all the hardcore compiling you are awarded a FFmpeg binary in the BIN folder (RAM disk).
- Introduction to FFmpeg
- Introduction to CGI Variables
- Introduction to Rave Reports
- Introduction to RSS
- Introduction to NMock
- An Introduction to Struts
- Links:Introduction To TDD
- Introduction to Smartphone
- Introduction to C# interface
- 第一章: Introduction to Objects
- Introduction to IoC
- An introduction to LaTeX2e
- About Introduction to Algorithms
- Introduction to MySQL Cluster
- Introduction To Alpha Blending
- An Introduction To Ajax
- Introduction to Ajax
- Introduction To Perspective Projection
- Android:根据图片的名称获取对应的资源id
- vs2010项目属性配置
- Cocos2d-X开发中国象棋《二》工程文件概述
- 快捷支付集成
- 微信数据挖掘 图文数据获取
- Introduction to FFmpeg
- 从SVN上下载的web项目包变成文件夹的解决办法
- Android界面特效全汇总
- BUG:android真机调试 opendir failed, Peermission denied
- 将django的HTTP响应保存为excel
- GIT和SVN之间的五个基本区别
- arm平台搭建vsftpd服务
- Struts2.ActionSupport
- Binary Tree Postorder Traversal