天天看点

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