Re: First frame as keyframe - writing compressed samples



On May 19, 9:35 pm, Jasleen <Jasl...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
We are writing wmv files using IWmWriter, We are writing compressed samples
using IWMWriterAdvanced's WriteStreamSample.
We want to make files of certain duration and keep on switching files.

The problem we are facing while writing compressed samples is that, files
after the first file do not start from the beginning.The file dosnt start
playing unless it encounters a key frame.

To solve this problem, instead of using the DMO wrapper filter provided by
microsoft, we wrote our own DMO wrapper filter wrapping
CLSID_CWMV9EncMediaObject, and at first frame of the every new file switched,
we set the property of the sample for WM_SampleExtensionGUID_OutputCleanPoint
as TRUE.

To achieve this I derived my buffer class from IMediaBuffer and INSSBuffer3,
and overridden SetProperty and GetProperty of INSBuffer3 interface.
The GetProperty implementation is as follows :

HRESULT STDMETHODCALLTYPE CLBVdoComBuffer::GetProperty(GUID
guidBufferProperty,void* pvBufferProperty,DWORD* pdwBufferPropertySize)
{
if(NULL == pdwBufferPropertySize)
return E_POINTER;

if( WM_SampleExtensionGUID_OutputCleanPoint == guidBufferProperty)
{
if( NULL == pvBufferProperty )
{
*pdwBufferPropertySize = sizeof( BOOL );
return S_OK;
}
else
{
if( *pdwBufferPropertySize < sizeof( BOOL ) )
{
return E_INVALIDARG;
}
else
{
*(BOOL*)pvBufferProperty =
m_bOutputCleanPoint if(m_bOutputCleanPoint)

return S_OK;
}
}
}
return (NS_E_UNSUPPORTED_PROPERTY);

}

and SetProperty implementation is :

HRESULT STDMETHODCALLTYPE CLBVdoComBuffer::SetProperty(GUID
guidBufferProperty,void* pvBufferProperty,DWORD dwBufferPropertySize)
{
if( NULL == pvBufferProperty )
return E_POINTER;

if( WM_SampleExtensionGUID_OutputCleanPoint == guidBufferProperty )
{
if( dwBufferPropertySize != sizeof(BOOL))
return E_INVALIDARG;
else
{
m_bOutputCleanPoint = *(BOOL*)pvBufferProperty;
return S_OK;
}
}
return NS_E_UNSUPPORTED_PROPERTY;

}

Despite of all this , unable to get the first frame as keyframe.
Please help.

If you're writing compressed samples, you can't simply lie and say
that a sample is compressed when it isn't. If you want the files to
start immediately and not skip any data, you need to break between
files on a keyframe.

So when you need to switch files, your code needs to wait for a
keyframe and _then_ switch files.
.


Loading