注:此前已经写了一系列分析MediaInfo源代码的文章,列表如下:
MediaInfo源代码分析 1:整体结构
MediaInfo源代码分析 2:API函数
MediaInfo源代码分析 3:Open()函数
MediaInfo源代码分析 4:Inform()函数
MediaInfo源代码分析 5:JPEG解析代码分析
===================
本文主要分析MediaInfo的API函数。它的API函数位于MediaInfo.h文件中的一个叫做MediaInfo的类中。
该类如下所示,部分重要的方法已经加上了注释:
//MediaInfo类 class MEDIAINFO_EXP MediaInfo { public : //Constructor/Destructor MediaInfo (); ~MediaInfo (); //File /// Open a file and collect information about it (technical information and tags) /// @brief Open a file /// @param File_Name Full name of file to open /// @retval 0 File not opened /// @retval 1 File opened //打开文件 size_t Open (const String &File_Name); /// Open a Buffer (Begin and end of the stream) and collect information about it (technical information and tags) /// @brief Open a buffer /// @param Begin First bytes of the buffer /// @param Begin_Size Size of Begin /// @param End Last bytes of the buffer /// @param End_Size Size of End /// @param File_Size Total size of the file /// @retval 0 File not opened /// @retval 1 File opened //打开一段内存! size_t Open (const ZenLib::int8u* Begin, size_t Begin_Size, const ZenLib::int8u* End=NULL, size_t End_Size=0, ZenLib::int64u File_Size=0); /// Open a stream and collect information about it (technical information and tags) /// @brief Open a stream (Init) /// @param File_Size Estimated file size /// @param File_Offset Offset of the file (if we don't have the beginning of the file) /// @retval 0 File not opened /// @retval 1 File opened //打开一个流和收集的关于它的信息 size_t Open_Buffer_Init (ZenLib::int64u File_Size=(ZenLib::int64u)-1, ZenLib::int64u File_Offset=0); /// Open a stream and collect information about it (technical information and tags) /// @brief Open a stream (Continue) /// @param Buffer pointer to the stream /// @param Buffer_Size Count of bytes to read /// @return a bitfield \n /// bit 0: Is Accepted (format is known) /// bit 1: Is Filled (main data is collected) /// bit 2: Is Updated (some data have beed updated, example: duration for a real time MPEG-TS stream) /// bit 3: Is Finalized (No more data is needed, will not use further data) /// bit 4-15: Reserved /// bit 16-31: User defined //打开一个流和收集的关于它的信息 size_t Open_Buffer_Continue (const ZenLib::int8u* Buffer, size_t Buffer_Size); /// Open a stream and collect information about it (technical information and tags) /// @brief Open a stream (Get the needed file Offset) /// @return the needed offset of the file \n /// File size if no more bytes are needed ZenLib::int64u Open_Buffer_Continue_GoTo_Get (); /// Open a stream and collect information about it (technical information and tags) /// @brief Open a stream (Finalize) /// @retval 0 failed /// @retval 1 succeed //打开一个流和收集的关于它的信息 size_t Open_Buffer_Finalize (); /// If Open() is used in "PerPacket" mode, parse only one packet and return /// @brief Read one packet (if "PerPacket" mode is set) /// @return a bitfield \n /// bit 0: A packet was read size_t Open_NextPacket (); /// (NOT IMPLEMENTED YET) Save the file opened before with Open() (modifications of tags) /// @brief (NOT IMPLEMENTED YET) Save the file /// @retval 0 failed /// @retval 1 suceed size_t Save (); /// Close a file opened before with Open() (without saving) /// @brief Close a file /// @warning without have saved before, modifications are lost void Close (); //General information /// Get all details about a file in one string /// @brief Get all details about a file /// @param Reserved Reserved, do not use /// @pre You can change default presentation with Inform_Set() /// @return Text with information about the file //返回文件信息 String Inform (size_t Reserved=0); //Get /// Get a piece of information about a file (parameter is an integer) /// @brief Get a piece of information about a file (parameter is an integer) /// @param StreamKind Kind of stream (general, video, audio...) /// @param StreamNumber Stream number in Kind of stream (first, second...) /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) /// @return a string about information you search \n /// an empty string if there is a problem //获取一部分文件的信息(参数是一个整数) String Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text); /// Get a piece of information about a file (parameter is a string) /// @brief Get a piece of information about a file (parameter is a string) /// @param StreamKind Kind of stream (general, video, audio...) /// @param StreamNumber Stream number in Kind of stream (first, second...) /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format ("Codec", "Width"...) \n /// See MediaInfo::Option("Info_Parameters") to have the full list /// @param InfoKind Kind of information you want about the parameter (the text, the measure, the help...) /// @param SearchKind Where to look for the parameter /// @return a string about information you search \n /// an empty string if there is a problem //获取一部分文件的信息(参数是一个字符串) String Get (stream_t StreamKind, size_t StreamNumber, const String &Parameter, info_t InfoKind=Info_Text, info_t SearchKind=Info_Name); //Set /// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an integer) /// @brief (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is an int) /// @warning Not yet implemented, do not use it /// @param ToSet Piece of information /// @param StreamKind Kind of stream (general, video, audio...) /// @param StreamNumber Stream number in Kind of stream (first, second...) /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in integer format (first parameter, second parameter...) /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled: tag is added \n if OldValue is filled and ToSet is filled: tag is replaced \n if OldValue is filled and ToSet is empty: tag is deleted /// @retval >0 succeed /// @retval 0 failed size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, size_t Parameter, const String &OldValue=String()); /// (NOT IMPLEMENTED YET) Set a piece of information about a file (parameter is a string) /// @warning Not yet implemented, do not use it /// @brief (NOT IMPLEMENTED YET) Set information about a file (parameter is a string) /// @param ToSet Piece of information /// @param StreamKind Kind of stream (general, video, audio...) /// @param StreamNumber Stream number in Kind of stream (first, second...) /// @param Parameter Parameter you are looking for in the stream (Codec, width, bitrate...), in string format /// @param OldValue The old value of the parameter \n if OldValue is empty and ToSet is filled: tag is added \n if OldValue is filled and ToSet is filled: tag is replaced \n if OldValue is filled and ToSet is empty: tag is deleted /// @retval >0 succeed /// @retval 0 failed size_t Set (const String &ToSet, stream_t StreamKind, size_t StreamNumber, const String &Parameter, const String &OldValue=String()); //Output_Buffered /// Output the written size when "File_Duplicate" option is used. /// @brief Output the written size when "File_Duplicate" option is used. /// @param Value The unique name of the duplicated stream (begin with "memory://") /// @return The size of the used buffer size_t Output_Buffer_Get (const String &Value); /// Output the written size when "File_Duplicate" option is used. /// @brief Output the written size when "File_Duplicate" option is used. /// @param Pos The order of calling /// @return The size of the used buffer size_t Output_Buffer_Get (size_t Pos); //Info /// Configure or get information about MediaInfoLib /// @param Option The name of option /// @param Value The value of option /// @return Depend of the option: by default "" (nothing) means No, other means Yes /// @post Known options are: \n /// * (NOT IMPLEMENTED YET) "BlockMethod": Configure when Open Method must return (default or not command not understood: "1") \n /// "0": Immediatly \n /// "1": After geting local information \n /// "2": When user interaction is needed, or whan Internet information is get /// * "Complete": For debug, configure if MediaInfoLib::Inform() show all information (doesn't care of InfoOption_NoShow tag): shows all information if true, shows only useful for user information if false (No by default)\n /// * "Complete_Get": return the state of "Complete" \n /// * "Language": Configure language (default language, and this object); Value is Description of language (format: "Column1;Colum2\n...) \n /// Column 1: Unique name ("Bytes", "Title") \n /// Column 2: translation ("Octets", "Titre") \n /// * "Language_Get": Get the language file in memory /// * "Language_Update": Configure language of this object only (for optimisation); Value is Description of language (format: "Column1;Colum2\n...) \n /// Column 1: Unique name ("Bytes", "Title") \n /// Column 2: translation ("Octets", "Titre") \n /// * "Inform": Configure custom text, See MediaInfoLib::Inform() function; Description of views (format: "Column1;Colum2...) \n /// Column 1: code (11 lines: "General", "Video", "Audio", "Text", "Other", "Begin", "End", "Page_Begin", "Page_Middle", "Page_End") \n /// Column 2: The text to show (exemple: "Audio: %FileName% is at %BitRate/String%") \n /// * "ParseUnknownExtensions": Configure if MediaInfo parse files with unknown extension\n /// * "ParseUnknownExtensions_Get": Get if MediaInfo parse files with unknown extension\n /// * "ShowFiles": Configure if MediaInfo keep in memory files with specific kind of streams (or no streams); Value is Description of components (format: "Column1;Colum2\n...) \n\n /// Column 1: code (available: "Nothing" for unknown format, "VideoAudio" for at least 1 video and 1 audio, "VideoOnly" for video streams only, "AudioOnly", "TextOnly") \n /// Column 2: "" (nothing) not keeping, other for keeping /// * (NOT IMPLEMENTED YET) "TagSeparator": Configure the separator if there are multiple same tags (" | " by default)\n /// * (NOT IMPLEMENTED YET) "TagSeparator_Get": return the state of "TagSeparator" \n /// * (NOT IMPLEMENTED YET) "Internet": Authorize Internet connection (Yes by default) /// * (NOT IMPLEMENTED YET) "Internet_Title_Get": When State=5000, give all possible titles for this file (one per line) \n /// Form: Author TagSeparator Title TagSeparator Year\n... /// * (NOT IMPLEMENTED YET) "Internet_Title_Set": Set the Good title (same as given by Internet_Title_Get) \n /// Form: Author TagSeparator Title TagSeparator Year /// * "Info_Parameters": Information about what are known unique names for parameters \n /// * "Info_Parameters_CSV": Information about what are known unique names for parameters, in CSV format \n /// * "Info_Codecs": Information about which codec is known \n /// * "Info_Version": Information about the version of MediaInfoLib /// * "Info_Url": Information about where to find the last version //配置 String Option (const String &Option, const String &Value=String()); /// Configure or get information about MediaInfoLib /// @param Option The name of option /// @param Value The value of option /// @return Depend of the option: by default "" (nothing) means No, other means Yes /// @post Known options are: See MediaInfo::Option() static String Option_Static (const String &Option, const String &Value=String()); /// @brief (NOT IMPLEMENTED YET) Get the state of the library /// @retval <1000 No information is available for the file yet /// @retval >=1000_<5000 Only local (into the file) information is available, getting Internet information (titles only) is no finished yet /// @retval 5000 (only if Internet connection is accepted) User interaction is needed (use Option() with "Internet_Title_Get") \n /// Warning: even there is only one possible, user interaction (or the software) is needed /// @retval >5000<=10000 Only local (into the file) information is available, getting Internet information (all) is no finished yet /// @retval <10000 Done size_t State_Get (); /// @brief Count of streams of a stream kind (StreamNumber not filled), or count of piece of information in this stream /// @param StreamKind Kind of stream (general, video, audio...) /// @param StreamNumber Stream number in this kind of stream (first, second...) /// @return The count of fields for this stream kind / stream number if stream number is provided, else the count of streams for this stream kind size_t Count_Get (stream_t StreamKind, size_t StreamNumber=(size_t)-1); private : MediaInfo_Internal* Internal; //Constructor MediaInfo (const MediaInfo&); // Prevent copy-construction MediaInfo& operator=(const MediaInfo&); // Prevent assignment };
由代码可见,MediaInfo实际上不仅仅可以读取一个特定路径的文件【Open (const String &File_Name);】
,而且可以读取一块内存中的数据【Open (const ZenLib::int8u* Begin, size_t Begin_Size, const ZenLib::int8u* End=NULL, size_t End_Size=0, ZenLib::int64u File_Size=0)】(这个函数目前还没有使用过)。
如果想要获取完整的信息,可以使用【Inform (size_t Reserved=0)】,并且使用【Option (const String &Option, const String &Value=String())】进行配置。
如果只想获得特定的信息,可以使用【Get (stream_t StreamKind, size_t StreamNumber, size_t Parameter, info_t InfoKind=Info_Text)】。
具体使用方法参见http://blog.csdn.net/leixiaohua1020/article/details/11902195。
相关推荐
1. **加载文件**:首先,你需要使用`MediaInfo_Open()`函数打开你要分析的多媒体文件,该函数会返回一个句柄,用于后续的操作。 2. **提取信息**:接着,你可以调用`MediaInfo_Inform()`或`MediaInfo_Get()`函数,...
这个“mediainfo_0.7.31.rar”压缩包包含了mediainfo的源代码,版本为0.7.31,适合开发者用于学习、定制或在Visual Studio环境下进行编译。 Mediainfo的源码是用C++编写的,它的设计目标是提供一个跨平台的解决...
2. **错误处理**:在调用MediaInfo的API时,需要注意错误处理,确保文件打开、解析和关闭过程中的异常情况得到妥善处理。 3. **语言支持**:MediaInfo支持多语言输出,可以通过设置接口参数来选择输出的语言。 4. **...
"MediaInfo视频编码分析查询器"是一款专门用于分析和查询视频文件编码信息的工具,它可以帮助用户深入了解视频文件的技术细节,包括编码格式、分辨率、帧率、音频编码、比特率等关键参数。在数字媒体领域,了解这些...
MediaInfo DLL允许程序员在不直接访问源代码的情况下,调用其内部的分析和解析功能。 2. **API接口**:MediaInfo提供了丰富的API接口,这些接口定义了如何与DLL交互。例如,`Open()`函数用于打开一个媒体文件,`...
MediaInfo就是这样一款强大的工具,专为媒体专业人士和普通用户提供了详尽的媒体文件分析功能。它可以帮助我们洞察视频、音频文件的每一个细节,包括编码方式、比特率、分辨率等关键信息。本文将深入探讨MediaInfo的...
The MediaInfo data display includes: Container: format, profile, commercial name of the format, duration, overall bit rate, writing application and library, title, author, director, album, track ...
MediaInfo 用来分析视频和音频文件的编码和内容信息,是一款是自由软件 (免费使用、免费获得源代码,许可协议:GNU GPL/LGPL)。 支持格式:视频:MKV, OGM, AVI, DivX, WMV, QuickTime, Real, MPEG-1, MPEG-2, MPEG-4...
MediaInfo遵循开源许可,可能使用的是GPL或MIT等开放源代码许可证,允许自由使用和分享。 4. **History.txt**:这是一个版本历史记录文件,列出了该版本的更新内容、改进和修复的bug,帮助用户了解软件的发展历程...
Linux中的 Mediainfo 执行程序是用于分析多媒体文件元数据的工具,它可以从音频、视频文件中提取出详细的格式和技术信息。 Mediainfo 源码编译后生成的可执行程序可以在各种Linux发行版中运行,这得益于其跨平台的...
MediaInfo 用来分析视频和音频文件的编码和内容信息,是一款是自由软件 (免费使用、免费获得源代码,许可协议:GNU GPL/LGPL)。 MediaInfo可以获得多媒体文件的哪些信息? 内容信息:标题,作者,专辑名,音轨号,...
MediaInfo 是一款强大的媒体信息查看工具,专门用于分析和提取各种多媒体文件的详细技术信息。这个软件可以帮助用户轻松地了解视频、音频文件的编码格式、分辨率、比特率、采样率等关键参数,从而在处理多媒体文件时...
**MediaInfo 媒体分析工具** MediaInfo 是一款强大的媒体信息分析工具,它能够提供详尽的多媒体文件元数据信息,包括视频、音频、字幕等不同轨道的数据。这款工具对于媒体处理、流媒体研究、视频编码和解码、内容...
它使用从C ++源代码编译而来。演示版在浏览器中尝试mediainfo.js: ://mediainfo.js.org用法浏览器您可以使用CDN将脚本文件直接包含在页面中,也可以使用JavaScript捆绑程序(例如webpack)。 CDN : [removed]...
1. `libmediainfo.so.0`:这是`Mediainfo`的动态链接库文件,它包含了运行`Mediainfo`所需的函数和数据结构。在Linux系统中,动态链接库可以在程序运行时被加载,而不是在编译时嵌入到可执行文件中,这样可以节省...
在Windows环境下,Visual Studio(如VS2010)这样的集成开发环境可以用于编译和调试Mediainfo的源代码,以便根据需要进行定制或扩展。 在具体应用中,Mediainfo可以为我们提供以下关键的视频信息: 1. 视频编码:...
MediaInfo的一大优点是开源且跨平台,它的源代码遵循GPLv2许可协议,这意味着用户可以自由查看、修改并分发源代码。此外,MediaInfo还提供了命令行版本和图形用户界面版本,以满足不同用户的需求。 总的来说,...
8. **开源项目**:MediaInfo是开源软件,遵循GPL许可证,这意味着源代码公开,用户可以自由查看、修改和分发。 在实际应用中,MediaInfo的使用场景广泛: - **视频编辑**:在剪辑和后期制作过程中,MediaInfo可以...
MediaInfo是一款强大的多媒体信息分析工具,专为用户提供详细的音频、视频文件元数据。这款软件在全球范围内广受欢迎,因其用户友好的界面和免费无限制的特性而备受赞誉。MediaInfo_20.03.dmg.zip是针对Mac OS平台的...
使用MediaInfo可以分析多媒体的信息如下: 内容信息:标题,作者,专辑名,音轨号,日期,总时间…… 视频:编码器,长宽比,帧频率,比特率…… 音频:编码器,采样率,声道数,语言,比特率……