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前記埋めるため、入力ストリームを出力し、最後のパラメータを埋め、プリント出力ストリームを

 

 サンプルコード

#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;
}

結果:

あなたは、2つのストリームの合計をtest.flv見ることができます

       #0:0ビデオストリーム、H264のエンコード、YUV420、1920 * 1080、30fpsの、

       #0:1 AACオーディオストリームの符号化、48000Hz、ステレオステレオ

公開された124元の記事 ウォン称賛84 ビュー160 000 +

おすすめ

転載: blog.csdn.net/yao_hou/article/details/104102235