首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

ffmpeg编译及施用 (转载)

2012-10-26 
ffmpeg编译及使用 (转载)FFmpeg can use a video4linux compatible video source and any Open Sound Syst

ffmpeg编译及使用 (转载)

FFmpeg can use a video4linux compatible video source and any Open Sound System audio source:? ?? ?? ?
? ?? ???ffmpeg /tmp/out.mpg
Note that you must activate the right video source and channel before launching ffmpeg. You can use any TV viewer such as

xawtv (<http://bytesex.org/xawtv/>) by Gerd Knorr which I find very good. You must also set correctly the audio recording

levels with a standard mixer.
"Video and Audio file format conversion"

* You can input from YUV files:? ?? ?
? ?? ???ffmpeg -i /tmp/test%d.Y /tmp/out.mpg

* You can transcode decrypted VOBs? ?? ?? ?
? ?? ???ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
This is a typical DVD ripper example, input from a VOB file, output to an AVI file with MPEG-4 video and
show help force displayed width force displayed height disable audio disable video disable graphical display force format
"Advanced options"

show the stream duration, the codec parameters, the current position in the stream, and the audio/video synchronisation drift. force RTP/TCP protocol usage instead of RTP/UDP. It is only meaningful if you are doing stream with the RTSP protocol.

set the master clock to audio ( type=audio), video ( type=video) or external ( type=ext). Default is audio. The master clock is used to control audio-video synchronization. Most media players use audio as master clock, but in some cases (streaming or high quality broadcast) it is necessary to change that. This option is mainly used for debugging purposes.


(3) ffserver的使用
ffsserver - FFserver video server
SYNOPSIS

ffserver [options]
DESCRIPTION

FFserver is a streaming server for both audio and video. It supports several live feeds, streaming from files and time shifting on live feeds (you can seek to positions in the past on each live feed, provided you specify a big enough feed

storage in ffserver.conf).

This documentation covers only the streaming aspects of ffserver / ffmpeg. All questions about parameters for ffmpeg, codec questions, etc. are not covered here. Read ffmpeg-doc.html for more information.
OPTIONS

print the license print the help use configfile instead of /etc/ffserver.conf

6 其他(参考)

(1)mencoder篇
? ?首先获取mplayer软件包极其mplayer官网上自带的codecs.如果喜欢mplayer,也可以下载gui和font.关于mplayer-1.0rc1在71.21的/home/zhengyu/tools中能找到.如果需要网上下载,可以去官网:http://www.mplayerhq.hu/de...下载rc1地址如

下:http://www1.mplayerhq.hu/M...最新的svn版本:http://www1.mplayerhq.hu/M...官网同时也给出了一些codec,其中就有rm格式的codec:http://www1.mplayerhq.hu/M...? ? xplore也提供下载,mplayer1.0rc1下载,codec下载.

? ?下载完成之后,将tar vxjf essential-20061022.tar.bz2;sudo mkdir -p /usr/lib/codecs;sudo cp -rf essential-20061022/*

/usr/lib/codecs;然后解包mplayer,按如下方式编译:

./configure --prefix=/usr/local --enable-gui --enable-largefiles??--enable-gif --enable-png --enable-jpeg --language=zh_CN --with-codecsdir=/usr/lib/codecs/
make
(sudo make install)

? ?然后就可以使用mencoder,当然也有一个没有gui的mplayer可以播放各种视频了.不过我们需要的是mencoder.至此,ffmpeg+mencoder搭建完成.

(2) 常见操作说明
对于ffmpeg,可以将除swf,rmvb,wmav9以外的视频/音频格式转换成flv/mp3,同时可以截取这些视频文件中的某个时间的该帧图片.这些实际上就是一个视频播客显示的部分.对于mencoder,支持各种常见格式的视频/音频转换成flv/mp3.或者转换成avi.

1) ffmpeg进行操作的常用方法:

? ?* 转换成flv文件:ffmpeg -i infile.* -y (-ss second_offset -ar ar -ab ab -r vr -b vb -s vsize) outfile.flv
? ?? ???其中second_offset是从开始的多好秒钟.可以支持**:**:**格式,至于ar,ab是音频的参数,可以指定ar= 22050,24000,44100(PAL制式),48000(NTSC制式),后两种常见,ab=56(视音频协议的codec而定,如果要听高品质,则80以上).vr,vb,vsize是视频参数,可以指定vr=15,25(PAL),29(NTSC),vb=200,500,800,1500 (视视频协议的codec而定,可以通过查看专业的codec说明文档获取,如果你手头有一份详细的各种codec的文档,请提供一份给我,不胜感激.),还有一些参数-acodec ac -vcodec vc(ac指定音频codec,ar和ab可以省去,vc指定视频codec,vr和vb可以省去,自动采用相应的codec参数)还有很多高级参数,如-qmin,-qcale等,请查看详细文档。还有-an和-vn参数,分别从多媒体文件中提取出纯粹视频和音频。另,如果你是用shell批量处理,请使用-y参数覆盖生成flv.

? ?* 截取图片:ffmpeg -i infile.* -y (-ss second_offset) -t 0.001 -s msize (-f image_fmt) outfile.jpg
? ?? ?? ?? ?其中second_offset同上,msize同vsize,图片大小.image_fmt=image2强制使用jpg,image_fmt=gif,强制使用gif格式.还可以用-vframes fn指定截取某帧图片,fn=1,2,3,...


2)mencoder操作
? ? mencoder的作用主要在视频转码方面.在安装完mplayer后,mencoder也编译生成了.可以man mencoder获取mencoder的说明文档. mencoder的参数更加复杂,不过也无非是音频处理视频处理两个方面,可以参看网络例子:http://www.masoncn.com/pos...这里不作详细的列举了.

? ?mencoder进行操作的常用方法: mencoder infile.* -o outfile.* [-ovc 目标视频格式] [-oac 目标音频格式] [-of 目标文件格式]

? ?* 转换成flv文件: mencoder infile.* -o outfile.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts

vcodec=flv:vbitrate=150:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050

? ?* 转换成avi文件: mencoder infile.* -o outfile.avi -of avi -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts

bitrate=600

? ?* 转换成wmv文件(复杂写法,其中高级参数可以省去): mencoder infile.* -o outfile.wmv -of lavf -ofps 25 -oac mp3lame -lameopts

cbr:preset=128 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=768:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=320:240 -srate

22050 -sws 9 -subcp cp936 -subpos 0 -subalign 0 -subfont-text-scale 3 -lavfopts i_certify_that_my_video_strea
? ?其中-ovc,-oac和-of是必须的,-ovc是指定视频codec,指定了ovc之后通常带一个该codec的opt参数,-oac是指定音频 codec,也会在其后带一个codec的opt参数.可以指定细节以决定视频音频质量和转换速率.具体的细节可以参看专业的技术文档.

7??ffmpeg配置选项

[root@web ffmpeg]# ./configure --help
Usage: configure [options]
Options: [defaults in brackets after descriptions]

Standard options:? ?基本选项参数
??--help? ?? ?? ?? ?? ?? ? 显示此帮助信息|print this message
??--log[=FILE|yes|no]? ?? ?记录测试并输出到config.err文件|log tests and output to FILE [config.err]
??--prefix=PREFIX? ?? ?? ? 安装程序到指定目录(默认/usr/local)|install in PREFIX [/usr/local]
??--libdir=DIR? ?? ?? ?? ? 安装库到指定目录(默认prefix/lib)|install libs in DIR [PREFIX/lib]
??--shlibdir=DIR? ?? ?? ???指定共享库路径(默认prefix/lib)|install shared libs in DIR [PREFIX/lib]
??--incdir=DIR? ?? ?? ?? ? 指定includes路径(默认prefix/include/ffmpeg)|install includes in DIR[PREFIX/include/ffmpeg]
??--mandir=DIR? ?? ?? ?? ? 指定man page路径(默认prefix/man)install man page in DIR [PREFIX/man]
??--enable-mp3lame? ?? ?? ?启用mp3编码libmp3lame(默认关闭)enable MP3 encoding via libmp3lame[default=no]
??--enable-libogg? ?? ?? ? 启用ogg支持libogg(默认关闭)enable Ogg support via libogg [default=no]
??--enable-vorbis? ?? ?? ? 启用Vorbis支持libvorbis(默认关闭)enable Vorbis support via libvorbis [default=no]
??--enable-faad? ?? ?? ?? ?启用faad支持libfaad(默认关闭)enable FAAD support via libfaad [default=no]
??--enable-faadbin? ?? ?? ?启用faad运行时链接支持(默认关闭)build FAAD support with runtime linking[default=no]
??--enable-faac? ?? ?? ?? ?启用faac支持libfaac(默认关闭)enable FAAC support via libfaac [default=no]
??--enable-libgsm? ?? ?? ? 启用GSM支持libgsm(默认关闭)enable GSM support via libgsm [default=no]
??--enable-xvid? ?? ?? ?? ?启用xvid支持xvidcore(默认关闭)enable XviD support via xvidcore [default=no]
??--enable-x264? ?? ?? ?? ?启用H.264编码(默认关闭)enable H.264 encoding via x264 [default=no]
??--enable-mingw32? ?? ?? ?启用MinGW本地/交叉win环境编译|enable MinGW native/cross Windows compile
??--enable-mingwce? ?? ?? ?启用MinGW本地/交叉winCE环境编译enable MinGW native/cross WinCE compile
??--enable-a52? ?? ?? ?? ? 启用A52支持(默认关闭)enable GPLed A52 support [default=no]
??--enable-a52bin? ?? ?? ? 启用运行时打开liba52.so.0(默认关闭)open liba52.so.0 at runtime [default=no]
??--enable-dts? ?? ?? ?? ? 启用DTS支持(默认关闭)enable GPLed DTS support [default=no]
??--enable-pp? ?? ?? ?? ???启用后加工支持(默认关闭)enable GPLed postprocessing support [default=no]
??--enable-static? ?? ?? ? 构建静态库(默认启用)build static libraries [default=yes]
??--disable-static? ?? ?? ?禁止构建静态库(默认关闭)do not build static libraries [default=no]
??--enable-shared? ?? ?? ? 构建共享库(默认关闭)build shared libraries [default=no]
??--disable-shared? ?? ?? ?禁止构建共享库(默认启用)do not build shared libraries [default=yes]
??--enable-amr_nb? ?? ?? ? 启用amr_nb float音频编解码器|enable amr_nb float audio codec
??--enable-amr_nb-fixed? ? 启用fixed amr_nb codec | use fixed point for amr-nb codec
??--enable-amr_wb? ?? ?? ? 启用amr_wb float音频编解码器|enable amr_wb float audio codec
??--enable-amr_if2? ?? ?? ?启用amr_wb IF2音频编解码器|enable amr_wb IF2 audio codec
??--enable-sunmlib? ?? ?? ?启用Sun medialib(默认关闭) | use Sun medialib [default=no]
??--enable-pthreads? ?? ???启用pthreads(多线程)(默认关闭)use pthreads [default=no]
??--enable-dc1394? ?? ?? ? 启用libdc1394、libraw1394抓取IIDC-1394(默认关闭)enable IIDC-1394 grabbing using libdc1394 and

libraw1394 [default=no]
??--enable-swscaler? ?? ???启用计数器支持?(默认关闭)software scaler support [default=no]
??--enable-avisynth? ?? ???允许读取AVISynth脚本本件(默认关闭)allow reading AVISynth script files [default=no]
??--enable-gpl? ?? ?? ?? ? 允许使用GPL(默认关闭)allow use of GPL code, the resulting libav* and ffmpeg will be under GPL

[default=no]

Advanced options (experts only): 高级选项参数(供专业人员使用)
??--source-path=PATH? ?? ? 源码的路径(当前为/root/flv/ffmpeg)| path to source code [/root/flv/ffmpeg]
??--cross-prefix=PREFIX? ? 为编译工具指定路径 | use PREFIX for compilation tools []
??--cross-compile? ?? ?? ? 假定使用了交叉编译 | assume a cross-compiler is used
??--cc=CC? ?? ?? ?? ?? ?? ?指定使用何种C编译器(默认gcc)use C compiler CC [gcc]
??--make=MAKE? ?? ?? ?? ???使用特定的make | use specified make [make]
??--extra-cflags=ECFLAGS? ?添加ECFLAGS到CFLAGS | add ECFLAGS to CFLAGS []
??--extra-ldflags=ELDFLAGS 添加ELDFLAGS到LDFLAGS(默认-Wl,--as-needed)| add ELDFLAGS to LDFLAGS [ -Wl,--as-needed]
??--extra-libs=ELIBS? ?? ? 添加ELIBS | add ELIBS []
??--build-suffix=SUFFIX? ? 为专用程序添加后缀 | suffix for application specific build []
??--arch=ARCH? ?? ?? ?? ???选择机器架构(默认x86)select architecture??[x86]
??--cpu=CPU? ?? ?? ?? ?? ? 选用最低的cpu(影响指令的选择,可以在老CPU上出错) | selects the minimum cpu required (affects

instruction selection, may crash on older CPUs)
??--powerpc-perf-enable? ? 启用PPC上面的性能报告(需要启用PMC)enable performance report on PPC
? ?? ?? ?? ?? ?? ?? ?? ?? ?(requires enabling PMC)
??--disable-mmx? ?? ?? ?? ?禁用MMX | disable MMX usage
??--disable-armv5te? ?? ???禁用armv5te | disable armv5te usage
??--disable-iwmmxt? ?? ?? ?禁用iwmmxt | disable iwmmxt usage
??--disable-altivec? ?? ???禁用AltiVec | disable AltiVec usage
??--disable-audio-oss? ?? ?禁用OSS音频支持(默认启用)disable OSS audio support [default=no]
??--disable-audio-beos? ???禁用BeOS音频支持(默认启用)disable BeOS audio support [default=no]
??--disable-v4l? ?? ?? ?? ?禁用video4linux提取(默认启用)disable video4linux grabbing [default=no]
??--disable-v4l2? ?? ?? ???禁用video4linux2提取(默认启用)disable video4linux2 grabbing [default=no]
??--disable-bktr? ?? ?? ???禁用bktr视频提取(默认启用)disable bktr video grabbing [default=no]
??--disable-dv1394? ?? ?? ?禁用DV1394提取(默认启用)disable DV1394 grabbing [default=no]
??--disable-network? ?? ???禁用网络支持(默认支持)disable network support [default=no]
??--disable-ipv6? ?? ?? ???禁用ipv6支持(默认支持)disable ipv6 support [default=no]
??--disable-zlib? ?? ?? ???禁用zlib(默认支持)disable zlib [default=no]
??--disable-simple_idct? ? 禁用simple IDCT例程(默认启用)disable simple IDCT routines [default=no]
??--disable-vhook? ?? ?? ? 禁用video hooking支持 | disable video hooking support
??--enable-gprof? ?? ?? ???enable profiling with gprof [no]
??--disable-debug? ?? ?? ? 禁用调试符号 | disable debugging symbols
??--disable-opts? ?? ?? ???禁用编译器最优化 | disable compiler optimizations
??--disable-mpegaudio-hp? ?启用更快的解码MPEG音频(但精确度较低)(默认禁用)faster (but less accurate) MPEG audio decoding

[default=no]
??--disable-protocols? ?? ?禁用 I/O 协议支持(默认启用)disable I/O protocols support [default=no]
??--disable-ffserver? ?? ? 禁用生成ffserver | disable ffserver build
??--disable-ffplay? ?? ?? ?禁用生成ffplay | disable ffplay build
??--enable-small? ?? ?? ???启用优化文件尺寸大小(牺牲速度)optimize for size instead of speed
??--enable-memalign-hack? ?启用模拟内存排列,由内存调试器干涉? | emulate memalign, interferes with memory debuggers
??--disable-strip? ?? ?? ? 禁用剥离可执行程序和共享库 | disable stripping of executables and shared libraries
??--disable-encoder=NAME? ?禁用XX编码器 | disables encoder NAME
??--enable-encoder=NAME? ? 启用XX编码器 | enables encoder NAME
??--disable-decoder=NAME? ?禁用XX解码器 | disables decoder NAME
??--enable-decoder=NAME? ? 启用XX解码器 | enables decoder NAME
??--disable-encoders? ?? ? 禁用所有编码器 | disables all encoders
??--disable-decoders? ?? ? 禁用所有解码器 | disables all decoders
??--disable-muxer=NAME? ???禁用XX混音器 | disables muxer NAME
??--enable-muxer=NAME? ?? ?启用XX混音器 | enables muxer NAME
??--disable-muxers? ?? ?? ?禁用所有混音器 | disables all muxers
??--disable-demuxer=NAME? ?禁用XX解轨器 | disables demuxer NAME
??--enable-demuxer=NAME? ? 启用XX解轨器 | enables demuxer NAME
??--disable-demuxers? ?? ? 禁用所有解轨器 | disables all demuxers
??--enable-parser=NAME? ???启用XX剖析器 | enables parser NAME
??--disable-parser=NAME? ? 禁用XX剖析器 | disables parser NAME
??--disable-parsers? ?? ???禁用所有剖析器 | disables all parsers


8 参考资料

ffmpeg的编译大全
ffmpeg的使用
ffmpeg_mencoder环境搭建和视频处理总结
自译的ffmpeg ./configure参数<!--++ plugin_code qcomic begin-->

热点排行