I want to open a video file using IMFSourceReader
to access its Frames as IMFSample.
In a WinRT C++ Class I send the RandomAccessStream
of a video file and use the following code to create an IMFSourceReader
object.
HRESULT hr = S_OK;
ComPtr<IMFSourceReader> pSourceReader;
ComPtr<IMFByteStream> spByteStream;
if (SUCCEEDED(hr))
{
// Initialize the Media Foundation platform.
hr = MFStartup(MF_VERSION);
hr = MFCreateMFByteStreamOnStreamEx((IUnknown*)InputVideoStream, &spByteStream);
ComPtr<IMFAttributes> Atrr;
hr = MFCreateAttributes(&Atrr, 10);
hr = Atrr->SetUINT32(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, true);
hr = MFCreateSourceReaderFromByteStream(spByteStream.Get(), Atrr.Get(), &pSourceReader);
}
But the HRESULT of the function MFCreateSourceReaderFromByteStream() is returning The Byte Stream Type of the Given URL is unsupported
.
I don't know what i'm doing wrong. Can anyone show me the correct way? I'm using Windows 8.1.
I have found a solution to the
The Byte Stream Type of the Given URL is unsupported
problem ofIMFSourceReader
. I could read Byte Stream ofWMV
files, someMP4
files but not all kind of video files. So before usingMFCreateSourceReaderFromByteStream()
I converted the video stream toVC-1/WMV
format which theMFCreateSourceReaderFromByteStream()
is able to read. I used the Transcoding media sample of MSDN to convert he video into WMV video. Now I am able to useMFCreateSourceReaderFromByteStream()
without any error.