Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3010249
  • 博文数量: 674
  • 博客积分: 17881
  • 博客等级: 上将
  • 技术积分: 4849
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-17 10:15
文章分类

全部博文(674)

文章存档

2013年(34)

2012年(146)

2011年(197)

2010年(297)

分类: LINUX

2010-07-06 06:48:05

ffmpeg命令行参数设定解说

ffmpeg参数设定解说
-bitexact 使用标准比特率
-vcodec xvid 使用xvid压缩
-s 320x240 指定分辨率
-r 29.97 桢速率(可以改,确认非标准桢率会导致音画不同步,所以只能设定为15或者29.97)
画面部分,选其一
-b <比特率> 指定压缩比特率,似乎ffmpeg是自动VBR的,指定了就大概是平均比特率,比如768,1500这样的就是原来默认项目中有的
-qscale <数值> 以<数值>质量为基础的VBR,取值0.01-255,约小质量越好
-qmin <数值> 设定最小质量,与-qmax(设定最大质量)共用,比如-qmin 10 -qmax 31
-sameq 使用和源同样的质量

声音部分
-acodec aac 设定声音编码
-ac <数值> 设定声道数,1就是单声道,2就是立体声,转换单声道的TVrip可以用1(节省一半容量),高品质的DVDrip就可以用2
-ar <采样率> 设定声音采样率,PSP只认24000
-ab <比特率> 设定声音比特率,前面-ac设为立体声时要以一半比特率来设置,比如192kbps的就设成96,转换君默认比特率都较小,要听到较高品质声音的话建议设到160kbps(80)以上
-vol <百分比> 设定音量,某些DVDrip的AC3轨音量极小,转换时可以用这个提高音量,比如200就是原来的2倍

这样,要得到一个高画质音质低容量的MP4的话,首先画面最好不要用固定比特率,而用VBR参数让程序自己去判断,而音质参数可以在原来的基础上提升一点,听起来要舒服很多,也不会太大(看情况调整)

//----------------------------------

ffmpeg的使用[zt]

先从ffmpeg开始。
上有说明,音视频的分离,转换,解码的完全解决方案。
其中最重要的就是libavcodec库。它被mplayer或者xine使用作为解码器。还有,国内比较流行的播放器影音风暴或MyMPC的后端ffdshow也是使用ffmpeg的解码库的。

ffmpeg包括一组软件,ffmpeg用于对媒体文件进行处理,ffserver是一个http的流媒体服务器,ffplay是一个基于SDL的简单播放器。两个库文件libavcodec和libavformat。

ffmpeg作为媒体文件处理软件,基本用法如下:
ffmpeg -i INPUTfile [OPTIONS] OUTPUTfile
输入输出文件通常就是待处理的多媒体文件了。可以是纯粹的音频文件,纯粹的视频文件,或者混合的。
大部分常见的格式都能够“通杀”。象常见的各种mpeg,AVI封装的DIVX和Xvid等等
具体的格式支持列表可以使用ffmpeg -formats查看或直接查阅文档。

另:由于Linux把设备视为文件,因此-i选项后可以跟设备名。比如DV,视频卡,光驱或者其它的各类设备。
输出的内容通过Options调整。列出几个主要的选项
-vcodec 视频流编码方式
-b 视频流码率(默认只有200k,一般都需要手动设置,具体的数值视codec选择而定)
-r 视频流帧数(一般说来PAL制式通常用25,NTSC制式通常用29)
-s 视频解析度(分辨率,也要视codec和你的需要而定。通常改变某个视频流的解析度是很耗费CPU的事情。另:具体写法使用“数字x数字”的形式。中间是小写字母“x”,这个用过mplayer的应该都知道)
-t 处理持续时间。
-acodec 音频流编码方式
-ab 音频流码率(默认是同源文件码率,也需要视codec而定)
-ar 音频流采样率(大多数情况下使用44100和48000,分别对应PAL制式和NTSC制式,根据需要选择)

还有些可能需要用到的选项如
-vn和-an分别是屏蔽视频流和屏蔽音频流,分别对源文件处理一次即可得到分离的音频和视频
-author -title分别是设置媒体文件的作者和title
-f选项是强制使用某种格式
-target type是使用预置的格式转换(可以转成dvd,vcd或svcd)

除此之外还有些更高级的选项,如设定vbr,或设定high quality,或者设定vbr的buff和max/min码率,象一般我们自用的dvd抓轨啦,DV转vcd或dvd啦,网上下载的电影转成vcd或dvd都不一定需要用到它们。
具体的使用方法在man里面有介绍。简单明了。

少许使用经验:
1:ffmpeg对于rm的处理能力实在不敢恭维。也许是因为我主要使用二进制包安装的缘故,对于Real媒体格式只能处理老式的RV8编码的格式。而且效果不佳。
2:格式转换是一件很耗费CPU资源的事情。虽说ffmpeg已经比WinAVI啦,TmpgEnc这些win下的非专业级视频处理软件做的好些了。毕竟我们可以把ffmpeg运行的时候放到后台。
3:ffmpeg不是万能的,虽说支持的格式很多,但是如果你不是用的最新CVS出来的版本,可能碰上某些古怪的媒体文件就要郁闷。
4:ffmpeg全部是命令行操作。哪位达人写个GUI前端出来就可以让不少菜鸟脱离苦海了。还有就是不能批量处理,但是这个可以用shell帮忙解决。
//-------------------------

出现找不到lame的问题时,把libmp3lame-0.dll复制下就可以

//--------------------------------------------------------------------------------------------------------

下面为ffmpeg-0.4.9-p20051216的输出帮助文档:

ffmpeg version CVS, build 3342336, Copyright (c) 2000-2004 Fabrice Bellard
  configuration:  --enable-memalign-hack --enable-mingw32 --enable-mp3lame --
ra-cflags=-I/local/include --extra-ldflags=-L/local/lib
  built on Jul 28 2006 14:50:53, gcc: 3.2.3 (mingw special 20030504-1)
usage: ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...
Hyper fast Audio and Video encoder

Main options:
-L                  show license
-h                  show help
-version            show version
-formats            show available formats, codecs, protocols, ...
-f fmt              force format
-img img_fmt        force image format
-i filename         input file name
-y                  overwrite output files
-t duration         set the recording time
-fs limit_size      set the limit file size
-ss time_off        set the start time offset
-itsoffset time_off  set the input ts offset
-title string       set the title
-timestamp time     set the timestamp
-author string      set the author
-copyright string   set the copyright
-comment string     set the comment
-v verbose          control amount of logging
-target type        specify target file type ("vcd", "svcd", "dvd", "dv", "pa
cd", "ntsc-svcd", ...)
-dframes number     set the number of data frames to record
-scodec codec       force subtitle codec ('copy' to copy stream)
-newsubtitle        add a new subtitle stream to the current output stream
-slang code         set the ISO 639 language code (3 letters) of the current
title stream

Video options:
-b bitrate          set video bitrate (in kbit/s)
-vframes number     set the number of video frames to record
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-croptop size       set top crop band size (in pixels)
-cropbottom size    set bottom crop band size (in pixels)
-cropleft size      set left crop band size (in pixels)
-cropright size     set right crop band size (in pixels)
-padtop size        set top pad band size (in pixels)
-padbottom size     set bottom pad band size (in pixels)
-padleft size       set left pad band size (in pixels)
-padright size      set right pad band size (in pixels)
-padcolor color     set color of pad bands (Hex 000000 thru FFFFFF)
-vn                 disable video
-bt tolerance       set video bitrate tolerance (in kbit/s)
-maxrate bitrate    set max video bitrate tolerance (in kbit/s)
-minrate bitrate    set min video bitrate tolerance (in kbit/s)
-bufsize size       set ratecontrol buffer size (in kByte)
-vcodec codec       force video codec ('copy' to copy stream)
-sameq              use same video quality as source (implies VBR)
-pass n             select the pass number (1 or 2)
-passlogfile file   select two pass log file name
-newvideo           add a new video stream to the current output stream

Advanced Video options:
-pix_fmt format     set pixel format
-g gop_size         set the group of picture size
-intra              use only intra frames
-vdt n              discard threshold
-qscale q           use fixed video quantiser scale (VBR)
-qmin q             min video quantiser scale (VBR)
-qmax q             max video quantiser scale (VBR)
-lmin lambda        min video lagrange factor (VBR)
-lmax lambda        max video lagrange factor (VBR)
-mblmin q           min macroblock quantiser scale (VBR)
-mblmax q           max macroblock quantiser scale (VBR)
-qdiff q            max difference between the quantiser scale (VBR)
-qblur blur         video quantiser scale blur (VBR)
-qsquish squish     how to keep quantiser between qmin and qmax (0 = clip, 1
se differentiable function)
-qcomp compression  video quantiser scale compression (VBR)
-rc_init_cplx complexity  initial complexity for 1-pass encoding
-b_qfactor factor   qp factor between p and b frames
-i_qfactor factor   qp factor between p and i frames
-b_qoffset offset   qp offset between p and b frames
-i_qoffset offset   qp offset between p and i frames
-ibias bias         intra quant bias
-pbias bias         inter quant bias
-rc_eq equation     set rate control equation
-rc_override override  rate control override for specific intervals
-me method          set motion estimation method
-me_threshold       motion estimaton threshold
-mb_threshold       macroblock threshold
-bf frames          use 'frames' B frames
-preme              pre motion estimation
-bug param          workaround not auto detected encoder bugs
-strict strictness  how strictly to follow the standards
-deinterlace        deinterlace pictures
-psnr               calculate PSNR of compressed frames
-vstats             dump video coding statistics to file
-vhook module       insert video processing module
-intra_matrix matrix  specify intra matrix coeffs
-inter_matrix matrix  specify inter matrix coeffs
-top                top=1/bottom=0/auto=-1 field first
-sc_threshold threshold  scene change threshold
-me_range range     limit motion vectors range (1023 for DivX player)
-dc precision       intra_dc_precision
-mepc factor (1.0 = 256)  motion estimation bitrate penalty compensation
-vtag fourcc/tag    force video tag/fourcc
-skip_threshold threshold  frame skip threshold
-skip_factor factor  frame skip factor
-skip_exp exponent  frame skip exponent
-genpts             generate pts

Audio options:
-aframes number     set the number of audio frames to record
-ab bitrate         set audio bitrate (in kbit/s)
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-newaudio           add a new audio stream to the current output stream
-alang code         set the ISO 639 language code (3 letters) of the current aud
io stream

Advanced Audio options:
-atag fourcc/tag    force audio tag/fourcc

Subtitle options:
-scodec codec       force subtitle codec ('copy' to copy stream)
-newsubtitle        add a new subtitle stream to the current output stream
-slang code         set the ISO 639 language code (3 letters) of the current sub
title stream

Audio/Video grab options:
-vd device          set video grab device
-vc channel         set video grab channel (DV1394 only)
-tvstd standard     set television standard (NTSC, PAL (SECAM))
-ad device          set audio device
-grab format        request grabbing using
-gd device          set grab device

Advanced options:
-map file:stream[:syncfile:syncstream]  set input stream mapping
-map_meta_data outfile:infile  set meta data information of outfile from infile
-benchmark          add timings for benchmarking
-dump               dump each input packet
-hex                when dumping packets, also dump the payload
-re                 read input at native frame rate
-loop               loop (current only works with images)
-loop_output        number of times to loop output in formats that support loopi
ng (0 loops forever)
-threads count      thread count
-vsync              video sync method
-async              audio sync method
-vglobal            video global header storage type
-copyts             copy timestamps
-shortest           finish encoding within shortest input
-b_strategy strategy  dynamic b frame selection strategy
-ps size            set packet size in bits
-error rate         error rate
-muxrate rate       set mux rate
-packetsize size    set packet size
-muxdelay seconds   set the maximum demux-decode delay
-muxpreload seconds  set the initial demux-decode delay
AVCodecContext AVOptions:
-bit_rate          E.VA.
-bit_rate_tolerance E.V..
-flags             EDVA.
-mv4               E.V.. use four motion vector by macroblock (mpeg4)
-obmc              E.V.. use overlapped block motion compensation (h263+)
-qpel              E.V.. use 1/4 pel motion compensation
-loop              E.V.. use loop filter
-gmc               E.V.. use gmc
-mv0               E.V.. always try a mb with mv=<0,0>
-part              E.V.. use data partitioning
-gray              EDV.. only decode/encode grayscale
-psnr              E.V.. error[?] variables will be set during encoding
-naq               E.V.. normalize adaptive quantization
-ildct             E.V.. use interlaced dct
-low_delay         .DV.. force low delay
-alt               E.V.. enable alternate scantable (mpeg2/mpeg4)
-trell             E.V.. use trellis quantization
-bitexact          EDVAS use only bitexact stuff (except (i)dct)
-aic               E.V.. h263 advanced intra coding / mpeg4 ac prediction
-umv               E.V.. use unlimited motion vectors
-cbp               E.V.. use rate distortion optimization for cbp
-qprd              E.V.. use rate distortion optimization for qp selection
-aiv               E.V.. h263 alternative inter vlc
-slice             E.V..
-ilme              E.V.. interlaced motion estimation
-scan_offset       E.V.. will reserve space for svcd scan offset user data
-cgop              E.V.. closed gop
-fast              E.V.. allow non spec compliant speedup tricks
-sgop              E.V.. strictly enforce gop size
-noout             E.V.. skip bitstream encoding
-local_header      E.V.. place global headers at every keyframe instead of in ex
tradata
-me_method         E.V..
-gop_size          E.V..
-qcompress         E.V..
-qblur             E.V..
-qmin              E.V..
-qmax              E.V..
-max_qdiff         E.V..
-max_b_frames      E.V..
-b_quant_factor    E.V..
-rc_strategy       E.V..
-b_frame_strategy  E.V..
-hurry_up          .DV..
-bugs              .DV..
-autodetect        .DV..
-old_msmpeg4       .DV..
-xvid_ilace        .DV..
-ump4              .DV..
-no_padding        .DV..
-amv               .DV..
-ac_vlc            .DV..
-qpel_chroma       .DV..
-std_qpel          .DV..
-qpel_chroma2      .DV..
-direct_blocksize  .DV..
-edge              .DV..
-hpel_chroma       .DV..
-dc_clip           .DV..
-ms                .DV..
-lelim             E.V.. single coefficient elimination threshold for luminance
(negative values also consider dc coefficient)
-celim             E.V.. single coefficient elimination threshold for chrominanc
e (negative values also consider dc coefficient)
-strict            E.V..
-very              E.V..
-strict            E.V..
-normal            E.V..
-inofficial        E.V..
-experimental      E.V..
-b_quant_offset    E.V..
-er                .DV..
-careful           .DV..
-compliant         .DV..
-aggressive        .DV..
-very_aggressive   .DV..
-mpeg_quant        E.V..
-rc_qsquish        E.V..
-rc_qmod_amp       E.V..
-rc_qmod_freq      E.V..
-rc_eq             E.V..
-rc_max_rate       E.V..
-rc_min_rate       E.V..
-rc_buffer_size    E.V..
-rc_buf_aggressivity E.V..
-i_quant_factor    E.V..
-i_quant_offset    E.V..
-rc_initial_cplx   E.V..
-dct               E.V..
-auto              E.V..
-fastint           E.V..
-int               E.V..
-mmx               E.V..
-mlib              E.V..
-altivec           E.V..
-faan              E.V..
-lumi_mask         E.V.. lumimasking
-tcplx_mask        E.V.. temporal complexity masking
-scplx_mask        E.V.. spatial complexity masking
-p_mask            E.V.. inter masking
-dark_mask         E.V.. darkness masking
-idct              EDV..
-auto              EDV..
-int               EDV..
-simple            EDV..
-simplemmx         EDV..
-libmpeg2mmx       EDV..
-ps2               EDV..
-mlib              EDV..
-arm               EDV..
-altivec           EDV..
-sh4               EDV..
-simplearm         EDV..
-h264              EDV..
-vp3               EDV..
-ipp               EDV..
-xvidmmx           EDV..
-ec                .DV..
-guess_mvs         .DV..
-deblock           .DV..
-pred              E.V.. prediction method
-left              E.V..
-plane             E.V..
-median            E.V..
-aspect            E.V..
-debug             EDVAS print specific debug info
-pict              .DV..
-rc                E.V..
-bitstream         .DV..
-mb_type           .DV..
-qp                .DV..
-mv                .DV..
-dct_coeff         .DV..
-skip              .DV..
-startcode         .DV..
-pts               .DV..
-er                .DV..
-mmco              .DV..
-bugs              .DV..
-vis_qp            .DV..
-vis_mb_type       .DV..
-vismv             .DV.. visualize motion vectors
-pf                .DV..
-bf                .DV..
-bb                .DV..
-mb_qmin           E.V..
-mb_qmax           E.V..
-cmp               E.V.. full pel me compare function
-subcmp            E.V.. sub pel me compare function
-mbcmp             E.V.. macroblock compare function
-ildctcmp          E.V.. interlaced dct compare function
-dia_size          E.V..
-last_pred         E.V..
-preme             E.V..
-precmp            E.V.. pre motion estimation compare function
-sad               E.V..
-sse               E.V..
-satd              E.V..
-dct               E.V..
-psnr              E.V..
-bit               E.V..
-rd                E.V..
-zero              E.V..
-vsad              E.V..
-vsse              E.V..
-nsse              E.V..
-w53               E.V..
-w97               E.V..
-dctmax            E.V..
-chroma            E.V..
-pre_dia_size      E.V..
-subq              E.V.. sub pel motion estimation quality
-me_range          E.V..
-ibias             E.V..
-pbias             E.V..
-coder             E.V..
-vlc               E.V.. variable length coder / huffman coder
-ac                E.V.. arithmetic coder
-context           E.V.. context model
-mbd               E.V..
-simple            E.V..
-bits              E.V..
-rd                E.V..
-sc_threshold      E.V..
-lmin              E.V.. min lagrange factor
-lmax              E.V.. max lagrange factor
-nr                E.V.. noise reduction
-rc_init_occupancy E.V..
-inter_threshold   E.V..
-antialias         .DV..
-auto              .DV..
-fastint           .DV..
-int               .DV..
-float             .DV..
-qns               E.V.. quantizer noise shaping
-thread_count      EDV..
-dc                E.V..
-nssew             E.V.. nsse weight
-skip_top          .DV..
-skip_bottom       .DV..
-profile           E.VA.
-unknown           E.VA.
-level             E.VA.
-unknown           E.VA.
-lowres            .DV..
-frame_skip_threshold E.V..
-frame_skip_factor E.V..
-frame_skip_exp    E.V..
-skipcmp           E.V.. frame skip compare function
-border_mask       E.V..
-mb_lmin           E.V..
-mb_lmax           E.V..
-me_penalty_compensation E.V..
阅读(3675) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~