天天看點

ffmpeg_av_dump_format

av_dump_format 在 avformat.h 中聲明,在libavformat/dump.c中實作,主要用來列印媒體資訊。

dump 是轉儲,轉存的意思。可以了解為将 AVFormatContext 中的媒體資訊轉存到輸出。

官方聲明如下:

/**
 * Print detailed information about the input or output format, such as
 * duration, bitrate, streams, container, programs, metadata, side data,
 * codec and time base.
 *
 * @param ic        the context to analyze
 * @param index     index of the stream to dump information about
 * @param url       the URL to print, such as source or destination file
 * @param is_output Select whether the specified context is an input(0) or output(1)
 */
void av_dump_format(AVFormatContext *ic,
                    int index,
                    const char *url,
                    int is_output);      

參數 index 是指目前輸入(url)的索引号,在源碼裡隻有 av_log 直接調用。

參數 url 是指目前輸入的 url 具體内容。在源碼裡隻有 av_log 直接調用。

這兩個參數隻是給人看的。也就是你給他什麼資訊,它就列印成什麼。

參數 is_output 是指 AVFormatContext 的類型是輸入還是輸出,決定了列印哪些資訊。隻有是輸入才會列印時長、比特率等資訊。

如果AVFormatContext實際是輸入,卻寫成輸出,會挂掉,這是因為會列印輸出資訊對應的 AVOutputFormat 為空。

Input #100, mov,mp4,m4a,3gp,3g2,mj2, from 'DUMMY_URL':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2011-11-10T02:12:11.000000Z
  Duration: 00:15:08.69, bitrate: N/A
    Stream #100:0(und): Video: h264 (avc1 / 0x31637661), none, 1024x432, 872 kb/s, 24 fps, 24 tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2011-11-09T02:33:10.000000Z
      handler_name    : Imported with GPAC 0.4.6-DEV (internal rev. 5)
    Stream #100:1(chi): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 2 channels, 33 kb/s (default)
    Metadata:
      creation_time   : 2011-11-09T02:33:54.000000Z
      handler_name    : GPAC ISO Audio Handler