[Windows Media Format 11 SDK 이 페이지와 연결된 기능은 레거시 기능입니다. 원본 판독기와 싱크 작성기로 대체되었습니다. 원본 판독기 및 싱크 기록기 Windows 10 및 Windows 11에 최적화되었습니다. 가능한 경우 새 코드에서 Windows Media Format 11 SDK 대신 원본 판독기 및 싱크 기록기 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
데이터와 일치하는 입력 형식을 식별한 경우 IWMWriter::SetInputProps호출하여 작성기에서 사용하도록 설정할 수 있습니다.
비디오 스트림의 경우 입력 샘플에서 프레임의 크기를 설정해야 합니다. 다음 예제 코드에서는 비디오 입력을 구성하고 설정하는 방법을 보여 줍니다. 입력 형식을 열거하는 방법 섹션에 정의된 FindInputFormat 함수를 사용하여 24비트 RGB 비디오의 입력 형식을 가져옵니다. 이 코드를 사용하는 방법에 대한 자세한 내용은 코드 예제 사용을 참조하세요.
HRESULT ConfigureVideoInput(IWMWriter* pWriter,
DWORD dwInput,
GUID guidSubType,
LONG lFrameWidth,
LONG lFrameHeight)
{
DWORD cbSize = 0;
LONG lStride = 0;
IWMInputMediaProps* pProps = NULL;
WM_MEDIA_TYPE* pType = NULL;
WMVIDEOINFOHEADER* pVidHdr = NULL;
BITMAPINFOHEADER* pbmi = NULL;
// Get the base input format for the required subtype.
HRESULT hr = FindInputFormat(pWriter, dwInput, guidSubType, &pProps);
if (FAILED(hr))
{
goto Exit;
}
// Get the size of the media type structure.
hr = pProps->GetMediaType(NULL, &cbSize);
if (FAILED(hr))
{
goto Exit;
}
// Allocate memory for the media type structure.
pType = (WM_MEDIA_TYPE*) new (std::nothrow) BYTE[cbSize];
if (pType == NULL)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
// Get the media type structure.
hr = pProps->GetMediaType(pType, &cbSize);
if (FAILED(hr))
{
goto Exit;
}
// Adjust the format to match your source images.
// First set pointers to the video structures.
pVidHdr = (WMVIDEOINFOHEADER*) pType->pbFormat;
pbmi = &(pVidHdr->bmiHeader);
pbmi->biWidth = lFrameWidth;
pbmi->biHeight = lFrameHeight;
// Stride = (width * bytes/pixel), rounded to the next DWORD boundary.
lStride = (lFrameWidth * (pbmi->biBitCount / 8) + 3) & ~3;
// Image size = stride * height.
pbmi->biSizeImage = lFrameHeight * lStride;
// Apply the adjusted type to the video input.
hr = pProps->SetMediaType(pType);
if (FAILED(hr))
{
goto Exit;
}
hr = pWriter->SetInputProps(dwInput, pProps);
Exit:
delete [] pType;
SAFE_RELEASE(pProps);
return hr;
}
관련 항목