ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

av_dump_format函数使用说明

2020-01-28 21:01:15  阅读:476  来源: 互联网

标签:dump format int param av output


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>

extern "C"
{
#include "libavformat/avformat.h"
}

using namespace std;

#pragma comment(lib,"avformat.lib")
#pragma comment(lib,"avutil.lib")

int ff_Error(int errNum)
{
	char buf[1024] = { 0 };
	av_strerror(errNum, buf, sizeof(buf));
	cout << buf << endl;
	system("pause");
	return -1;
}

int main()
{
	char *inUrl = "D:\\TestFiles\\test.flv";
	av_register_all();

	AVFormatContext *ictx = NULL;

	//打开文件,解封文件头
	int re = avformat_open_input(&ictx, inUrl, 0, 0);
	if (re != 0)
	{
		return ff_Error(re);
	}

	cout << "open file " << inUrl << " success..." << endl;

	//获取音频视频流信息 ,h264 flv
	re = avformat_find_stream_info(ictx, 0);
	if (re != 0)
	{
		return ff_Error(re);
	}

	//打印流信息
	//注意:最后一个参数填0,打印输入流;最后一个参数填1,打印输出流
	av_dump_format(ictx, 0, inUrl, 0);  

	system("pause");
	return 0;
}

运行结果:

可以看到test.flv一共有两个流,

       #0:0视频流,h264编码,yuv420, 1920*1080, 30fps,

       #0:1音频流   aac编码,48000Hz, stereo立体声

令狐掌门 发布了124 篇原创文章 · 获赞 84 · 访问量 16万+ 私信 关注

标签:dump,format,int,param,av,output
来源: https://blog.csdn.net/yao_hou/article/details/104102235

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有