I modified the transcode sample to record microphone to wmv file. The record stopped when I unplugged the mic.
However, the recorded file show that the length of the media is 0:00:00 (file size looks alright though).
This is due to hr = pEvent->GetStatus(&hrStatus); giving hrStatus of 0xc00d4e86, causing the session to auto-terminate.
Thus the output file did not close and finalise properly. Is there a way to solve this ?
HRESULT CTranscoder::Transcode() { assert (m_pSession); IMFMediaEvent* pEvent = NULL; MediaEventType meType = MEUnknown; // Event type HRESULT hr = S_OK; HRESULT hrStatus = S_OK; // Event status //Get media session events synchronously while (meType != MESessionClosed) { hr = m_pSession->GetEvent(0, &pEvent); if (FAILED(hr)) { break; } // Get the event type. hr = pEvent->GetType(&meType); if (FAILED(hr)) { break; } hr = pEvent->GetStatus(&hrStatus); if (FAILED(hr)) { break; } if (FAILED(hrStatus)) { wprintf_s(L"Failed. 0x%X error condition triggered this event.\n", hrStatus); hr = hrStatus; break; } switch (meType) { case MESessionTopologySet: hr = Start(); if (SUCCEEDED(hr)) { wprintf_s(L"Ready to start.\n"); } break; case MESessionStarted: wprintf_s(L"Started encoding...\n"); break; case MESessionEnded: hr = m_pSession->Close(); if (SUCCEEDED(hr)) { wprintf_s(L"Finished encoding.\n"); } break; case MESessionClosed: wprintf_s(L"Output file created.\n"); break; } if (FAILED(hr)) { break; } SafeRelease(&pEvent); } SafeRelease(&pEvent); return hr; }