Chr1snv
2010-05-03 22:13:01 UTC
Hi Everyone,
I'm new to the Windows Media Format SDK, and have been playing around with
it a bit, and after [semi] reading the documentation, I'm a bit stuck.
Basically I'm trying to grab some rendered frames from the graphics card,
and encode them into a windows media file in real time.
But, I don't quite understand how to go about writing a raw frame to the
IWMWriter.
The code I am using is (taken mostly from the media format sdk help file):
(called once at the start of the program)
//create the writer
HRESULT hr;
hr = WMCreateWriter(NULL, &pWriter);
if ( FAILED ( hr ) )
exit(1);
//set its profile
//set a defualt codec
hr = pWriter->SetProfileByID(WMProfile_V80_56VideoOnly);
if ( FAILED ( hr ) )
exit(2);
//set its output file
hr = pWriter->SetOutputFilename( L"test.wmv" );
if ( FAILED ( hr ) )
exit(3);
//ready it for data
hr = pWriter->BeginWriting();
if( FAILED ( hr ) )
exit(4);
and then (per frame)
//write the frame to the video for encoding
DWORD sampleSize = 10240; //guess
INSSBuffer* pSample = NULL;
hr = pWriter->AllocateSample( sampleSize, &pSample );
if( FAILED ( hr ) )
return;
(plus the actual writing of the data to the sample, and the WriteSample call)
From reading the documentation, I understand that a IWMWriter is configured
with a profile which consists of streams.
And that samples have headers of some sort, but I'm still confused about:
How to know how big a sample is when you allocate it?
and
How to know what resolution of a video you are encoding?
Greatly Appreciated,
Chris Hoffman
I'm new to the Windows Media Format SDK, and have been playing around with
it a bit, and after [semi] reading the documentation, I'm a bit stuck.
Basically I'm trying to grab some rendered frames from the graphics card,
and encode them into a windows media file in real time.
But, I don't quite understand how to go about writing a raw frame to the
IWMWriter.
The code I am using is (taken mostly from the media format sdk help file):
(called once at the start of the program)
//create the writer
HRESULT hr;
hr = WMCreateWriter(NULL, &pWriter);
if ( FAILED ( hr ) )
exit(1);
//set its profile
//set a defualt codec
hr = pWriter->SetProfileByID(WMProfile_V80_56VideoOnly);
if ( FAILED ( hr ) )
exit(2);
//set its output file
hr = pWriter->SetOutputFilename( L"test.wmv" );
if ( FAILED ( hr ) )
exit(3);
//ready it for data
hr = pWriter->BeginWriting();
if( FAILED ( hr ) )
exit(4);
and then (per frame)
//write the frame to the video for encoding
DWORD sampleSize = 10240; //guess
INSSBuffer* pSample = NULL;
hr = pWriter->AllocateSample( sampleSize, &pSample );
if( FAILED ( hr ) )
return;
(plus the actual writing of the data to the sample, and the WriteSample call)
From reading the documentation, I understand that a IWMWriter is configured
with a profile which consists of streams.
And that samples have headers of some sort, but I'm still confused about:
How to know how big a sample is when you allocate it?
and
How to know what resolution of a video you are encoding?
Greatly Appreciated,
Chris Hoffman