//------------------------------------------------------------------- // Initialise the source reader // HRESULT VidReader::initSourceReader(WCHAR *filename) { HRESULT hr = S_OK; IMFAttributes *pAttributes = NULL; SafeRelease(&m_pReader); // Configure the source reader to perform video processing hr = MFCreateAttributes(&pAttributes, 1); if (FAILED(hr)) goto done; hr = pAttributes->SetUINT32(MF_SOURCE_READER_ENABLE_VIDEO_PROCESSING, TRUE); if (FAILED(hr)) goto done; // Create the source reader from the URL hr = MFCreateSourceReaderFromURL(filename, pAttributes, &m_pReader); if (FAILED(hr)) goto done; // Attempt to find a video stream hr = selectVideoStream(); if (FAILED(hr)) goto done; // Get the stream format hr = getVideoFormat(); if (FAILED(hr)) goto done; // Get the duration hr = getDuration(); done: return hr; }
void Demuxer::selectFirstVideoStream() { std::set< std::shared_ptr<Stream> > videoStreams = getStreamsOfType(Video); if (videoStreams.size()) selectVideoStream(std::dynamic_pointer_cast<VideoStream>(*videoStreams.begin())); }