I have an IP camera streaming video into blackbox buffer code that a company provided me. They also provided me example code of how i can take the buffer and convert it to an unsigned char* array. With this array I can create an AVI file and save the video buffer to it and create a video file.
for( unsigned short lLine = 0; lLine < mSizeY -1; lLine++)
{
NumOfLines = lLine;
unsigned char *lCurLine = (unsigned char *)aBuffer + (lLine) * mSizeX * mBPP;
unsigned char *lCurLineInv = temp + (mSizeY - lLine - 1) * mSizeX * mBPP;
::memcpy(lCurLineInv, lCurLine, mSizeX * mBPP );
}
AVIStreamWrite(mAVICompressedStream, mLastSample, 1, temp, mImageSize, AVIIF_KEYFRAME, &lSamplesWritten, &lBytesWritten )
Its a开发者_如何学编程 terrible system in so many ways. Including the fact that it's all done in VFW
Currently im doing all of this code in C# and in a C++/CLi DLL. I know how to use Directshow.Net and i was wondering if there is a more elegant way to save this video buffer i have to an avi file or something that i can easily work on in say DirectShow or DirectShow.net?
Take a look at DirectShow.net's source filter sample in Samples\Misc\GSSF
. I probably wouldn't rewrite to DS just to avoid VFW, though: I've had stability issues using it even in C++, so only I'd do it to get output format flexability. Media Foundation is the new hotness if you can ditch < Vista.
Check out AForge.Net. Its a c# wrapper for VfW, DirectShow and FFMpeg. The FFMpeg route should be the most elegant and robust.
精彩评论