设为首页 收藏本站
查看: 1114|回复: 0

[经验分享] [trans]在CentOS 5上安装FFMPEG

[复制链接]

尚未签到

发表于 2016-5-11 06:09:37 | 显示全部楼层 |阅读模式
  
http://hi.baidu.com/lhabc/blog/item/6745898f6316c6f1503d9229.html
faac是用来压AAC音轨的,而faad2就是AAC音轨的解码器,liba52是进行AC3支持的
安装前准备编译的环境

yum install -y automake autoconf libtool gcc gcc-c++
1.下载需要的解码器
wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz
wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz
wget http://downloads.sourceforge.net/faac/faac-1.26.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz
wget ftp://ftp.videolan.org:21//pub/videolan/x264/snapshots/x264-snapshot-20090107-2245.tar.bz2
wget http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz
wget http://down1.iyunv.com/distfiles/libdts-0.0.2.tar.gz
2.解压安装
解压
for i in *.tar.gz; do tar -xzvf "$i"; done
for i in *.tar.bz2; do tar -xjvf "$i"; done

安装的参数

a52dec: ./configure –enable-shared=PKGS && make && make install
faac & faad2: ./bootstrap && ./configure && make && make install
xvidcore: cd build/generic; ./configure && make && make install
libx264: ./configure –enable-mp4-output –enable-shared –enable-pthread && make && make install
lame & yasm: ./configure && make && make install

最后下载和安装ffmpeg
我是使用的svn同步比较新的,如果有时不能编译通过,可以考虑不使用最新的,不过要提示一下,就是连接这个网站,被我们国家的防火墙给kill掉了。需要各位自己想法子.
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
编译参数
./configure –enable-gpl –enable-postproc –enable-nonfree –enable-postproc –enable-libfaad –enable-swscale –enable-avfilter –enable-pthreads –enable-libxvid –enable-libx264 –enable-libmp3lame –enable-libfaac –disable-ffserver –disable-ffplay

支持rm和rmvb
对rm和rmvb,只有ffmpeg是不行的,还需要下面的mplayer
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2
wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-amd64-20071007.tar.bz2
for i in *.tar.bz2; do tar -xjvf "$i"; done
cp -rf essential-20071007/* /usr/local/lib/codecs
cp -rf all-20071007/* /usr/local/lib/codecs
cp -rf essential-amd64-20071007/* /usr/local/lib/codecs
./configure –prefix=/usr/local/mplayer –enable-gui –enable-freetype –codecsdir=/usr/local/lib/codes –win32codecsdir=/usr/local/lib/win32codcs

更新动态链接库
因为是编译器安装的,所以需要让系统可以找到动态链接库
#echo "/usr/local/lib" >> /etc/ld.so.conf
#echo "/usr/lib" >> /etc/ld.so.conf
#ldconfig
到这基本就安装完了
最基本的几个命令(一定要了解的)
显示支持的格式,不过好象加参数时,加其中的会有问题,看来参数和支持的格式是不一样的
$ ffmpeg -formats 

显示视频的相关信息,如时长,文件声音和视频格式之类的信息
ffmpeg -i abc.ts

查看可以加什么参数 
ffmpeg -h
mplayer获取影片信息
mplayer -identify movie-filename -nosound -vc dummy -vo null
使用ffmpeg从视频中抓图
ffmpeg -i 原视频文件路径 -y -f image2 -ss 8 -t 0.001 -s 图象大小(400×300) 图片存放路径
使用ffmpeg给视频转换成flv
ffmpeg -i 原视频文件路径 -o 目标文件路径 -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=视频码流:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:dia=4:cmp=6:vb_strategy=1 -vf scale=高:宽 -ofps 12 -srate 22050′)
ffmpeg 00:04:00 -t 00:08:00 -i -vcodec copy -acodec copy aaa.avi
FAQ
1.出现如下提示
-soname,libx264.so.65 -lm -lpthread -lgpac_static -s
/usr/bin/ld: cannot find -lgpac_static
collect2: ld returned 1 exit status
make: *** [libx264.so.65] Error 1
解决方法
yum install zlib-devel
wget http://internap.dl.sourceforge.net/sourceforge/gpac/gpac-0.4.5.tar.gz
wget http://internap.dl.sourceforge.net/sourceforge/gpac/gpac_extra_libs-0.4.5.tar.gz
tar -zxf gpac-0.4.5.tar.gz
tar -zxf gpac_extra_libs-0.4.5.tar.gz
cd gpac_extra_libs
cp -r * ../gpac/extra_lib
cd ../gpac
chmod +x configure
./configure
make lib
make apps
make install-lib
make install
cp bin/gcc/libgpac.so /usr/lib
注意,使用下面的参数出错
–enable-liba52 –enable-liba52bin
查看源码发现中包括了ac3

为了查找方便,把ffmpeg中的参数都列出来
参数英文说明-Lshow license-hshow help-versionshow version-formats显示可以使用的格式,编码,协议-f强行设置输出格式[fmt]-i输入文件名[filename]-y不询问直接覆盖输出文件-mapset input stream mapping,file:stream[:syncfile:syncstream]-map_meta_dataset meta data information of outfile from infile,outfile:infile-tset the recording time[duration]-fsset the limit file size[limit_size]-ssset the start time offset[time_off]-itsoffsetset the input ts offset[time_off]-title视频文件标题[string]-timestampset the timestamp[time]-authorset the author[string]-copyrightset the copyright[string]-commentset the comment[string]-albumset the album[string]-benchmarkadd timings for benchmarking-dumpdump each input packet-hexwhen dumping packets, also dump the payload-reread input at native frame rate-loop_inputloop (current only works with images)-loop_outputnumber of times to loop output in formats that support looping (0 loops forever)-vcontrol amount of logging[verbose]-targetspecify target file type (”vcd”, “svcd”, “dvd”, “dv”, “dv50″, “pal-vcd”, “ntsc-svcd”, …)[type]-threadsthread count[count]-vsyncvideo sync method-asyncaudio sync method-vglobalvideo global header storage type-copytscopy timestamps-shortestfinish encoding within shortest input-dts_delta_thresholdtimestamp discontinuity delta threshold以下是视频相关的命令-vframes按所提供的帧数对文件解码(例ffmpeg -i test5.flv -r 15 -s 384*288 -y -vframes 1 photos.flv)[num]-aframesset the number of audio frames to record[num]-dframesset the number of data frames to record[num]-r设置帧速率,每秒多少帧 (Hz value, fraction or abbreviation)[rate]-s设置视频的宽度和高度,格式为320×240,320*240,320:240都可以-aspectset aspect ratio (4:3, 16:9 or 1.3333, 1.7777)[aspect]-pix_fmtset pixel format[format]-croptopset top crop band size (in pixels)[size]-cropbottom“set bottom crop band size (in pixels)[size]-cropleftset left crop band size (in pixels)[size]-croprightset right crop band size (in pixels)[size]-padtopset top pad band size (in pixels)[size]-padbottomset bottom pad band size (in pixels)[size]-padleftset left pad band size (in pixels)[size]-padrightset right pad band size (in pixels)[size]-padcolorset color of pad bands (Hex 000000 thru FFFFFF)[color]-intrause only intra frames-vndisable video-vdtdiscard threshold[n]-qscaleuse fixed video quantizer scale (VBR)[q]-qdiffmax difference between the quantizer scale (VBR)[q]-rc_eqset rate control equation[equation]-rc_overriderate control override for specific intervals[override]-vcodecforce video codec (’copy’ to copy stream)[codec]-meset motion estimation method[method]-me_thresholdmotion estimaton threshold-psset packet size in bits[size]-stricthow strictly to follow the standards[strictness]-samequse same video quality as source (implies VBR)-passselect the pass number (1 or 2)[n]-passlogfileselect two pass log file name[filename]-deinterlacedeinterlace pictures-psnrcalculate PSNR of compressed frames-vstatsdump video coding statistics to file-vhookinsert video processing module[module]-intra_matrixspecify intra matrix coeffs[matrix]-inter_matrixspecify inter matrix coeffs[matrix]-toptop=1/bottom=0/auto=-1 field first-dcintra_dc_precision[precision]-vtagforce video tag/fourcc[fourcc/tag]-newvideoadd a new video stream to the current output stream-qphistshow QP histogram以下是音频相关的命令-ab声音码流(in kbit/s)[bitrate]-aq声音品质(codec-specific)[quality]-ar声音的采样频率 (in Hz)[rate]-ac设置输出的声道数[channels]-an不输出声音-acodec设置输入声音的编码格式 (’copy’ to copy stream)[codec]-atagforce audio tag/fourcc[fourcc/tag]-volchange audio volume (256=normal)[volume]-newaudioadd a new audio stream to the current output stream-alangset the ISO 639 language code (3 letters) of the current audio stream[code]以下是字幕相关的命令-scodecforce subtitle codec (’copy’ to copy stream)[codec]-newsubtitleadd a new subtitle stream to the current output stream-slangset the ISO 639 language code (3 letters) of the current subtitle stream[code]以下是不常用的命令-vdset video grab device[device]-vcset video grab channel (DV1394 only)[channel]-tvstdset television standard (NTSC, PAL (SECAM))[standard]-adset audio device[device]-grabrequest grabbing using[format]-gdset grab device[device]-muxdelayset the maximum demux-decode delay[sec]-muxpreloadset the initial demux-decode delay[sec]-absf-vbsf-defaultgeneric catch all option(ffmpeg参数说明)
http://hi.baidu.com/lhabc/blog/item/6745898f6316c6f1503d9229.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-215256-1-1.html 上篇帖子: Centos 图形界面没了解决办法 下篇帖子: centos 6.0 python lxml pyquery mysqldb
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表