使用mediainfo库取得媒体文件的tag

mediainfo的官网:http://mediaarea.net/


#ifdef MEDIAINFO_LIBRARY
    #include "MediaInfo.h" //Staticly-loaded library (.lib or .a or .so)
    #define MediaInfoNameSpace MediaInfoLib;
#else //MEDIAINFO_LIBRARY
    #include "MediaInfoDLL.h" //Dynamicly-loaded library (.dll or .so)
    #define MediaInfoNameSpace MediaInfoDLL;
#endif //MEDIAINFO_LIBRARY
#include <iostream>
#include <iomanip>
#include <locale>
using namespace MediaInfoNameSpace;

void printTagInfo(String filePath)
{	
	MediaInfo mi;
	mi.Open(filePath);
	
	static const struct MATRIX {
		std::wstring printStr;
		String tagName;
	} lookupInfo[] = {
		{L"Title", L"Title"},
		{L"Album", L"Album"},
		{L"Artist", L"Artist"},
		{L"Composer", L"Composer"},
		{L"Genre", L"Genre"},
	};

	// set locale
	std::wcout.imbue(std::locale(""));

	std::wcout << L"file [" << filePath << L"] tag information:" << std::endl;
	for (size_t i = 0; i < sizeof(lookupInfo)/sizeof(MATRIX); i++)
	{
		String tagInfo = mi.Get(Stream_General, 0, lookupInfo[i].tagName);
		std::wcout << std::setw(10) << lookupInfo[i].printStr << L" : " << tagInfo << std::endl;
	}
	std::wcout << std::endl;

	mi.Close();
}

int main()
{
	printTagInfo(L"F:\\temp\\benow.mp3");
	printTagInfo(L"F:\\temp\\benow.aac");
	printTagInfo(L"F:\\temp\\benow.wma");

	getchar();
}


发布了8 篇原创文章 · 获赞 2 · 访问量 1万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览