FFmpeg av_dump_format函数使用

函数说明
一般使用av_find_stream_info函数探测码流格式,它的作用是为pFormatContext->streams填充上正确的音视频格式信息。可以通过av_dump_format函数将音视频数据格式通过av_log输出到指定的文件或者控制台,方便开发者了解输入的视音频格式,对于程序的调用,删除该函数的调用没有任何的影响

函数参数
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
is_output等于0代表,打印输入的视音频文件格式信息

代码
av_dump_format(pFormatContext, 0, “”, 0);

通过av_log_set_callback设置日志文件输出,输出的结果如下:
Input #0, h264, from ‘’:
Duration: N/A, bitrate: N/A
Stream #0:0, 0, 1/1200000: Video: h264 (Baseline), yuvj420p, 1920x1080, 25 fps, 0.04 tbr, 1200k tbn

函数功能:

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

参数说明:
最后一个参数 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;
}

转载:https://blog.csdn.net/yao_hou/article/details/104102235
转载:https://blog.csdn.net/weixin_34219944/article/details/89821498?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0.control&spm=1001.2101.3001.4242

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值