📄 fileinfodialog.cpp
字号:
case ID3CT_OTHER: mi->strInfo << _T("Other"); break;
case ID3CT_LYRICS: mi->strInfo << _T("Lyrics"); break;
case ID3CT_TEXTTRANSCRIPTION: mi->strInfo << _T("Text transcription"); break;
case ID3CT_MOVEMENT: mi->strInfo << _T("Movement/part name"); break;
case ID3CT_EVENTS: mi->strInfo << _T("Events"); break;
case ID3CT_CHORD: mi->strInfo << _T("Chord"); break;
case ID3CT_TRIVIA: mi->strInfo << _T("Trivia/'pop up' information"); break;
}
mi->strInfo << _T("\n");
/*ID3_Field* fld = frame->GetField(ID3FN_DATA);
if (fld)
{
ID3_MemoryReader mr(fld->GetRawBinary(), fld->BinSize());
while (!mr.atEnd())
{
mi->strInfo << io::readString(mr).c_str();
mi->strInfo << " [" << io::readBENumber(mr, sizeof(uint32)) << " "
<< format << "] ";
}
}
mi->strInfo << "\n";*/
delete [] sDesc;
delete [] sLang;
break;
}
case ID3FID_AUDIOCRYPTO:
case ID3FID_EQUALIZATION:
case ID3FID_EVENTTIMING:
case ID3FID_CDID:
case ID3FID_MPEGLOOKUP:
case ID3FID_OWNERSHIP:
case ID3FID_PRIVATE:
case ID3FID_POSITIONSYNC:
case ID3FID_BUFFERSIZE:
case ID3FID_VOLUMEADJ:
case ID3FID_REVERB:
case ID3FID_SYNCEDTEMPO:
case ID3FID_METACRYPTO:
mi->strInfo << _T(" (unimplemented)") << _T("\n");
break;
default:
mi->strInfo << _T(" frame") << _T("\n");
break;
}
}
delete iter;
}
catch(...)
{
ASSERT(0);
}
}
else
{
// starting the MediaDet object takes a noticeable amount of time.. avoid starting that object
// for files which are not expected to contain any Audio/Video data.
// note also: MediaDet does not work well for too short files (e.g. 16K)
//
// same applies for MediaInfoLib, its even slower than MediaDet -> avoid calling for non AV files.
//
// since we have a thread here, this should not be a performance problem any longer.
// check again for AV type; MediaDet object has trouble with RAR files (?)
EED2KFileType eFileType = GetED2KFileTypeID(pFile->GetFileName());
if (eFileType == ED2KFT_AUDIO || eFileType == ED2KFT_VIDEO)
{
// Use MediaInfo only for non AVI files.. Reading potentially broken AVI files with the VfW API (as MediaInfo
// is doing) is rather dangerous.
if (!bIsAVI)
{
try
{
USES_CONVERSION;
if (theMediaInfoDLL.Initialize())
{
void* Handle = (*theMediaInfoDLL.fpMediaInfo_Open)((LPSTR)T2CA(pFile->GetFilePath()));
if (Handle)
{
CStringA str;
mi->strFileFormat = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_General, 0, "Format_String", Info_Text, Info_Name);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_General, 0, "PlayTime", Info_Text, Info_Name);
float fFileLengthSec = atoi(str) / 1000.0;
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_General, 0, "VideoCount", Info_Text, Info_Name);
int iVideoStreams = atoi(str);
if (iVideoStreams > 0)
{
mi->iVideoStreams = iVideoStreams;
mi->fVideoLengthSec = fFileLengthSec;
CStringA strCodecA = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Video, 0, "Codec", Info_Text, Info_Name);
mi->strVideoFormat = strCodecA;
if (!strCodecA.IsEmpty())
mi->video.bmiHeader.biCompression = *(LPDWORD)(LPCSTR)strCodecA;
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Video, 0, "Codec_String", Info_Text, Info_Name);
if (!str.IsEmpty())
mi->strVideoFormat += _T(" (") + CString(str) + _T(")");
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Video, 0, "Width", Info_Text, Info_Name);
mi->video.bmiHeader.biWidth = atoi(str);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Video, 0, "Height", Info_Text, Info_Name);
mi->video.bmiHeader.biHeight = atoi(str);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Video, 0, "FrameRate", Info_Text, Info_Name);
mi->fVideoFrameRate = atof(str);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Video, 0, "BitRate", Info_Text, Info_Name);
mi->video.dwBitRate = atoi(str);
bResult = true;
}
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_General, 0, "AudioCount", Info_Text, Info_Name);
int iAudioStreams = atoi(str);
if (iAudioStreams > 0)
{
mi->iAudioStreams = iAudioStreams;
mi->fAudioLengthSec = fFileLengthSec;
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "Codec", Info_Text, Info_Name);
if (sscanf(str, "%hx", &mi->audio.wFormatTag) != 1)
{
mi->strAudioFormat = str;
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "Codec_String", Info_Text, Info_Name);
if (!str.IsEmpty())
mi->strAudioFormat += _T(" (") + CString(str) + _T(")");
}
else
{
mi->strAudioFormat = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "Codec_String", Info_Text, Info_Name);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "Codec_Info", Info_Text, Info_Name);
if (!str.IsEmpty())
mi->strAudioFormat += _T(" (") + CString(str) + _T(")");
}
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "Channels", Info_Text, Info_Name);
mi->audio.nChannels = atoi(str);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "SamplingRate", Info_Text, Info_Name);
mi->audio.nSamplesPerSec = atoi(str);
str = (*theMediaInfoDLL.fpMediaInfo_Get)(Handle, Stream_Audio, 0, "BitRate", Info_Text, Info_Name);
mi->audio.nAvgBytesPerSec = atoi(str) / 8;
bResult = true;
}
(*theMediaInfoDLL.fpMediaInfo_Close)(Handle);
if (bResult)
return true;
}
}
}
catch(...)
{
ASSERT(0);
}
}
if (!IsWindow(hWndOwner))
return false;
// Avoid processing of some file types which are known to crash due to bugged DirectShow filters.
TCHAR szExt[_MAX_EXT];
_tsplitpath(pFile->GetFilePath(), NULL, NULL, NULL, szExt);
_tcslwr(szExt);
if (_tcscmp(szExt, _T(".ogm"))!=0 && _tcscmp(szExt, _T(".ogg"))!=0 && _tcscmp(szExt, _T(".mkv"))!=0)
{
try
{
CComPtr<IMediaDet> pMediaDet;
HRESULT hr = pMediaDet.CoCreateInstance(__uuidof(MediaDet));
if (SUCCEEDED(hr))
{
USES_CONVERSION;
if (SUCCEEDED(hr = pMediaDet->put_Filename(CComBSTR(T2CW(pFile->GetFilePath())))))
{
long lStreams;
if (SUCCEEDED(hr = pMediaDet->get_OutputStreams(&lStreams)))
{
for (long i = 0; i < lStreams; i++)
{
if (SUCCEEDED(hr = pMediaDet->put_CurrentStream(i)))
{
GUID major_type;
if (SUCCEEDED(hr = pMediaDet->get_StreamType(&major_type)))
{
if (major_type == MEDIATYPE_Video)
{
mi->iVideoStreams++;
if (mi->iVideoStreams > 1)
{
if (!bSingleFile)
{
if (!mi->strInfo.str.IsEmpty())
mi->strInfo << _T("\n\n");
mi->strInfo << _T("File: ") << pFile->GetFileName() << _T("\n");
}
mi->strInfo << _T("Additional Video Stream\n");
}
AM_MEDIA_TYPE mt = {0};
if (SUCCEEDED(hr = pMediaDet->get_StreamMediaType(&mt)))
{
if (mt.formattype == FORMAT_VideoInfo)
{
VIDEOINFOHEADER* pVIH = (VIDEOINFOHEADER*)mt.pbFormat;
if (mi->iVideoStreams == 1)
{
mi->video = *pVIH;
mi->video.dwBitRate = 0; // don't use this value
mi->strVideoFormat = GetVideoFormatName(mi->video.bmiHeader.biCompression);
pMediaDet->get_FrameRate(&mi->fVideoFrameRate);
bResult = true;
}
else
{
mi->strInfo << _T(" Codec:\t") << (LPCTSTR)GetVideoFormatName(pVIH->bmiHeader.biCompression) << _T("\n");
mi->strInfo << _T(" Width x Height:\t") << abs(pVIH->bmiHeader.biWidth) << _T(" x ") << abs(pVIH->bmiHeader.biHeight) << _T("\n");
// do not use that 'dwBitRate', whatever this number is, it's not
// the bitrate of the encoded video stream. seems to be the bitrate
// of the uncompressed stream divided by 2 !??
//if (pVIH->dwBitRate)
// mi->strInfo << " Bitrate:\t" << (UINT)(pVIH->dwBitRate / 1000) << " kBit/s\n";
double fFrameRate = 0.0;
if (SUCCEEDED(pMediaDet->get_FrameRate(&fFrameRate)) && fFrameRate)
mi->strInfo << _T(" Frames/sec:\t") << fFrameRate << _T("\n");
}
}
}
double fLength = 0.0;
if (SUCCEEDED(pMediaDet->get_StreamLength(&fLength)) && fLength)
{
if (mi->iVideoStreams == 1)
mi->fVideoLengthSec = fLength;
else
{
CString strLength;
SecToTimeLength(fLength, strLength);
mi->strInfo << _T(" Length:\t") << strLength;
if (pFile->IsPartFile()){
mi->strInfo << _T(" (This may not reflect the final total length!)");
}
mi->strInfo << _T("\n");
}
}
if (mt.pUnk != NULL)
mt.pUnk->Release();
if (mt.pbFormat != NULL)
CoTaskMemFree(mt.pbFormat);
if (mi->iVideoStreams > 1)
mi->strInfo << _T("\n");
}
else if (major_type == MEDIATYPE_Audio)
{
mi->iAudioStreams++;
if (mi->iAudioStreams > 1)
{
if (!bSingleFile)
{
if (!mi->strInfo.str.IsEmpty())
mi->strInfo << _T("\n\n");
mi->strInfo << _T("File: ") << pFile->GetFileName() << _T("\n");
}
mi->strInfo << _T("Additional Audio Stream\n");
}
AM_MEDIA_TYPE mt = {0};
if (SUCCEEDED(hr = pMediaDet->get_StreamMediaType(&mt)))
{
if (mt.formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX* wfx = (WAVEFORMATEX*)mt.pbFormat;
if (mi->iAudioStreams == 1)
{
memcpy(&mi->audio, wfx, sizeof mi->audio);
mi->strAudioFormat = GetWaveFormatTagName(wfx->wFormatTag);
}
else
{
CString strFormat = GetWaveFormatTagName(wfx->wFormatTag);
mi->strInfo << _T(" Format:\t") << strFormat << _T("\n");
if (wfx->nAvgBytesPerSec)
mi->strInfo << _T(" Bitrate:\t") << (UINT)(((wfx->nAvgBytesPerSec * 8.0) + 500.0) / 1000.0) << _T(" kBit/s\n");
if (wfx->nSamplesPerSec)
mi->strInfo << _T(" Samples/sec:\t") << wfx->nSamplesPerSec / 1000.0 << _T(" kHz\n");
if (wfx->wBitsPerSample)
mi->strInfo << _T(" Bit/sample:\t") << wfx->wBitsPerSample << _T(" Bit\n");
mi->strInfo << _T(" Mode:\t");
if (wfx->nChannels == 1)
mi->strInfo << _T("Mono");
else if (wfx->nChannels == 2)
mi->strInfo << _T("Stereo");
else
mi->strInfo << wfx->nChannels << _T(" channels");
mi->strInfo << _T("\n");
}
bResult = true;
}
}
double fLength = 0.0;
if (SUCCEEDED(pMediaDet->get_StreamLength(&fLength)) && fLength)
{
if (mi->iAudioStreams == 1)
mi->fAudioLengthSec = fLength;
else
{
CString strLength;
SecToTimeLength(fLength, strLength);
mi->strInfo << _T(" Length:\t") << strLength;
if (pFile->IsPartFile()){
mi->strInfo << _T(" (This may not reflect the final total length!)");
}
mi->strInfo << _T("\n");
}
}
if (mt.pUnk != NULL)
mt.pUnk->Release();
if (mt.pbFormat != NULL)
CoTaskMemFree(mt.pbFormat);
if (mi->iAudioStreams > 1)
mi->strInfo << _T("\n");
}
else{
TRACE("%s - Unknown stream type\n", pFile->GetFileName());
}
}
}
}
}
}
else{
TRACE("Failed to open \"%s\" - %s\n", pFile->GetFilePath(), GetErrorMessage(hr, 1));
}
}
}
catch(...){
ASSERT(0);
}
}
}
}
return bResult;
}
void CFileInfoDialog::DoDataExchange(CDataExchange* pDX)
{
CResizablePage::DoDataExchange(pDX);
DDX_Control(pDX, IDC_FULL_FILE_INFO, m_fi);
}
void CFileInfoDialog::Localize()
{
GetDlgItem(IDC_FD_XI1)->SetWindowText(GetResString(IDS_FD_SIZE));
GetDlgItem(IDC_FD_XI2)->SetWindowText(GetResString(IDS_LENGTH)+_T(":"));
GetDlgItem(IDC_FD_XI3)->SetWindowText(GetResString(IDS_VIDEO));
GetDlgItem(IDC_FD_XI4)->SetWindowText(GetResString(IDS_AUDIO));
GetDlgItem(IDC_FD_XI5)->SetWindowText( GetResString(IDS_CODEC)+_T(":"));
GetDlgItem(IDC_FD_XI6)->SetWindowText( GetResString(IDS_CODEC)+_T(":"));
GetDlgItem(IDC_FD_XI7)->SetWindowText( GetResString(IDS_BITRATE)+_T(":"));
GetDlgItem(IDC_FD_XI8)->SetWindowText( GetResString(IDS_BITRATE)+_T(":"));
GetDlgItem(IDC_FD_XI9)->SetWindowText( GetResString(IDS_WIDTH)+_T(":"));
GetDlgItem(IDC_FD_XI11)->SetWindowText( GetResString(IDS_HEIGHT)+_T(":"));
GetDlgItem(IDC_FD_XI13)->SetWindowText( GetResString(IDS_FPS)+_T(":"));
GetDlgItem(IDC_FD_XI10)->SetWindowText( GetResString(IDS_CHANNELS)+_T(":"));
GetDlgItem(IDC_FD_XI12)->SetWindowText( GetResString(IDS_SAMPLERATE)+_T(":"));
GetDlgItem(IDC_STATICFI)->SetWindowText( GetResString(IDS_FILEFORMAT)+_T(":"));
}
void CFileInfoDialog::AddFileInfo(LPCTSTR pszFmt, ...)
{
va_list pArgp;
va_start(pArgp, pszFmt);
CString strInfo;
strInfo.FormatV(pszFmt, pArgp);
va_end(pArgp);
m_fi.SetSel(m_fi.GetWindowTextLength(), m_fi.GetWindowTextLength());
m_fi.ReplaceSel(strInfo);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -