Пример #1
0
long AVIWriter::openAVI(const char* pName,long x ,long y, float fps,short ch,
						short baudio,long rate,int nVideoFormat)
{	
	if( fp !=  0 ){
		closeAVI();
	}
	fp = fopen(pName, "wb");	
	if( NULL == fp ){
		return -1;
	} 
	width = x;
	height = y;
	this->fps = fps;
	this->nVideoFormat = nVideoFormat;
	nAudioChannel = ch;
	nAudioRate = rate;
	WriteHeader();
	indexlist.clear();
	return 0;
}
Пример #2
0
AVIWriter::~AVIWriter()
{
	if( fp ){
        closeAVI();
	}
}
Пример #3
0
	/**
	 * デストラクタ
	 */
	~LayerExAVI() {
		closeAVI();
	}
Пример #4
0
	/**
	 * AVIファイルを開く
	 * @param filename 保存ファイル名
	 * @param fps 秒間フレーム数
	 */
	void openAVI(const tjs_char *filename, int fps) {

		closeAVI();

		// 録画開始時のサイズを記録しておく
		aviWidth  = _width;
		aviHeight = _height;

		// AVIファイルを開く
		ttstr path = TVPNormalizeStorageName(ttstr(filename));
		TVPGetLocalName(path);
		if (AVIFileOpen(&pavi, path.c_str(), OF_CREATE | OF_WRITE | OF_SHARE_DENY_NONE,NULL) != 0)	{
			ttstr msg = filename;
			msg += ":can't open";
			TVPThrowExceptionMessage(msg.c_str());
		}

		// AVIストリームの生成
		AVISTREAMINFO si = {	
			streamtypeVIDEO, // Video Stream
			comptypeDIB,
			0,               // Stream Flag
			0,
			0,
			0,
			1,               // 時間単位 dwScale
			fps,             // フレーム dwRate
			0,
			0,         // ストリームの長さ XXX
			0,
			0,
			(DWORD)-1,       // -1: Default品質 [0-10000]
			0,
			// 表示する矩形サイズ
			{ 0, 0, aviWidth, aviHeight },
			0,
			0,
			L"KIRIKIRI" };

		if (AVIFileCreateStream(pavi, &pstm, &si) != 0) {
			closeAVI();
			TVPThrowExceptionMessage(L"AVIFileCreateStream");
                }


		// ストリームに投げ込むデータフォーマットを指定

		BITMAPINFOHEADER bih;
		bih.biSize = sizeof(bih);
		bih.biWidth  = aviWidth;
		bih.biHeight = aviHeight;
		bih.biPlanes = 1;
		bih.biBitCount = 32;
		bih.biCompression = BI_RGB;
		bih.biSizeImage = 0;
		bih.biXPelsPerMeter = 0;
		bih.biYPelsPerMeter = 0;
		bih.biClrUsed = 0;
		bih.biClrImportant = 0;

		if (AVIStreamSetFormat(pstm, 0, &bih, sizeof(bih)) != 0 ) {
			closeAVI();
			TVPThrowExceptionMessage(L"AVIFileCreateStream");
		}

		// 先頭フレーム
                lastFrame = -1;

                hasCv = false;
        }
Пример #5
0
	/**
	 * AVIファイルを圧縮フォーマットを指定して開く
	 * @param filename 保存ファイル名
	 * @param fps 秒間フレーム数
         * @param return 圧縮ダイアログでキャンセルを押した場合false。
	 */
	bool openCompressedAVI(const tjs_char *filename, int fps) {

		closeAVI();

		// 録画開始時のサイズを記録しておく
		aviWidth  = _width;
		aviHeight = _height;

		// ストリームに投げ込むデータフォーマットを指定

		BITMAPINFOHEADER bih;
		bih.biSize = sizeof(bih);
		bih.biWidth  = aviWidth;
		bih.biHeight = aviHeight;
		bih.biPlanes = 1;
		bih.biBitCount = 32;
		bih.biCompression = BI_RGB;
		bih.biSizeImage = 0;
		bih.biXPelsPerMeter = 0;
		bih.biYPelsPerMeter = 0;
		bih.biClrUsed = 0;
		bih.biClrImportant = 0;

                // 圧縮オプションを取得
                memset(&cv,0,sizeof(COMPVARS));
                cv.cbSize=sizeof(COMPVARS);
                cv.dwFlags=ICMF_COMPVARS_VALID;
                cv.fccHandler=comptypeDIB;
                cv.lQ=ICQUALITY_DEFAULT;
                if (!ICCompressorChoose(NULL,ICMF_CHOOSE_DATARATE | ICMF_CHOOSE_KEYFRAME,
                                        &bih,NULL,&cv,NULL)) {
                  return false;
                }

                // オプションを指定
                opt.fccType=streamtypeVIDEO;
                opt.fccHandler=cv.fccHandler;
                opt.dwKeyFrameEvery=cv.lKey;
                opt.dwQuality=cv.lQ;
                opt.dwBytesPerSecond=cv.lDataRate;
                opt.dwFlags=(cv.lDataRate>0?AVICOMPRESSF_DATARATE:0)
                  |(cv.lKey>0?AVICOMPRESSF_KEYFRAMES:0);
                opt.lpFormat=NULL;
                opt.cbFormat=0;
                opt.lpParms=cv.lpState;
                opt.cbParms=cv.cbState;
                opt.dwInterleaveEvery=0;
                

		// AVIファイルを開く
		ttstr path = TVPNormalizeStorageName(ttstr(filename));
		TVPGetLocalName(path);
		if (AVIFileOpen(&pavi, path.c_str(), OF_CREATE | OF_WRITE | OF_SHARE_DENY_NONE,NULL) != 0)	{
			ttstr msg = filename;
			msg += ":can't open";
			TVPThrowExceptionMessage(msg.c_str());
		}

		// AVIストリームの生成
		AVISTREAMINFO si = {	
			streamtypeVIDEO, // Video Stream
			comptypeDIB,
			0,               // Stream Flag
			0,
			0,
			0,
			1,               // 時間単位 dwScale
			fps,             // フレーム dwRate
			0,
			10,         // ストリームの長さ XXX
			0,
			0,
			(DWORD)-1,       // -1: Default品質 [0-10000]
			0,
			// 表示する矩形サイズ
			{ 0, 0, aviWidth, aviHeight },
			0,
			0,
			L"KIRIKIRI" };
                si.fccHandler=cv.fccHandler;

		if (AVIFileCreateStream(pavi, &pstm, &si) != 0) {
			closeAVI();
			TVPThrowExceptionMessage(L"AVIFileCreateStream");
		}
                if (AVIMakeCompressedStream(&ptmp,pstm,&opt,NULL)!=AVIERR_OK) {
                  closeAVI();
                  TVPThrowExceptionMessage(L"AVIMakeCompressedStream");
                }

		if (AVIStreamSetFormat(ptmp, 0, &bih, sizeof(bih)) != 0 ) {
			closeAVI();
			TVPThrowExceptionMessage(L"AVIFileCreateStream");
		}

		// 先頭フレーム
		lastFrame = -1;

                hasCv = true;

                return true;
	}