Extract the information of the AVI file and play the AVI audio clip.

Source: Internet
Author: User

# Include <VFW. h>

# Pragma comment (Lib, "vfw32 ")

Play AVI audio streams

// Initialization

Hwnd m_haviwnd = mciwndcreate (m_stccarry.getsafehwnd (),
AfxGetInstanceHandle (),
Ws_child | ws_visible | mciwndf_nomenu, m_stravifile); // cstring m_stravifile

// Operation

Mciwndopen (m_haviwnd, (lpctstr) m_stravifile, 0 );
Mciwndplay (m_haviwnd );

Mciwndstop (m_haviwnd );

Mciwnddestroy (m_haviwnd );

//////////////////////////////////////// //////////////////////////////////////// /////////

// Open a file

Pavifile;
Avifileinit ();
Hresult hR = avifileopen (& pavifile, m_stravifile, of_read, null );

// Retrieve AFI Information

Avifileinfo AFI;
Memset (void *) & AFI, 0, sizeof (avifileinfo ));
HR = avifileinfo (pavifile, & AFI, sizeof (avifileinfo ));

// Obtain the ASI information.

Pavistream pvideostream = NULL;
HR = avifilegetstream (pavifile, & pvideostream, streamtypevideo, 0 );

Avistreaminfo ASI;
HR = avistreaminfo (pvideostream, & ASI, sizeof (avistreaminfo ));

// Outputs Information

Cstring strtext;
Strtext. Format ("total frames: % lu", AFI. dwlength );
M_listaviinfo.addstring (strtext );

Strtext. Format ("FPS: % lf", asi. dwrate/(double) asi. dwscale );
M_listaviinfo.addstring (strtext );

Strtext. Format ("stream: % lu", AFI. dwstreams );
M_listaviinfo.addstring (strtext );

Int nwidth = asi. rcframe. Right-asi. rcframe. Left;
Int nheight = asi. rcframe. Bottom-asi. rcframe. Top;
Strtext. Format ("width/height: % d", nwidth, nheight );
M_listaviinfo.addstring (strtext );

Strtext. Format ("encoding: % s", (char *) & asi. fcchandler );
M_listaviinfo.addstring (strtext );
'// Stream-related, file (the preceding generation is also required)
Avistreamrelease (pvideostream );
Avifileexit ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.