基本選項:
-formats 輸出所有可用格式
-f fmt 指定格式(音頻或視頻格式)
-i filename 指定輸入文件名,在linux下當然也能指定:0.0(屏幕錄製)或攝像頭
-y 覆蓋已有文件
-t duration 記錄時長爲t
-fs limit_size 設置文件大小上限
-ss time_off 從指定的時間(s)開始, [-]hh:mm:ss[.xxx]的格式也支持
-itsoffset time_off 設置時間偏移(s),該選項影響所有後面的輸入文件。該偏移被加到輸入文件的時戳,定義一個正偏移意味着相應的流被延遲了 offset秒。 [-]hh:mm:ss[.xxx]的格式也支持
-title string 標題
-timestamp time 時間戳
-author string 作者
-copyright string 版權信息
-comment string 評論
-album string album名
-v verbose 與log相關的
-target type 設置目標文件類型("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)
-dframes number 設置要記錄的幀數
視頻選項:
-b 指定比特率(bits/s),似乎ffmpeg是自動VBR的,指定了就大概是平均比特率
-bitexact 使用標準比特率
-vb 指定視頻比特率(bits/s)
-vframes number 設置轉換多少楨(frame)的視頻
-r rate 幀速率(fps) (可以改,確認非標準楨率會導致音畫不同步,所以只能設定爲15或者29.97)
-s size 指定分辨率 (320x240)
-aspect aspect 設置視頻長寬比(4:3, 16:9 or 1.3333, 1.7777)
-croptop size 設置頂部切除尺寸(in pixels)
-cropbottom size 設置底部切除尺寸(in pixels)
-cropleft size 設置左切除尺寸 (in pixels)
-cropright size 設置右切除尺寸 (in pixels)
-padtop size 設置頂部補齊尺寸(in pixels)
-padbottom size 底補齊(in pixels)
-padleft size 左補齊(in pixels)
-padright size 右補齊(in pixels)
-padcolor color 補齊帶顏色(000000-FFFFFF)
-vn 取消視頻
-vcodec codec 強制使用codec編解碼方式('copy' to copy stream)
-sameq 使用同樣視頻質量作爲源(VBR)
-pass n 選擇處理遍數(1或者2)。兩遍編碼非常有用。第一遍生成統計信息,第二遍生成精確的請求的碼率
-passlogfile file 選擇兩遍的紀錄文件名爲file
-newvideo 在現在的視頻流後面加入新的視頻流
高級視頻選項 :
-pix_fmt format set pixel format, 'list' as argument shows all the pixel formats supported
-intra 僅適用幀內編碼
-qscale q 以<數值>質量爲基礎的VBR,取值0.01-255,約小質量越好
-loop_input 設置輸入流的循環數(目前只對圖像有效)
-loop_output 設置輸出視頻的循環數,比如輸出gif時設爲0表示無限循環
-g int 設置圖像組大小
-cutoff int 設置截止頻率
-qmin int 設定最小質量,與-qmax(設定最大質量)共用,比如-qmin 10 -qmax 31
-qmax int 設定最大質量
-qdiff int 量化標度間最大偏差 (VBR)
-bf int 使用frames B 幀,支持mpeg1,mpeg2,mpeg4
音頻選項:
-ab 設置比特率(單位:bit/s,也許老版是kb/s)前面-ac設爲立體聲時要以一半比特率來設置,比如192kbps的就設成96,轉換 默認比特率都較小,要聽到較高品質聲音的話建議設到160kbps(80)以上。
-aframes number 設置轉換多少楨(frame)的音頻
-aq quality 設置音頻質量 (指定編碼)
-ar rate 設置音頻採樣率 (單位:Hz),PSP只認24000
-ac channels 設置聲道數,1就是單聲道,2就是立體聲,轉換單聲道的TVrip可以用1(節省一半容量),高品質的DVDrip就可以用2
-an 取消音頻
-acodec codec 指定音頻編碼('copy' to copy stream)
-vol volume 設置錄製音量大小(默認爲256) <百分比> ,某些DVDrip的AC3軌音量極小,轉換時可以用這個提高音量,比如200就是原來的2倍
-newaudio 在現在的音頻流後面加入新的音頻流
字幕選項:
-sn 取消字幕
-scodec codec 設置字幕編碼('copy' to copy stream)
-newsubtitle 在當前字幕後新增
-slang code 設置字幕所用的ISO 639編碼(3個字母)
Audio/Video 抓取選項:
-vc channel 設置視頻捕獲通道(只對DV1394)
-tvstd standard 設置電視標準 NTSC PAL(SECAM)
要得到一個高畫質音質低容量的MP4的話,首先畫面最好不要用固定比特率,而用VBR參數讓程序自己去判斷,而音質參數可以在原來的基礎上提升一點,聽起來要舒服很多,也不會太大(看情況調整 )
轉換爲flv:
ffmpeg -i test.mp3 -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv
ffmpeg -i test.wmv -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv
轉換文件格式的同時抓縮微圖:
ffmpeg -i "test.avi" -y -f image2 -ss 8 -t 0.001 -s 350x240 'test.jpg'
對已有flv抓圖:
ffmpeg -i "test.flv" -y -f image2 -ss 8 -t 0.001 -s 350x240 'test.jpg'
轉換爲3gp:
ffmpeg -y -i test.mpeg -bitexact -vcodec h263 -b 128 -r 15 -s 176x144 -acodec aac -ac 2 -ar 22500 -ab 24 -f 3gp test.3gp
ffmpeg -y -i test.mpeg -ac 1 -acodec amr_nb -ar 8000 -s 176x144 -b 128 -r 15 test.3gp
例:ffmpeg -y -i "test.avi" -title "Test" -vcodec xvid -s 368x208 -r 29.97 - b 1500 -acodec aac -ac 2 -ar 24000 -ab 128 -vol 200 -f psp -muxvb 768 "test.***"
# 參數解釋:
-y(覆蓋輸出文件,即如果1.***文件已經存在的話,不經提示就覆蓋掉了)
-i "1.avi"(輸入文件是和ffmpeg在同一目錄下的1.avi文件,可以自己加路徑,改名字)
-title "Test"(在PSP中顯示的影片的標題)
-vcodec xvid(使用XVID編碼壓縮視頻,不能改的)
-s 368x208(輸出的分辨率爲368x208,注意片源一定要是16:9的不然會變形)
-r 29.97(幀數,一般就用這個吧)
-b 1500(視頻數據流量,用-b xxxx的指令則使用固定碼率,數字隨便改,1500以上沒效果;還可以用動態碼率如:-qscale 4和-qscale 6,4的質量比6高)
-acodec aac(音頻編碼用AAC)
-ac 2(聲道數1或2)
-ar 24000(聲音的採樣頻率,好像PSP只能支持24000Hz)
-ab 128(音頻數據流量,一般選擇32、64、96、128)
-vol 200(200%的音量,自己改)
-f psp(輸出psp專用格式)
-muxvb 768(好像是給PSP機器識別的碼率,一般選擇384、512和768,我改成1500,PSP就說文件損壞了)
"test.***"(輸出文件名,也可以加路徑改文件名)
用-ss指定開始時間,用hh:mm:ss[.ms]格式,或者換算成用秒計。
用-t指定長度,和-ss的格式一樣,用hh:mm:ss[.ms]格式,或者換算成用秒計。
如果-ss放在-i之前,就會成爲輸入選項,會先跳轉過去。如果-i放在輸出文件前面,則會成爲輸出選項,ffmpeg會先解碼到給定時間,再開始編碼行爲,這樣做會比較慢,但更精確。
如果想用這個方法無損分割(用-codec copy),是不一定能切準的。
各種濾鏡:
Filters:
A = Audio input/output
V = Video input/output
N = Dynamic number and/or type of input/output
| = Source or sink filter
aconvert A->A Convert the input audio to sample_fmt:channel_layout
.
afade A->A Fade in/out input audio.
aformat A->A Convert the input audio to one of the specified form
ats.
ainterleave N->A Temporally interleave audio inputs.
allpass A->A Apply a two-pole all-pass filter.
amerge N->A Merge two or more audio streams into a single multi-
channel stream.
amix N->A Audio mixing.
anull A->A Pass the source unchanged to the output.
apad A->A Pad audio with silence.
aperms A->A Set permissions for the output audio frame.
aphaser A->A Add a phasing effect to the audio.
aresample A->A Resample audio data.
aselect A->N Select audio frames to pass in output.
asendcmd A->A Send commands to filters.
asetnsamples A->A Set the number of samples for each output audio fram
es.
asetpts A->A Set PTS for the output audio frame.
asetrate A->A Change the sample rate without altering the data.
asettb A->A Set timebase for the audio output link.
ashowinfo A->A Show textual information for each audio frame.
asplit A->N Pass on the audio input to N audio outputs.
astats A->A Show time domain statistics about audio frames.
astreamsync AA->AA Copy two streams of audio data in a configurable ord
er.
atempo A->A Adjust audio tempo.
bandpass A->A Apply a two-pole Butterworth band-pass filter.
bandreject A->A Apply a two-pole Butterworth band-reject filter.
bass A->A Boost or cut lower frequencies.
biquad A->A Apply a biquad IIR filter with the given coefficient
s.
channelmap A->A Remap audio channels.
channelsplit A->N Split audio into per-channel streams.
earwax A->A Widen the stereo image.
ebur128 A->N EBU R128 scanner.
equalizer A->A Apply two-pole peaking equalization (EQ) filter.
highpass A->A Apply a high-pass filter with 3dB point frequency.
join N->A Join multiple audio streams into multi-channel outpu
t.
lowpass A->A Apply a low-pass filter with 3dB point frequency.
pan A->A Remix channels with coefficients (panning).
silencedetect A->A Detect silence.
treble A->A Boost or cut upper frequencies.
volume A->A Change input volume.
volumedetect A->A Detect audio volume.
aevalsrc |->A Generate an audio signal generated by an expression.
anullsrc |->A Null audio source, return empty audio frames.
sine |->A Generate sine wave audio signal.
anullsink A->| Do absolutely nothing with the input audio.
alphaextract V->V Extract an alpha channel as a grayscale image compon
ent.
alphamerge VV->V Copy the luma value of the second input into the alp
ha channel of the first input.
ass V->V Render ASS subtitles onto input video using the liba
ss library.
bbox V->V Compute bounding box for each frame.
blackdetect V->V Detect video intervals that are (almost) black.
blackframe V->V Detect frames that are (almost) black.
blend VV->V Blend two video frames into each other.
boxblur V->V Blur the input.
colorbalance V->V Adjust the color balance.
colorchannelmixer V->V Adjust colors by mixing color channels.
colormatrix V->V Convert color matrix.
copy V->V Copy the input video unchanged to the output.
crop V->V Crop the input video to width:height:x:y.
cropdetect V->V Auto-detect crop size.
curves V->V Adjust components curves.
decimate N->V Decimate frames (post field matching filter).
delogo V->V Remove logo from input video.
deshake V->V Stabilize shaky video.
drawbox V->V Draw a colored box on the input video.
drawtext V->V Draw text on top of video frames using libfreetype l
ibrary.
edgedetect V->V Detect and draw edge.
fade V->V Fade in/out input video.
field V->V Extract a field from the input video.
fieldmatch N->V Field matching for inverse telecine.
fieldorder V->V Set the field order.
format V->V Convert the input video to one of the specified pixe
l formats.
fps V->V Force constant framerate.
framestep V->V Select one frame every N frames.
frei0r V->V Apply a frei0r effect.
geq V->V Apply generic equation to each pixel.
gradfun V->V Debands video quickly using gradients.
hflip V->V Horizontally flip the input video.
histeq V->V Apply global color histogram equalization.
histogram V->V Compute and draw a histogram.
hqdn3d V->V Apply a High Quality 3D Denoiser.
hue V->V Adjust the hue and saturation of the input video.
idet V->V Interlace detect Filter.
il V->V Deinterleave or interleave fields.
interlace V->V Convert progressive video into interlaced.
interleave N->V Temporally interleave video inputs.
kerndeint V->V Apply kernel deinterlacing to the input.
lut V->V Compute and apply a lookup table to the RGB/YUV inpu
t video.
lutrgb V->V Compute and apply a lookup table to the RGB input vi
deo.
lutyuv V->V Compute and apply a lookup table to the YUV input vi
deo.
mp V->V Apply a libmpcodecs filter to the input video.
mpdecimate V->V Remove near-duplicate frames.
negate V->V Negate input video.
noformat V->V Force libavfilter not to use any of the specified pi
xel formats for the input to the next filter.
noise V->V Add noise.
null V->V Pass the source unchanged to the output.
overlay VV->V Overlay a video source on top of the input.
pad V->V Pad input image to width:height[:x:y[:color]] (defau
lt x and y: 0, default color: black).
perms V->V Set permissions for the output video frame.
pixdesctest V->V Test pixel format definitions.
pp V->V Filter video using libpostproc.
removelogo V->V Remove a TV logo based on a mask image.
scale V->V Scale the input video to width:height size and/or co
nvert the image format.
select V->N Select video frames to pass in output.
sendcmd V->V Send commands to filters.
separatefields V->V Split input video frames into fields.
setdar V->V Set the frame display aspect ratio.
setfield V->V Force field for the output video frame.
setpts V->V Set PTS for the output video frame.
setsar V->V Set the pixel sample aspect ratio.
settb V->V Set timebase for the video output link.
showinfo V->V Show textual information for each video frame.
smartblur V->V Blur the input video without impacting the outlines.
split V->N Pass on the input video to N outputs.
stereo3d V->V Convert video stereoscopic 3D view.
subtitles V->V Render text subtitles onto input video using the lib
ass library.
super2xsai V->V Scale the input by 2x using the Super2xSaI pixel art
algorithm.
swapuv V->V Swap U and V components.
telecine V->V Apply a telecine pattern.
thumbnail V->V Select the most representative frame in a given sequ
ence of consecutive frames.
tile V->V Tile several successive frames together.
tinterlace V->V Perform temporal field interlacing.
transpose V->V Transpose input video.
unsharp V->V Sharpen or blur the input video.
vflip V->V Flip the input video vertically.
yadif V->V Deinterlace the input image.
cellauto |->V Create pattern generated by an elementary cellular a
utomaton.
color |->V Provide an uniformly colored input.
frei0r_src |->V Generate a frei0r source.
life |->V Create life.
mandelbrot |->V Render a Mandelbrot fractal.
mptestsrc |->V Generate various test pattern.
nullsrc |->V Null video source, return unprocessed video frames.
rgbtestsrc |->V Generate RGB test pattern.
smptebars |->V Generate SMPTE color bars.
smptehdbars |->V Generate SMPTE HD color bars.
testsrc |->V Generate test pattern.
nullsink V->| Do absolutely nothing with the input video.
concat N->N Concatenate audio and video streams.
showspectrum A->V Convert input audio to a spectrum video output.
showwaves A->V Convert input audio to a video output.
amovie |->N Read audio from a movie source.
movie |->N Read from a movie source.
ffbuffersink V->| Buffer video frames, and make them available to the
end of the filter graph.
ffabuffersink A->| Buffer audio frames, and make them available to the
end of the filter graph.
abuffer |->A Buffer audio frames, and make them accessible to the
filterchain.
buffer |->V Buffer video frames, and make them accessible to the
filterchain.
abuffersink A->| Buffer audio frames, and make them available to the
end of the filter graph.
buffersink V->| Buffer video frames, and make them available to the
end of the filter graph.
afifo A->A Buffer input frames and send them when they are requ
ested.
fifo V->V Buffer input images and send them when they are requ
ested.