转载自: 视频技术论坛 中华视频网ffmpeg工程组 http://bbs.chinavideo.org/archiver/?fid-10.html

先从ffmpeg开始。

http://ffmpeg.sourceforge.net/上有说明,音视频的分离,转换,解码的完全解决方案。
其中最重要的就是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帮忙解决。

NAME

ffmpeg - FFmpeg video converter 
SYNOPSIS

ffmpeg [[options][-i input_file]]... {[options] output_file}... 
DESCRIPTION

If no input file is given, audio/video grabbing is done.

As a general rule, options are applied to the next specified file. For example, if you give the -b 64 option, it sets the video bitrate of the next file. Format option may be needed for raw input files.

By default, ffmpeg tries to convert as losslessly as possible: it uses the same audio and video parameter for the outputs as the one specified for the inputs. 
OPTIONS

"Main options"

show license show help show available formats, codecs, protocols, ... force format input file name overwrite output files set the recording time in seconds. hh:mm:ss[.xxx] syntax is also supported. set the title set the author set the copyright set the comment activate high quality settings 
"Video Options"

set the video bitrate in kbit/s (default = 200 kb/s) set frame rate (default = 25) set frame size. The format is WxH (default 160x128).  The following abbreviations are recognized: 128x96 176x144 352x288 704x576 set aspect ratio (4:3, 16:9 or 1.3333, 1.7777) set top crop band size (in pixels) set bottom crop band size (in pixels) set left crop band size (in pixels) set right crop band size (in pixels) disable video recording set video bitrate tolerance (in kbit/s) set max video bitrate tolerance (in kbit/s) set min video bitrate tolerance (in kbit/s) set ratecontrol buffere size (in kbit) force video codec to codec. Use the copy special value to tell that the raw codec data must be copied as is. use same video quality as source (implies VBR) select the pass number (1 or 2). It is useful to do two pass encoding. The statistics of the video are recorded in the first pass and the video at the exact requested bit rate is generated in the second pass. select two pass log file name to file. 
"Advanced Video Options"

set the group of picture size use only intra frames use fixed video quantiser scale (VBR) min video quantiser scale (VBR) max video quantiser scale (VBR) max difference between the quantiser scale (VBR) video quantiser scale blur (VBR) video quantiser scale compression (VBR) initial complexity for 1-pass encoding qp factor between p and b frames qp factor between p and i frames qp offset between p and b frames qp offset between p and i frames set rate control equation. Default is tex^qComp. rate control override for specific intervals set motion estimation method to method. Available methods are (from lower to best quality): Try just the (0, 0) vector. (default method) exhaustive search (slow and marginally better than epzs) set dct algorithm to algo. Available values are: FF_DCT_AUTO (default) FF_DCT_FASTINT FF_DCT_INT FF_DCT_MMX FF_DCT_MLIB FF_DCT_ALTIVEC set idct algorithm to algo. Available values are: FF_IDCT_AUTO (default) FF_IDCT_INT           FF_IDCT_SIMPLE        FF_IDCT_SIMPLEMMX     FF_IDCT_LIBMPEG2MMX   FF_IDCT_PS2           FF_IDCT_MLIB          FF_IDCT_ARM           FF_IDCT_ALTIVEC       FF_IDCT_SH4           FF_IDCT_SIMPLEARM     set error resilience to n. FF_ER_CAREFULL (default) FF_ER_COMPLIANT FF_ER_AGGRESSIVE FF_ER_VERY_AGGRESSIVE set error concealment to bit_mask. bit_mask is a bit mask of the following values: FF_EC_GUESS_MVS (default=enabled) FF_EC_DEBLOCK (default=enabled) use "frames" B frames (only MPEG-4) macroblock decision FF_MB_DECISION_SIMPLE: use mb_cmp (cannot change it yet in ffmpeg) FF_MB_DECISION_BITS: chooses the one which needs the fewest bits FF_MB_DECISION_RD: rate distoration use four motion vector by macroblock (only MPEG-4) use data partitioning (only MPEG-4) workaround not auto detected encoder bugs how strictly to follow the standarts enable Advanced intra coding (h263+) enable Unlimited Motion Vector (h263+) deinterlace pictures calculate PSNR of compressed frames dump video coding statistics to vstats_HHMMSS.log. insert video processing module. module contains the module name and its parameters separated by spaces. 
"Audio Options"

set audio bitrate (in kbit/s) set the audio sampling freq (default = 44100 Hz) set the audio bitrate in kbit/s (default = 64) set the number of audio channels (default = 1) disable audio recording force audio codec to codec. Use the copy special value to tell that the raw codec data must be copied as is. 
"Audio/Video grab options"

set video grab device (e.g. /dev/video0) set video grab channel (DV1394 only) set television standard (NTSC, PAL (SECAM)) set DV1394 grab set audio device (e.g. /dev/dsp) 
"Advanced options"

set input stream mapping print specific debug info add timings for benchmarking dump each input packet only use bit exact algorithms (for codec testing) set packet size in bits read input at native frame rate. Mainly used to simulate a grab device. loop over the input stream. Currently it works only for image streams. This option is used for ffserver automatic testing. 
"FFmpeg formula evaluator"

When evaluating a rate control string, FFmpeg uses an internal formula evaluator.

The following binary operators are available: +, -, *, /, ^.

The following unary operators are available: +, -, (...).

The following functions are available:

The following constants are available: 
EXAMPLES

"Video and Audio grabbing"

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"

* ffmpeg can use any supported file format and protocol as input:

Examples:

* You can input from YUV files:

ffmpeg -i /tmp/test%d.Y /tmp/out.mpg

It will use the files: /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V, /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...

The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the -s option if ffmpeg cannot guess it.

* You can input from a RAW YUV420P file:

ffmpeg -i /tmp/test.yuv /tmp/out.avi

The RAW YUV420P is a file containing RAW YUV planar, for each frame first come the Y plane followed by U and V planes, which are half vertical and horizontal resolution.

* You can output to a RAW YUV420P file:

ffmpeg -i mydivx.avi -o hugefile.yuv

* You can set several input files and output files:

ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg

Convert the audio file a.wav and the raw yuv video file a.yuv to mpeg file a.mpg

* You can also do audio and video conversions at the same time:

ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2

Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.

* You can encode to several formats at the same time and define a mapping from input stream to output streams:

ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0

Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. "-map file:index" specify which input stream is used for each output stream, in the order of the definition of output streams.

* 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 MP3 audio, note that in this command we use B frames so the MPEG-4 stream is DivX5 compatible, GOP size is 300 that means an INTRA frame every 10 seconds for 29.97 fps input video.  Also the audio stream is MP3 encoded so you need LAME support which is enabled using --enable-mp3lame when configuring.  The mapping is particularly useful for DVD transcoding to get the desired audio language.

NOTE: to see the supported input formats, use ffmpeg -formats.

NAME

ffplay - FFplay media player 
SYNOPSIS

ffplay [options] input_file 
DESCRIPTION

FFplay is a very simple and portable media player using the FFmpeg libraries and the SDL library. It is mostly used as a test bench for the various APIs of FFmpeg. 
OPTIONS

"Main options"

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.

NAME

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

使用ffmpeg转换AVI到3GP命令行参数

ffmpeg -i test.avi -y -b 20 -s sqcif -r 10 -ab 23.85 -ac 1 -ar 8000 test.3gp
(以上参数由ffmpeg工程组 阳光白云 在QQ群中发布,特此感谢)

本文转自peterzb博客园博客,原文链接:http://www.cnblogs.com/peterzb/archive/2009/05/15/1458023.html,如需转载请自行联系原作者。

[转载]ffmpeg的使用相关推荐

  1. [转载] ffmpeg超详细综合教程——摄像头直播

    本文的示例将实现:读取PC摄像头视频数据并以RTMP协议发送为直播流.示例包含了 1.ffmpeg的libavdevice的使用 2.视频解码.编码.推流的基本流程 具有较强的综合性. 要使用liba ...

  2. [技术杂谈][转载]ffmpeg压缩视频几个参数解析

    Ffmpeg 视频压缩的几个关键参数 Ffmpeg的视频操作官网文档:FFmpeg Filters Documentation 视频压缩用到的参数主要为以下几个: 文件路径:-i 输入文件的路径 码率 ...

  3. 如何用FFmpeg编写一个简单播放器详细步骤介绍

    如何用FFmpeg编写一个简单播放器详细步骤介绍(转载) FFMPEG是一个很好的库,可以用来创建视频应用或者生成特定的工具.FFMPEG几乎为你把所有的繁重工作都做了,比如解码.编码.复用和解复用. ...

  4. android ffmpeg neno优化

    1. 前言 最近搞的视频监控项目,需要在android移动端做视频显示.用的是android ndk的开发方式, 利用ffmpeg作为解码库.640*480 分辨率下, 10帧每秒尚可正常播放, 但是 ...

  5. 大小端转换 int16 和int32

    int16 大小端转换: static inline uint16_t bswap_16(uint16_t x) {     return (x >> 8) | (x << 8 ...

  6. (转载)[FFmpeg]使用ffmpeg从各种视频文件中直接截取视频图片

    你曾想过从一个视频文件中提取图片吗?在Linux下就可以,在这个教程中我将使用ffmpeg来从视频中获取图片. 什么是ffmpeg?What is ffmpeg? ffmpeg是一个非常有用的命令行程 ...

  7. 【FFmpeg】FFmpeg常用基本命令(转载)

    转自:http://www.cnblogs.com/dwdxdy/p/3240167.html 1.分离视频音频流 ffmpeg -i input_file -vcodec copy -an outp ...

  8. 【转载】移植FFMpeg到VC环境心得

    原文地址:http://www.cnblogs.com/mcodec/articles/1659671.html 移植ffmpeg到windows,主要修改的是ffmpeg中VC6不支持的C99语法, ...

  9. 【FFmpeg】【转载】图像拼接:画中画连麦

    所谓画中画就是在一个视频里面再播放另一个小一点的视频.连麦是互动直播的一种产品形式,是在主播直播的时候,观众发起连线,其他观众能看到主播画面的右下角有连线观众的画面,同时听到主播和连线观众的语音. 转 ...

最新文章

  1. python列表按照批次分配数据(亲测)
  2. 家用电脑配置_家用电脑无需太高配置,不要听电脑店瞎忽悠,2500元机子够用了!...
  3. 选好财务软件做好企业管理
  4. nda协议_如何将NDA项目添加到您的投资组合
  5. Autodesk招聘开发咨询顾问(北京或上海),需要内推的扔简历过来啊
  6. 计算机操作员五级知识点,计算机操作员五级.doc
  7. Educational Codeforces Round 64 Div.2 D - 0-1-Tree
  8. 如何解决远程windows服务器安装matlab出现License Manager Error-103问题
  9. django高级应用(分页功能)
  10. 大数据工作由哪几部分组成
  11. shell 变量自增(转)
  12. 计算机领域CCF推荐会议列表
  13. verilog学习笔记——8位数码管驱动设计与验证
  14. 揭露培训机构以招聘名义变相招生的欺诈套路!【附上企业黑名单】
  15. win10无法装载重装系统iso文件_Win10系统如何装载和弹出ISO镜像文件?
  16. 《狂人日记》是中国第一部现代白话文小说
  17. 酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东
  18. Mac下安装MacPorts卡住了,“正在运行软件包脚本”,完美解决!
  19. MTK进入工程模式方法
  20. css小鸡破壳,小班美术教案《小鸡破壳》

热门文章

  1. 如何才能学好zbrush,成为3D建模大神,腾讯角色设计大佬给出的秘典
  2. 发现一个免费打网络电话的方法。
  3. python 实现图片加密
  4. 2019 CNCF的中国云原生调查报告
  5. 前端 vue 二维码解析工具
  6. Xshell6 中文不限时版下载(免密匙)
  7. Android原生开发--模拟器检测工具包
  8. PowerBuilder DeCompiler(PB DeCompiler) Demo download(PB反编译,支持5-12)
  9. freeswitch如何播放语音验证码(esl方式)
  10. 区块链公司谈区块链技术最新应用