eATM

ffmpeg用法

				
					// eMusicTag.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include <iostream>
#include <easy/easy_curl.h>

using namespace easy;

extern "C" {
	#include "libavformat/avformat.h"
	#include "libavutil/dict.h"
}
#pragma comment(lib, "ffmpeg\\avformat.lib")
#pragma comment(lib, "ffmpeg\\avutil.lib")

int main()
{
	/*
		auto httpclient = create_http_client();
		//httpclient->set_proxy("http://192.168.3.5:59910");
		httpclient->set_proxy("127.0.0.1:910");
		//auto data = httpclient->get("https://www.google.com/search?surl=1&tbm=isch&q=DJ-%E8%8B%B1%E6%96%87%E4%B8%B2%E7%83%A7+-+DJ&tbs=iar:s,isz:m");
		auto data = httpclient->get("https://www.baidu.com");
		data = httpclient->get("https://www.baidu.com/abb#ie=UTF-8&wd=aaa");
		//data = httpclient->get("https://www.taobao.com");*/

	AVFormatContext* fmt_ctx = NULL;
	const AVDictionaryEntry* tag = NULL;
	int ret;

	//av_register_all();

	char szPath[] = "邓紫棋.flac";
	//char szPath[] = "I:\\原声音乐\\德国调音金修改效果\\邓紫棋 - 再见.wav";

	if ((ret = avformat_open_input(&fmt_ctx, szPath, NULL, NULL)))
		return ret;

	if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
		av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
		return ret;
	}

	while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
	{
		eString val = eString::utf8_ansi(tag->value);
		printf("%s=%s\n", tag->key, val.c_str());
	}

	if (fmt_ctx->iformat->read_header(fmt_ctx) < 0) {
		printf("No header format");
		return 0;
	}

	for (int i = 0; i < (int)fmt_ctx->nb_streams; i++) {
		if (fmt_ctx->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
			AVPacket pkt = fmt_ctx->streams[i]->attached_pic;

			int x = 0;
			/*//使用QImage读取完整图片数据(注意,图片数据是为解析的文件数据,需要用QImage::fromdata来解析读取)
			QImage img = QImage::fromData((uchar*)pkt.data, pkt.size);
			imageWidget->setPixmap(QPixmap::fromImage(img));
			break;*/ 
		}
	}

	avformat_close_input(&fmt_ctx);

	system("pause");
	return 0;
}

				
			

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注