ffprobe命令參數學習總結


1、NAME
       ffprobe - ffprobe media prober

2、SYNOPSIS
       ffprobe [options] [input_file]

3、DESCRIPTION
       ffprobe gathers information from multimedia streams and prints it in
       human- and machine-readable fashion.

4、GENERIC OPTION

‘-L’    顯示 license  
‘-h, -?, -help, --help [arg]’ 打印幫助信息;可以指定一個參數 arg ,如果不指定,只打印基本選項  
   可選的 arg 選項:  
   ‘long’    除基本選項外,還將打印高級選項  
   ‘full’    打印一個完整的選項列表,包含 encoders, decoders, demuxers, muxers, filters 等的  
                共享以及私有選項  
   ‘decoder=decoder_name’    打印名稱爲 “decoder_name” 的解碼器的詳細信息  
   ‘encoder=encoder_name’    打印名稱爲 “encoder_name” 的編碼器的詳細信息  
   ‘demuxer=demuxer_name’    打印名稱爲 “demuxer_name” 的 demuxer 的詳細信息  
   ‘muxer=muxer_name’        打印名稱爲 “muxer_name” 的 muxer 的詳細信息  
   ‘filter=filter_name’      打印名稱爲 “filter_name” 的過濾器的詳細信息  
              
‘-version’     顯示版本信息  
‘-formats’     顯示有效的格式  
‘-codecs’      顯示 libavcodec 已知的所有編解碼器  
‘-decoders’    顯示有效的解碼器  
‘-encoders’    顯示有效的編碼器  
‘-bsfs’        顯示有效的比特流過濾器  
‘-protocols’   顯示有效的協議  
‘-filters’     顯示 libavfilter 有效的過濾器  
‘-pix_fmts’    顯示有效的像素格式   
‘-sample_fmts’ 顯示有效的採樣格式  
‘-layouts’     顯示通道名稱以及標準通道佈局  
‘-colors’      顯示認可的顏色名稱  
‘-hide_banner’ 禁止打印歡迎語;也就是禁止默認會顯示的版權信息、編譯選項以及庫版本信息等

5、MAIN OPTION

    ‘-f format’    強制使用的格式  
    ‘-unit’        顯示值的單位  
    ‘-prefix’      顯示的值使用標準國際單位制詞頭  
    ‘-byte_binary_prefix’ 對字節值強制使用二進制前綴  
    ‘-sexagesimal’ 時間值使用六十進位的格式 HH:MM:SS.MICROSECONDS  
    ‘-pretty’      美化顯示值的格式。它相當於 "-unit -prefix -byte_binary_prefix -sexagesimal"  
    ‘-of, -print_format writer_name[=writer_options]’   
                  設置輸出打印格式。writer_name 指定打印程序 (writer) 的名稱,writer_options   
                  指定傳遞給 writer 的選項。例如:將輸出打印爲 JSON 格式:-print_format json   
    ‘-select_streams stream_specifier’   
                  只選擇 stream_specifier 指定的流。該選項隻影響那些與流相關的選項  
                  (例如:show_streams, show_packets, 等)。  
                  舉例:只顯示音頻流,使用命令:  
                    ffprobe -show_streams -select_streams a INPUT  
                       只顯示視頻流,使用命令:
                    ffprobe -show——streams -select_streams v INPUT
    ‘-show_data’ 顯示有效載荷數據,以十六進制和ASCII轉儲。與 ‘-show_packets’ 結合使用,它將   
                  dump 包數據;與 ‘-show_streams’ 結合使用,它將 dump codec 附加數據。  
    ‘-show_error’    顯示探測輸入文件時的錯誤信息  
    ‘-show_format’   顯示輸入多媒體流的容器格式信息  
    ‘-show_packets’  顯示輸入多媒體流中每一個包的信息  
    ‘-show_frames’   顯示輸入多媒體流中的每一幀以及字幕的信息  
    ‘-show_streams’  顯示輸入多媒體流中每一個流的信息  
    ‘-show_programs’ 顯示輸入多媒體流中程序以及它們的流的信息  
    ‘-show_chapters’ 顯示格式中存儲的章節信息  
    ‘-count_frames’  計算每一個流中的幀數,在相應的段中進行顯示  
                如:ffprobe -show_streams -count_frames -i sample.mp4
                  n_read_frames會有數據,否則爲N/A
    ‘-count_packets’ 計算每一個流中的包數,在相應的段中進行顯示  
    ‘-show_program_version’   顯示程序版本及配置相關信息  
    ‘-show_library_versions’  顯示庫版本相關信息  
    ‘-show_versions’          顯示程序和庫版本相關信息。相當於同時設置‘-show_program_version’ 和   
                              ‘-show_library_versions’  
    ‘-i input_file’           指定輸入文件  


6、AVOPTION

      音視頻選項。這些選項直接由libavformat, libavdevice和libavcodec庫提供,它們可以分成兩類:
generic : 這些選項可以用於設置所有容器,codec或設備。
          一般的選項都列在AVFormatContext容器/設備之下,並根據AVCodecContext中選擇編解碼器。
private : 這些選項用於設置指定的容器,設備和codec. 私有選項都列在它們對應的容器/設備/codec下。

例如:
寫一個ID3v2.3頭來代替默認的ID3v2.4頭到一個MP3文件,使用MP3混合器的"id3v2_version"私有選項:
    ffmpeg -i input.flac -id3v2_version 3 out.mp3

所有AVOption選項可作用於每個流,因此使用流指示符來指示作用於特定流。
Note: the ‘-nooption’ syntax cannot be used for boolean AVOptions, use ‘-option 0’/‘-option 1’.
Note: the old undocumented way of specifying per-stream AVOptions by prepending v/a/s to the options name is now obsolete and will be removed soon.


7、OTHER OPTION

    NONE


8、WRITERS

    8.1 default   
      默認格式。按照以下形式打印每個 section :  
        [SECTION]  
        key1=val1  
        ...  
        keyN=valN  
        [/SECTION]  
      
    8.2 compact, csv   
      緊湊與CSV格式。每個 section 打印在一個單獨的行。如果不指定其他選項,其輸入格式如下:  
        section|key1=val1| ... |keyN=valN  
      
    8.3 flat  
      一種自由格式輸出,每一行包含一個明確的 key=value 對。  
      
    8.4 ini  
      INI 格式輸出。  
      
    8.5 json  
      JSON 格式輸出。每一個 section 使用 JSON 符號來打印。  
      
    8.6 xml  
      XML 格式輸出

9、流指示符

     很多選項可應用於每個流,如碼率或codec.
    流指示符用於明確指示給定的選項屬於哪個流。

    流指示符是跟在選項名後的字符串,由冒號分隔。
    例如:
           -codec:a:1 ac3
    它包含了 a:1 這個流指示符,用於匹配第二個音頻流,因此,整個意思是選擇AC3 codec來處理第二個音頻流。

    一個流指示符可以匹配多個流,因此選項也可以同時作用於它們。
    例如,
         -b:a 128k     匹配所有的音頻流;

    空流指示符匹配所有流。
   例如:
         -codec copy 或 -codec:copy  指示所有的流都不進行再編碼;

    流指示符的可能形式:
     ‘stream_index’ 使用索引號來匹配流;
    例如:
         -threads:1 4 
    將設置第二個流的線程數爲4;

    ‘stream_type[:stream_index]’
     stream_type可以是下列之一: 
            'v'  爲視頻;
           'a'  爲音頻;
           's'  爲子目錄;
           'd'  爲數據;
            't'  爲附錄。
     如果指定了stream_index,那麼這些類型只能stream_index指定的流有效,否則,對所有的流起作用; 

     ‘p:program_id[:stream_index]’
      如果指定了stream_index, 那麼它只匹配id號爲program_id的由stream_index指定的流,否則,匹配節目中的所有流。

     ‘ #stream_id or i:stream_id’
     匹配stream_id指定的流(如, MPEG-TS容器中的PID)


10、命令示例

(1)最簡單的命令:ffprobe sample.mp4

ffprobe version 1.2.3 Copyright (c) 2007-2013 the FFmpeg developers
  built on Apr 28 2015 00:55:12 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
  configuration: --enable-gpl --enable-libx264 --enable-libmp3lame --disable-yasm
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 99 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler

(2)顯示格式相關信息

          ffprobe -show_format test.flv

Input #0, flv, from 'test.flv':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf54.63.104
  Duration: 00:09:56.58, start: 0.000000, bitrate: 275 kb/s
    Stream #0:0: Video: flv1, yuv420p, 424x240, 200 kb/s, 15 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16p, 0 kb/s
[FORMAT]
filename=test.flv
nb_streams=2
format_name=flv
format_long_name=FLV (Flash Video)
start_time=0.000000
duration=596.584000
size=20546366
bit_rate=275520
TAG:major_brand=qt  
TAG:minor_version=512
TAG:compatible_brands=qt  
TAG:encoder=Lavf54.63.104
[/FORMAT]

(3)以 JSON 格式顯示每個流的信息

             ffprobe -print_format json -show_streams test.mp4
(4)查看包信息

            ffprobe -show_packets sample.mp4

[PACKET]
codec_type=video
stream_index=0
pts=14314
pts_time=596.416667
dts=14314
dts_time=596.416667
duration=1
duration_time=0.041667
convergence_duration=N/A
convergence_duration_time=N/A
size=478
pos=38774446
flags=_
[/PACKET]
......
(5)顯示幀信息

           ffprobe -show_frames sample.mp4

[FRAME]
media_type=video
key_frame=0
pkt_pts=1
pkt_pts_time=0.041667
pkt_dts=1
pkt_dts_time=0.041667
pkt_duration=1
pkt_duration_time=0.041667
pkt_pos=1190
pkt_size=13
width=424
height=240
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=1
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
reference=0
[/FRAME]
[FRAME]
media_type=video
key_frame=0
pkt_pts=3
pkt_pts_time=0.125000
pkt_dts=3
pkt_dts_time=0.125000
pkt_duration=1
pkt_duration_time=0.041667
pkt_pos=2570
pkt_size=13
width=424
height=240
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=P
coded_picture_number=3
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
reference=0
[/FRAME]
.... 
(6)顯示流信息

         ffprobe -show_streams sample.mp4

[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Constrained Baseline
codec_type=video
codec_time_base=1/48
codec_tag_string=avc1
codec_tag=0x31637661
width=424
height=240
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=30
timecode=N/A
id=N/A
r_frame_rate=24/1
avg_frame_rate=24/1
time_base=1/24
start_pts=0
start_time=0.000000
duration_ts=14315
duration=596.458333
bit_rate=420991
nb_frames=14315
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:creation_time=1970-01-01 00:00:00
TAG:language=eng
TAG:handler_name=DataHandler
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=2
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=28628992
duration=596.437333
bit_rate=99080
nb_frames=27958
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:creation_time=1970-01-01 00:00:00
TAG:language=eng
TAG:handler_name=DataHandler
[/STREAM]

(7)不顯示版本等 信息

     ffprobe -v quiet -show_format -i sample.mp4


11、參考

[1]http://www.it165.net/os/html/201404/7862.html

[2]http://blog.chinaunix.net/uid-26000296-id-4282102.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章