打开输出的流和读取头信息。其原型如下:

int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options)

  • ps:函数调用成功之后处理过的 AVFormatContext 结构体。
  • url:打开的视音频流的 URL。
  • fmt:强制指定 AVFormatContext 中 AVInputFormat 的。这个参数一般情况下可以设置为 NULL,这样 FFmpeg 可以自动检测 AVInputFormat。
  • options:附加的一些选项,一般情况下可以设置为 NULL。

函数执行成功的话,其返回值大于等于 0。