int main() { int ret = -1; AVFormatContext *fmt_ctx = NULL;
av_log_set_level(AV_LOG_INFO);av_register_all();//第三个参数是输入的文件格式, NULL可以 通过文件名获取//第四个参数是通过命令行获取的参数,一般不用设置为NULL即可ret = avformat_open_input(&fmt_ctx, "./test.mp4", NULL, NULL);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "Can't open file: %s\n", av_err2str(ret));return -1;}//第二个参数是流的索引值, 可以直接写0//第四个参数是指输入流还是输出流 0-输入 1-输出av_dump_format(fmt_ctx, 0, "./test.mp4", 0);avformat_close_input(&fmt_ctx);return 0;
}
编译: gcc -lavutil -lavformat ```
