Decoding has been using the FFmpeg, recently want to decode before decoding the number of frames, found that FFmpeg can only be traversed to obtain the number of frames.
Online check, MediaInfo seems to be a good library.
Download the MediaInfo library file, extract the MediaInfoDLL.h header file and the MediaInfo.dll file.
Start compiling error, change a person with MediaInfo.dll , normal operation, unknown so. It is estimated that DLL compilation generated the problem.
Under the console SDK development, C + + language, there are routines:
#include "MediaInfoDLL.h" #include <iostream> #include <iomanip> #include <string>using namespace Mediainfodll;int Main () {//information about mediainfo mediainfo MI; String To_display=mi. Option (__t ("Info_version"), __t ("0.7.61.0; mediainfodll_example_msvc;0.7.61.0 ")). C_str (); To_display + = __t ("\r\n\r\ninfo_parameters\r\n"); To_display + = MI. Option (__t ("Info_parameters")). C_str (); To_display + = __t ("\r\n\r\ninfo_codecs\r\n"); To_display + = MI. Option (__t ("Info_codecs")). C_str (); An example of the library To_display + = __t ("\r\n\r\nopen\r\n"); MI. Open (__t ("D:\\picture\\video.avi")); MI. Open (__t ("Example.ogg")); To_display + = __t ("\r\n\r\ninform with complete=false\r\n"); MI. Option (__t ("complete")); To_display + = Mi.inform (). C_STR (); To_display + = __t ("\r\n\r\ninform with complete=true\r\n"); MI. Option (__t ("complete"), __t ("1")); To_display + = Mi.inform (). C_STR (); To_display + = __t ("\r\n\r\ncustom inform\r\n "); MI. Option (__t ("Inform"), __t ("General; Example:filesize=%filesize% ")); To_display + = Mi.inform (). C_STR (); To_display + = __t ("\r\n\r\nget with Stream=general and parameter=\" filesize\ "\ r \ n"); To_display + = MI. Get (stream_general, 0, __t ("FileSize"), Info_text, Info_name). C_STR (); To_display + = __t ("\r\n\r\ngeti with Stream=general and parameter=46\r\n"); To_display + = MI. Get (stream_general, 0, Info_text). C_STR (); To_display + = __t ("\r\n\r\ncount_get with streamkind=stream_audio\r\n"); Tostringstream SS; SS << Std::setbase (Ten) << MI. Count_get (Stream_audio); To_display + = Ss.str (); To_display + = __t ("\r\n\r\nget with Stream=general and parameter=\" audiocount\ "\ r \ n"); To_display + = MI. Get (stream_general, 0, __t ("Audiocount"), Info_text, Info_name). C_STR (); To_display + = __t ("\r\n\r\nget with Stream=audio and parameter=\" streamcount\ "\ r \ n"); To_display + = MI. Get (Stream_audio, 0, __t ("Streamcount"), Info_text, Info_name). C_STR (); To_display + = __t ("\r\n\r\nclose\r\n"); MI. Close (); Std::wcout << To_display; return 0;}
Run results
The full information obtained on the above video, most of the circumstances do not need to live so detailed information, only care about the information they want, under the MFC test.
void Cmediainfo1dlg::onbnclickedread () {//TODO: In this Add control notification handler code MediaInfo MI; CString Width,height,count,rate,duration;mi. Open ("D:\\picture\\video.avi"); width = MI. Get (stream_t::stream_video,0, "Width"). C_str (); height = MI. Get (stream_t::stream_video,0, "Height"). C_str (); count = MI. Get (stream_t::stream_video,0, "Framecount"). C_STR (); rate = MI. Get (stream_t::stream_video,0, "framerate"). C_str ();d uration = MI. Get (stream_t::stream_video,0, "Duration"). C_str (); MI. Close (); AfxMessageBox (width+height+count+rate+duration);}
width, height, number of frames, frame rate, length of time, in turn.
MediaInfo of Video Learning notes