int capture(unsigned char* sps, unsigned int spsLen, unsigned char* pps, unsigned int ppsLen, unsigned char* IFrame, unsigned int IFrameLen, const char* imageFileName)
{
std::string tempFile = imageFileName+ "_temp";
FILE* fp = fopen(tempFile.c_str(), "wb");
char h264FrameHead[4] = {0x00, 0x00, 0x00, 0x01};
fwrite(h264FrameHead, 4, 1, fp);
fwrite(sps, spsLen, 1, fp);
fwrite(h264FrameHead, 4, 1, fp);
fwrite(pps, ppsLen, 1, fp);
fwrite(h264FrameHead, 4, 1, fp);
fwrite(IFrame, IFrameLen, 1, fp);
fflush(fp);
fclose(fp);
char cmd[256];
memset(cmd,0,256);
snprintf(cmd,256,"/opt/mediaserver/bin/ffmpeg -i %s -y -ss 00:00:00 -vframes 1 %s>/dev/null", tempFile.c_str(), imageName.c_str());
system(cmd);
remove(tempFile.c_str());
}