官方参考网址https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
ffmpeg,可以将视频进行视频格式转换、音频视频合成、从视频中提取出声音、从视频中去除声音、从视频中提取图片、给视频加水印、音频压缩、屏幕录制或者同时录制声音。
开始安装,以下步骤完全参考于网址2。
首先从官网上下载ffmpeg-3.3.tar.bz2
sudo apt-get update
sudo apt-get install yasm
sudo apt-get install libx264-dev
sudo apt-get install libfaac-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libtheora-dev
sudo apt-get install libvorbis-dev
sudo apt-get install libxvidcore-dev
sudo apt-get install libxext-dev
sudo apt-get install libxfixes-dev
解压ffmpeg-3.3.tar.bz2
tar -xjvf ffmpeg-3.3.tar.bz2
./configure –prefix=/usr/local/ffmpeg –enable-gpl –enable-version3 –enable-nonfree –enable-postproc –enable-pthreads –enable-libmp3lame –enable-libtheora –enable-libx264 –enable-libxvid –enable-libvorbis
make
sudo make install
我在两台ubuntu环境中均用以上办法成功安装了 ffmpeg,看到有的网页说直接用apt-get install的方式直接安装ffmpeg,暂未尝试。在configure中,可以有不同的配置,我这里的安装,可以从视频中提取图片,以及视频格式转换。
测试是否安装成功,可以尝试几个功能
- 从视频中提取出图片
-
/usr/local/ffmpeg/bin/ffmpeg -y -i /usr/local/tomcat/webapps/simplest_video_website/videoori/12345.mp4 -ss 5 -s 220x110 -f image2 -vframes 1 /usr/local/tomcat/webapps/simplest_video_website/videothumbnail/50.jpg
- 视频格式转换
-
/usr/local/ffmpeg/bin/ffmpeg -y -i /usr/local/tomcat/webapps/simplest_video_website/videoori/12345.mp4 -vcodec libx264 -b:v 500000 -r 25 -acodec libmp3lame -b:a 64000 -ar 22050 -vf scale=w=640:h=360:force_original_aspect_ratio=decrease,pad=w=640:h=360:x=(ow-iw)/2:y=(oh-ih)/2[aa];movie=svw.png[bb];[aa][bb]overlay=x=5:y=5 /usr/local/tomcat/webapps/simplest_video_website/video/50.flv
If you want the ffmpeg command to just work from anywhere:
- Log in and log out
- Or run source ~/.profile
-
If you want to run man ffmpeg to have local access to the documentation:
- echo “MANPATH_MAP HOME/bin HOME/ffmpeg_build/share/man” >> ~/.manpath
-
Updating FFmpeg
Development of FFmpeg is active and an occasional update can give you new features and bug fixes. First you need to delete (or move) the old files:rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,yasm,ytasm}
Now just follow the guide from the beginning.
参考网页
[1]linux下ffmpeg的使用方法http://www.cnblogs.com/lifan3a/articles/4711706.html
[2] ubuntu14.04安装ffmpeghttp://blog.csdn.net/redstarofsleep/article/details/45092145
[3]ubuntu14.04下ffmpeg的安装http://blog.csdn.net/ba_mboo/article/details/44620567
这是直接使用apt-get install 的方式安装的
[4]雷霄骅http://blog.csdn.net/leixiaohua1020/article/list/2