MediaInfo获取视频文件时长

来源:互联网 发布:java带毫秒 编辑:程序博客网 时间:2024/05/24 05:40

一.导入相关项

#include "MediaInfoDLL.h" 

using namespace MediaInfoDLL;


二. 获取文件时长并转化为秒
void CTestMediaInfoDlg::OnButton1() 
{
// TODO: Add your control notification handler code here
// CString 
String m_strFileName="D:\\FTPDir\\SECOND\\77VY0432.mpg";
MediaInfo MI;
MI.Open(m_strFileName);
OutputDebugString("MI.Open(m_strFileName);");
String strInfo= MI.Get(Stream_General, 0, __T("Duration/String3"), Info_Text, Info_Name).c_str();
  CString strTest=strInfo.c_str();

int second=GetSecond(strTest);
}


int CTestMediaInfoDlg::GetSecond(CString strTime)
{
int result=0;
int Hour, minute,second;
//strTime=strTime.Left(strTime.ReverseFind('.'));
Hour=atoi(strTime.Left(strTime.Find(':')).GetBuffer(0));
strTime=strTime.Right(strTime.GetLength()-strTime.Find(':')-1);
minute=atoi(strTime.Left(strTime.Find(':')).GetBuffer(0));
strTime=strTime.Right(strTime.GetLength()-strTime.Find(':')-1);
second=atoi(strTime.GetBuffer(0));
result=Hour*3600+minute*60+second;
return result;
}
原创粉丝点击