1.ffmpeg学习之打印本地视频流信息

音视频码流播放流程

视频数据处理流程
##读取文件并打印视频流信息

#include "stdafx.h"
#include <string>
#include "ScopeGuard.h"
#ifdef __cplusplus
extern "C" {
#endif

#include <libavformat/avformat.h>
#ifdef __cplusplus
}
#endif
#pragma comment(lib,"avformat.lib")
int main()
{
	AVFormatContext* ifmt_ctx = nullptr;
	const char* file_name = "D:\\rtsp_test\\h264.mp4";
	int res = avformat_open_input(&ifmt_ctx, file_name, nullptr, nullptr);//打开文件流
	if (res != 0){
		fprintf(stderr, "avformat_open_input error\n");
		getchar();
		return 0;
	}
	ON_SCOPE_EXIT([&] {avformat_close_input(&ifmt_ctx); });
	res = avformat_find_stream_info(ifmt_ctx, nullptr);//查询流信息
	if (res < 0) {
		fprintf(stderr, "avformat_open_input error\n");
		getchar();
		return 0;
	}

	int video_stream_no = -1;
	for (unsigned int i = 0; i < ifmt_ctx->nb_streams; ++i){
		if (AVMEDIA_TYPE_VIDEO == ifmt_ctx->streams[i]->codecpar->codec_type){
			video_stream_no = i;
			break;
		}
	}
	if(-1!=video_stream_no)
		av_dump_format(ifmt_ctx, video_stream_no, file_name, 0);//打印视频流信息
	getchar();
    return 0;
}

输出信息如下图:
控制台输出信息

使用的ffmpeg版本号

ffmpeg version git-2020-03-01-1281399

文档资料

雷霄骅博士csdn博客总结

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值