FFmpeg源码分析:av_dump_format()

FFmpeg API : av_dump_format, 打印关于输入或输出格式的详细信息, 代码声明如下

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

函数功能:
打印关于输入或输出格式的详细信息,例如持续时间,比特率,流,容器,程序,元数据,边数据,编解码器和时基。

参数说明:
最后一个参数 is_output 选择指定的上下文是输入(0)还是输出(1),也就说最后一个参数填0,打印输入流;最后一个参数填1,打印输出流

代码示例:

#include <iostream>

#ifdef __cplusplus
extern "C" {
#endif

#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

#ifdef __cplusplus
}
#endif 


int main()
{
    //std::cout <<"avcodec_configuration "<< avcodec_configuration() << std::endl;
    //std::cout <<"avcodec_version "<< avcodec_version() << std::endl;

    AVFormatContext* pAVFormat = NULL;
    //return 0 on success, a negative AVERROR on failure.
    const char* pMediaPath = "test_video.mp4";
    int iret = avformat_open_input(&pAVFormat, pMediaPath, NULL, NULL);
    if (0 == iret) {
        std::cout << "avformat_open_input success!" << std::endl;
    }
    else {
        std::cout << "avformat_open_input failed!" << std::endl;
    }

    //@return >=0 if OK, AVERROR_xxx on error
    iret = avformat_find_stream_info(pAVFormat, NULL);
    if (0 <= iret) {
        std::cout << "avformat_find_stream_info success!" << std::endl;
    }
    else {
        std::cout << "avformat_find_stream_info failed!" << std::endl;
    }

    av_dump_format(pAVFormat, 0, pMediaPath, 0);

    return 0;
}

运行结果:
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值