다중 비트레이트 상호 배제 사용
[Windows Media Format 11 SDK 이 페이지와 연결된 기능은 레거시 기능입니다. 원본 판독기와 싱크 작성기에 의해 대체되었습니다. 원본 판독기 및 싱크 기록기 Windows 10 및 Windows 11에 최적화되었습니다. 가능한 경우 새 코드에서 Windows Media Format 11 SDK 대신 원본 판독기 및 싱크 기록기 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
MBR(다중 비트 전송률) 상호 제외는 다양한 재생 시나리오에 대한 콘텐츠를 인코딩하려는 경우에 유용합니다. MBR 비디오 출력은 각각 서로 다른 비트 전송률 설정을 사용하여 여러 번 인코딩된 단일 입력으로 구성됩니다. MBR 인코딩이 있는 파일을 읽을 때 판독기는 사용 가능한 대역폭에 따라 사용할 스트림을 결정합니다.
Windows Media Format SDK는 비디오 및 오디오 스트림 모두에 대해 MBR 인코딩을 지원합니다. 또한 다중 비디오 크기 MBR 인코딩이라는 특수 형식의 MBR 인코딩을 만들 수 있습니다. 다중 비디오 크기의 MBR 비디오는 일반 MBR 비디오와 동일하게 작동합니다. 단, 상호 제외에서 비디오 스트림에 대해 다른 이미지 크기를 지정할 수 있습니다.
다음 예제에서는 여러 비디오 크기로 MBR 비디오에 대한 프로필을 설정하는 방법을 보여 줍니다. 다양한 비트 속도와 크기의 세 개의 비디오 스트림을 사용하여 새 프로필을 만들고 상호 제외 개체에 포함합니다.
IWMProfileManager* pProfileMgr = NULL;
IWMProfile* pProfile = NULL;
IWMMutualExclusion* pMutex = NULL;
IWMStreamConfig* pStream = NULL;
IWMMediaProps* pMediaProps = NULL;
WM_MEDIA_TYPE* pMediaType = NULL;
DWORD cbMediaType = 0;
HRESULT hr = S_OK;
// Initialize COM.
hr = CoInitialize(NULL);
// Create a profile manager object.
hr = WMCreateProfileManager(&pProfileMgr);
// Create an empty profile.
hr = pProfileMgr->CreateEmptyProfile(WMT_VER_9_0, &pProfile);
// Give the new profile a name and description.
hr = pProfile->SetName(L"MBR_Video_3_Stream_test");
hr = pProfile->SetDescription(L"Only for use with example code.");
// Create the first stream.
hr = pProfile->CreateNewStream(WMMEDIATYPE_Video, &pStream);
// Get the media properties interface for the new stream.
hr = pStream->QueryInterface(IID_IWMMediaProps, (void**)&pMediaProps);
// Get the media-type structure.
// First, get the size of the media-type structure.
hr = pMediaProps->GetMediaType(NULL, &cbMediaType);
// Allocate memory for the structure based on the retrieved size.
pMediaType = (WM_MEDIA_TYPE*) new BYTE[cbMediaType];
// Retrieve the media-type structure.
hr = pMediaProps->GetMediaType(pMediaType, &cbMediaType);
// Change the video size to 640 x 480.
pMediaType->pbFormat->bmiHeader.biWidth = 640;
pMediaType->pbFormat->bmiHeader.biHeight = 480;
// Replace the WM_MEDIA_TYPE in the profile with the one just changed.
hr = pMediaProps->SetMediaType(pMediaType);
// Release the media properties interface and delete the structure.
pMediaProps->Release();
pMediaProps = NULL;
delete[] pMediaType;
pMediaType = NULL;
// Set the bit rate to 200.
hr = pStream->SetBitrate(200000);
// Set the stream number.
hr = pStream->SetStreamNumber(1);
// Include the new stream in the profile.
hr = pProfile->AddStream(pStream);
// Release the stream configuration interface.
pStream->Release();
pStream = NULL;
// For the remaining two streams, leave the video at its default size of
// 320 x 240 <entity type="ndash"/>- just change the bit rates.
// Repeat for a 100K stream.
hr = pProfile->CreateNewStream(WMMEDIATYPE_Video, &pStream);
hr = pStream->SetBitrate(100000);
hr = pStream->SetStreamNumber(2);
hr = pProfile->AddStream(pStream);
pStream->Release();
pStream = NULL;
// Repeat for a 56K stream.
hr = pProfile->CreateNewStream(WMMEDIATYPE_Video, &pStream);
hr = pStream->SetBitrate(56000);
hr = pStream->SetStreamNumber(3);
hr = pProfile->AddStream(pStream);
pStream->Release();
pStream = NULL;
// Now that we have three streams, create a mutual exclusion object.
hr = pProfile->CreateNewMutualExclusion(&pMutex);
// Add the three streams to the mutual exclusion.
hr = pMutex->AddStream(1);
hr = pMutex->AddStream(2);
hr = pMutex->AddStream(3);
// Configure the mutual exclusion for MBR video.
hr = pMutex->SetType(CLSID_WMMUTEX_Bitrate);
// Add the mutual exclusion to the profile.
hr = pProfile->AddMutualExclusion(pMutex);
// Release the mutual exclusion object.
pMutex->Release();
pMutex = NULL;
// TODO: Save the profile to a string, and save the string to a file.
// For more information, see To Save a Custom Profile.
// Release remaining interfaces.
pProfile->Release();
pProfile = NULL;
pProfileMgr->Release();
pProfileMgr = NULL;
관련 항목