FFmpeg函数简单分析:av

FFmpeg函数简单分析:av,第1张

/**
 * 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);

参数分析:
1.AVFormatContext *ic:封装格式的上下文
2.int index:要转储信息的流的索引,只是打印没什么影响
3.const char *url:url只是打印结果的显示,所以输入什么不影响
4.int is_output:选择指定的上下文是输入(0)还是输出(1),解封装是输入(0),封装是输出(1)
注意:有的流需要经过avformat_find_stream_info才能打印出信息

#include 
using namespace std;
extern "C"
{
    #include "libavformat/avformat.h"
}
int main()
{
    AVFormatContext	*pFormatCtx=NULL;

    const char *filepath="cuc_ieschool.flv";

    if(avformat_open_input(&pFormatCtx,filepath,NULL,NULL)!=0){
        printf("Couldn't open input stream.\n");
        return -1;
    }
		//获取流信息
    if(avformat_find_stream_info(pFormatCtx,NULL)<0){
        printf("Couldn't find stream information.\n");
        return -1;
    }

    //打印详细信息
    av_dump_format(pFormatCtx,0,filepath,0);
    //关闭
    avformat_close_input(&pFormatCtx);
    return 0;
}

根据输出可以看到视频流、音频流的详细信息了

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/716698.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存