diandaolly
2010-06-13 17:10:56 UTC
I used directshow filter "wm asf writer" to encode wma for my mp3
files (which are all mono music).
Yes I did made it work. However, all generated wma files are stereo (I
used system profile WMProfile_V80_64StereoAudio).
Is it possible to configure the asf writer so that I can generate mono
wma?
The following code did generate MONO wma, but apparently problematic
since I only got strange sound. Any hint on what the problem is?
Thanks.
---------------------------------------------
// Change profile to keep mono:
CComQIPtr<IConfigAsfWriter> spiConfigAsfWriter(spiAsfWriter);
CComPtr<IWMProfile> spiProfile = NULL;
hr = spiConfigAsfWriter->GetCurrentProfile(&spiProfile); // a system
profile being used
DWORD dwCount = 0;
hr = spiProfile->GetStreamCount(&dwCount);
for (DWORD i = 0; i < dwCount; i++)
{
CComPtr<IWMStreamConfig> spiStreamConfig = NULL;
hr = spiProfile->GetStream(i, &spiStreamConfig);
GUID guidST;
hr = spiStreamConfig->GetStreamType(&guidST);
if (WMMEDIATYPE_Audio == guidST)
{
CComQIPtr<IWMMediaProps> pAudioPro(spiStreamConfig);
DWORD dwSize = 0;
pAudioPro->GetMediaType(NULL, &dwSize);
ByteArray baMT(dwSize);
WM_MEDIA_TYPE * pmt = (WM_MEDIA_TYPE *)baMT.GetData();
::ZeroMemory(pmt, dwSize);
pAudioPro->GetMediaType(pmt, &dwSize);
if (pmt->majortype == MEDIATYPE_Audio)
{
if (pmt->formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX * pwfx = (WAVEFORMATEX *)pmt->pbFormat;
pwfx->nChannels = 1; // ensure mono
//
// what else fields should I change? and how?
//
}
}
hr = pAudioPro->SetMediaType(pmt);
hr = spiProfile->ReconfigStream(spiStreamConfig);
hr = spiConfigAsfWriter-
files (which are all mono music).
Yes I did made it work. However, all generated wma files are stereo (I
used system profile WMProfile_V80_64StereoAudio).
Is it possible to configure the asf writer so that I can generate mono
wma?
The following code did generate MONO wma, but apparently problematic
since I only got strange sound. Any hint on what the problem is?
Thanks.
---------------------------------------------
// Change profile to keep mono:
CComQIPtr<IConfigAsfWriter> spiConfigAsfWriter(spiAsfWriter);
CComPtr<IWMProfile> spiProfile = NULL;
hr = spiConfigAsfWriter->GetCurrentProfile(&spiProfile); // a system
profile being used
DWORD dwCount = 0;
hr = spiProfile->GetStreamCount(&dwCount);
for (DWORD i = 0; i < dwCount; i++)
{
CComPtr<IWMStreamConfig> spiStreamConfig = NULL;
hr = spiProfile->GetStream(i, &spiStreamConfig);
GUID guidST;
hr = spiStreamConfig->GetStreamType(&guidST);
if (WMMEDIATYPE_Audio == guidST)
{
CComQIPtr<IWMMediaProps> pAudioPro(spiStreamConfig);
DWORD dwSize = 0;
pAudioPro->GetMediaType(NULL, &dwSize);
ByteArray baMT(dwSize);
WM_MEDIA_TYPE * pmt = (WM_MEDIA_TYPE *)baMT.GetData();
::ZeroMemory(pmt, dwSize);
pAudioPro->GetMediaType(pmt, &dwSize);
if (pmt->majortype == MEDIATYPE_Audio)
{
if (pmt->formattype == FORMAT_WaveFormatEx)
{
WAVEFORMATEX * pwfx = (WAVEFORMATEX *)pmt->pbFormat;
pwfx->nChannels = 1; // ensure mono
//
// what else fields should I change? and how?
//
}
}
hr = pAudioPro->SetMediaType(pmt);
hr = spiProfile->ReconfigStream(spiStreamConfig);
hr = spiConfigAsfWriter-
ConfigureFilterUsingProfile(spiProfile);
}