PTS:Presentation Time Stamp。PTS主要用於度量解碼後的視頻幀什麼時候被顯示出來
DTS:Decode Time Stamp。DTS主要是標識讀入內存中的 bitstream 流在什麼時候開始送入解碼器中進行解碼
也就是pts反映幀什麼時候開始顯示,dts反映數據流什麼時候開始解碼
BB 發表在 痞客邦 留言(0) 人氣(2,571)
REF: wanglongqi.github.io/tools/2015/02/13/ffmpegcn/
1. 概要
ffmpeg [global_options] {[input_file_options] -i INPUT_FILE} ... {[output_file_options] OUTPUT_FILE} ...
BB 發表在 痞客邦 留言(0) 人氣(2,106)
在 Ubuntu 13 以後, FFmpeg 以經被 libav 取代.
在官方提供的軟體庫沒有辨法再簡單的 sudo apt-get install ffmpeg 了.
新的 libav-tools 套件也用 avconv 執行程式來取代原有的 ffmpeg.
在 Ubuntu 14 之後,ffmpeg 已經完全不支援了. (其實ffmpeg也沒有被淘汏).
如果想省去麻煩,可以參考以下的簡單方法來加入PPA (Personal Package Archives)的程式庫就可以直接安裝 FFmpeg 了.
BB 發表在 痞客邦 留言(0) 人氣(3,514)
FFMPEG編譯參數解析
1 Standard options: 基本選項參數
2 --help 顯示此幫助信息|print this message
3 --log[=FILE|yes|no] 記錄測試並輸出到config.err文件|log tests and output to FILE [config.err]
4 --prefix=PREFIX 安裝程序到指定目錄(默認/usr/local)|install in PREFIX [/usr/local]
5 --libdir=DIR 安裝庫到指定目錄(默認prefix/lib)|install libs in DIR [PREFIX/lib]
6 --shlibdir=DIR 指定共享庫路徑(默認prefix/lib)|install shared libs in DIR [PREFIX/lib]
7 --incdir=DIR 指定includes路徑(默認prefix/include/ffmpeg)|install includes in DIR[PREFIX/include/ffmpeg]
8 --mandir=DIR 指定man page路徑(默認prefix/man)install man page in DIR [PREFIX/man]
9 --enable-mp3lame 啟用mp3編碼libmp3lame(默認關閉)enable MP3 encoding via libmp3lame[default=no]
10 --enable-libogg 啟用ogg支持libogg(默認關閉)enable Ogg support via libogg [default=no]
11 --enable-vorbis 啟用Vorbis支持libvorbis(默認關閉)enable Vorbis support via libvorbis [default=no]
12 --enable-faad 啟用faad支持libfaad(默認關閉)enable FAAD support via libfaad [default=no]
13 --enable-faadbin 啟用faad運行時連結支持(默認關閉)build FAAD support with runtime linking[default=no]
14 --enable-faac 啟用faac支持libfaac(默認關閉)enable FAAC support via libfaac [default=no]
15 --enable-libgsm 啟用GSM支持libgsm(默認關閉)enable GSM support via libgsm [default=no]
16 --enable-xvid 啟用xvid支持xvidcore(默認關閉)enable XviD support via xvidcore [default=no]
17 --enable-x264 啟用H.264編碼(默認關閉)enable H.264 encoding via x264 [default=no]
18 --enable-mingw32 啟用MinGW本地/交叉win環境編譯|enable MinGW native/cross Windows compile
19 --enable-mingwce 啟用MinGW本地/交叉winCE環境編譯enable MinGW native/cross WinCE compile
20 --enable-a52 啟用A52支持(默認關閉)enable GPLed A52 support [default=no]
21 --enable-a52bin 啟用運行時打開liba52.so.0(默認關閉)open liba52.so.0 at runtime [default=no]
22 --enable-dts 啟用DTS支持(默認關閉)enable GPLed DTS support [default=no]
23 --enable-pp 啟用後加工支持(默認關閉)enable GPLed postprocessing support [default=no]
24 --enable-static 構建靜態庫(默認啟用)build static libraries [default=yes]
25 --disable-static 禁止構建靜態庫(默認關閉)do not build static libraries [default=no]
26 --enable-shared 構建共享庫(默認關閉)build shared libraries [default=no]
27 --disable-shared 禁止構建共享庫(默認啟用)do not build shared libraries [default=yes]
28 --enable-amr_nb 啟用amr_nb float音頻編解碼器|enable amr_nb float audio codec
29 --enable-amr_nb-fixed 啟用fixed amr_nb codec | use fixed point for amr-nb codec
30 --enable-amr_wb 啟用amr_wb float音頻編解碼器|enable amr_wb float audio codec
31 --enable-amr_if2 啟用amr_wb IF2音頻編解碼器|enable amr_wb IF2 audio codec
32 --enable-sunmlib 啟用Sun medialib(默認關閉) | use Sun medialib [default=no]
33 --enable-pthreads 啟用pthreads(多線程)(默認關閉)use pthreads [default=no]
34 --enable-dc1394 啟用libdc1394、libraw1394抓取IIDC-1394(默認關閉)enable IIDC-1394 grabbing using libdc1394 and libraw1394 [default=no]
35 --enable-swscaler 啟用計數器支持?(默認關閉)software scaler support [default=no]
36 --enable-avisynth 允許讀取AVISynth腳本本件(默認關閉)allow reading AVISynth script files [default=no]
37 --enable-gpl 允許使用GPL(默認關閉)allow use of GPL code, the resulting libav* and ffmpeg will be under GPL [default=no]
38 Advanced options (experts only): 高級選項參數(供專業人員使用)
39 --source-path=PATH 源碼的路徑(當前為/root/flv/ffmpeg)| path to source code [/root/flv/ffmpeg]
40 --cross-prefix=PREFIX 為編譯工具指定路徑 | use PREFIX for compilation tools []
41 --cross-compile 假定使用了交叉編譯 | assume a cross-compiler is used
42 --cc=CC 指定使用何種C編譯器(默認gcc)use C compiler CC [gcc]
43 --make=MAKE 使用特定的make | use specified make [make]
44 --extra-cflags=ECFLAGS 添加ECFLAGS到CFLAGS | add ECFLAGS to CFLAGS []
45 --extra-ldflags=ELDFLAGS 添加ELDFLAGS到LDFLAGS(默認-Wl,--as-needed)| add ELDFLAGS to LDFLAGS [ -Wl,--as-needed]
46 --extra-libs=ELIBS 添加ELIBS | add ELIBS []
47 --build-suffix=SUFFIX 為專用程序添加尾碼 | suffix for application specific build []
48 --arch=ARCH 選擇機器架構(默認x86)select architecture [x86]
49 --cpu=CPU 選用最低的cpu(影響指令的選擇,可以在老CPU上出錯) | selects the minimum cpu required (affects instruction selection, may crash on older CPUs)
50 --powerpc-perf-enable 啟用PPC上面的性能報告(需要啟用PMC)enable performance report on PPC (requires enabling PMC)
52 --disable-mmx 禁用MMX | disable MMX usage
53 --disable-armv5te 禁用armv5te | disable armv5te usage
54 --disable-iwmmxt 禁用iwmmxt | disable iwmmxt usage
55 --disable-altivec 禁用AltiVec | disable AltiVec usage
56 --disable-audio-oss 禁用OSS音頻支持(默認啟用)disable OSS audio support [default=no]
57 --disable-audio-beos 禁用BeOS音頻支持(默認啟用)disable BeOS audio support [default=no]
58 --disable-v4l 禁用video4linux提取(默認啟用)disable video4linux grabbing [default=no]
59 --disable-v4l2 禁用video4linux2提取(默認啟用)disable video4linux2 grabbing [default=no]
60 --disable-bktr 禁用bktr視頻提取(默認啟用)disable bktr video grabbing [default=no]
61 --disable-dv1394 禁用DV1394提取(默認啟用)disable DV1394 grabbing [default=no]
62 --disable-network 禁用網絡支持(默認支持)disable network support [default=no]
63 --disable-ipv6 禁用ipv6支持(默認支持)disable ipv6 support [default=no]
64 --disable-zlib 禁用zlib(默認支持)disable zlib [default=no]
65 --disable-simple_idct 禁用simple IDCT常式(默認啟用)disable simple IDCT routines [default=no]
66 --disable-vhook 禁用video hooking支持 | disable video hooking support
67 --enable-gprof enable profiling with gprof [no]
68 --disable-debug 禁用調試符號 | disable debugging symbols
69 --disable-opts 禁用編譯器最佳化 | disable compiler optimizations
70 --disable-mpegaudio-hp 啟用更快的解碼MPEG音頻(但精確度較低)(默認禁用)faster (but less accurate) MPEG audio decoding [default=no]
71 --disable-protocols 禁用 I/O 協議支持(默認啟用)disable I/O protocols support [default=no]
72 --disable-ffserver 禁用生成ffserver | disable ffserver build
73 --disable-ffplay 禁用生成ffplay | disable ffplay build
74 --enable-small 啟用優化文件尺寸大小(犧牲速度)optimize for size instead of speed
75 --enable-memalign-hack 啟用模擬內存排列,由內存調試器干涉? | emulate memalign, interferes with memory debuggers
76 --disable-strip 禁用剝離可執行程序和共享庫 | disable stripping of executables and shared libraries
77 --disable-encoder=NAME 禁用XX編碼器 | disables encoder NAME
78 --enable-encoder=NAME 啟用XX編碼器 | enables encoder NAME
79 --disable-decoder=NAME 禁用XX解碼器 | disables decoder NAME
80 --enable-decoder=NAME 啟用XX解碼器 | enables decoder NAME
81 --disable-encoders 禁用所有編碼器 | disables all encoders
82 --disable-decoders 禁用所有解碼器 | disables all decoders
83 --disable-muxer=NAME 禁用XX混音器 | disables muxer NAME
84 --enable-muxer=NAME 啟用XX混音器 | enables muxer NAME
85 --disable-muxers 禁用所有混音器 | disables all muxers
86 --disable-demuxer=NAME 禁用XX解軌器 | disables demuxer NAME
87 --enable-demuxer=NAME 啟用XX解軌器 | enables demuxer NAME
88 --disable-demuxers 禁用所有解軌器 | disables all demuxers
89 --enable-parser=NAME 啟用XX剖析器 | enables parser NAME
90 --disable-parser=NAME 禁用XX剖析器 | disables parser NAME
91 --disable-parsers 禁用所有剖析器 | disables all parsers
BB 發表在 痞客邦 留言(0) 人氣(2,275)
使用 FFmpeg 將 MKV、MP4 等容器更換為 FLV 容器。
1. ffmpeg -i 原始影片檔 -f flv 輸出.flv
2. ffmpeg -i 原始影片檔 -vcodec copy -acodec copy -y 輸出.flv
-i input.mkv:使用 -i 指定欲處理之檔案的名稱。
output.flv:指定將要最終生成的檔案的名稱,檔案類型根據副檔名判斷。這裡副檔名是 flv 就會生成 flv 檔案。
-acodec copy:音訊不轉檔,直接複製給將要最終生成的檔案。
-vcodec copy:視訊不轉檔,直接複製給將要最終生成的檔案。
使用copy 選項將不會有任何 encode 步驟,所以不算是轉檔,只是換個容器而已。
ffmpeg -i <input_file> -timecode_frame_start <start_timecode> -vcodec mpeg2video -an output.m2v
Note:
Start timecode is set as number of frames.
For instance, if you want to start at 18:12:36:15, you will have to set -timecode_frame_start to 1638915 (for 25 fps content).
Sub-clip Creation
ffmpeg -i <input_file> -ss -t -vcodec copy -acodec copy <output_file>
ffmpeg -i foo.mov -vcodec copy -acodec copy -ss 00:00:08 -t 00:00:05 foo_1.mov
-ss 開始攝取時間: 00:00:08,-t 總共攝取時間: 00:00:05,也就是 8+5=13,開頭8秒,結尾至13秒,只攝取5秒影片長度之意
--------------------------------------------------------------------------------
ffmpeg
ffmpeg [[infile options][`-i' infile]]… {[outfile options] outfile}…
ffmpeg -i source.avi -f flv Out.flv
ffmpeg -i source.avi -vcodec flv -acodec copy -y Out.flv
ffmpeg支援的格式非常多,只要輸入 ffmpeg -formats 就可以看到支援的codec。
codec前會有一些說明文字,例如:
`D’ Decoding available
`E’ Encoding available
`V/A/S’ Video/audio/subtitle codec
`S’ Codec supports slices
`D’ Codec supports direct rendering
`T’ Codec can handle input truncated at random locations instead of only at frame boundaries
ffmpeg參數:
Main options:
-i : 輸入檔案名稱,會自動依codec 讀入
-f :輸入格式,例:flv
-y : overwrite output files
-t : duration set the recording time,指定輸出影片最大長度,例:hh:mm:ss[.xxx]
-fs : 限定輸出影片最大大小
-ss : 從指定的時間開始轉檔,例 hh:mm:ss[.xxx]
一些可以設定的影片資訊
-tilte : string
-author : string
-copyright: string
-comment: string
-album: string
-track: number
-year: number
Video options:
-vcodec : 影像編碼格式,例:libxvid ,即XVID
-s : 輸出畫面的解析度,例如:-s 320×240,預設和source一樣, qvga = 320×240
-r : 指FPS,rate set frame rate,例: 25 (fps)
-b bitrate set video bitrate (in kbit/s),例: 200 (kb/s)
-pass n : n = [1|2],one pass , two pass
-newvideo : append 影片到輸出檔上
Audio options:
-acodec : 聲音編碼格式,例:libmp3lame , 即MP3
-ar : 聲音的取樣頻率,預設是 44100 Hz
-ac : 設定聲音的聲道數。1指是的單聲道
-ab : 指定聲音的bitrate,例: 64k
-an : 關掉聲音
-newaudio : 一樣 append
Subtitle options:
`-scodec codec’
Force subtitle codec (‘copy’ to copy stream).
`-newsubtitle’
append字幕到輸出檔上
`-slang code’
Set the ISO 639 language code (3 letters) of the current subtitle stream.
`-sbsf bitstream_filter’
Bitstream filters available are “mov2textsub", “text2movsub".
一些例子:(from ffmpeg常用轉檔參數)
把影像檔案轉換成avi格式
# ffmpeg -i filename.flv -f avi -vcodec libxvid -acodec libmp3lame -ar 22050 filename.avi
把影像檔案轉換成3gp格式
# ffmpeg -i filename.avi -s qcif -vcodec h263 -acodec libfaac -ac 1 -ar 8000 -r 25 -ab 32 filename.3gp
把影像檔轉換成flv格式
# ffmpeg -i filename.mpg -ab 56 -ar 22050 -b 500 -r 15 filename.flv
將聲音檔案轉成mp3
# ffmpeg -i filename.wav -acodec libmp3lame -ar 44100 -ab 128k filename.mp3
BB 發表在 痞客邦 留言(0) 人氣(26,927)
參考資料
http://www.mplayerhq.hu/DOCS/codecs-status.html
Video codecs:
BB 發表在 痞客邦 留言(0) 人氣(3,818)