// Add a video frame to the file void AddFrame (CScreen *pScreen_) { DWORD size; // Ignore if we're not recording or we're expecting audio if (!f || !fWantVideo) return; // Old-style AVI has a 2GB size limit, so restart if we're within 1MB of that if (ftell(f) >= 0x7ff00000) { Stop(); // Restart for a continuation volume if (!Start(fHalfSize)) return; } // Start of file? if (ftell(f) == 0) { // Store the dimensions, and allocate+invalidate the frame copy width = pScreen_->GetPitch() >> (fHalfSize?1:0); height = pScreen_->GetHeight() >> (fHalfSize?1:0); size = (DWORD)width * (DWORD)height; pbCurr = new BYTE[size]; memset(pbCurr, 0xff, size); // Write the placeholder file headers WriteFileHeaders(f); }
void Stop () { // Ignore if we're not recording if (!f) return; // Silence the sound in case index generation is slow Sound::Silence(); // Complete the movi chunk, add the index, and complete the RIFF WriteChunkEnd(f, lMoviPos); WriteIndex(f); WriteChunkEnd(f, lRiffPos); // Write the completed file headers WriteFileHeaders(f); // Seek to end before closing if (fseek(f, 0, SEEK_END) != 0) TRACE("!!! AVI::Stop(): Failed to seek to end of recording\n"); // Close the recording fclose(f); f = nullptr; // Free current frame data delete[] pbCurr, pbCurr = nullptr; // Free resample buffer delete[] pbResample, pbResample = nullptr; Frame::SetStatus("Saved %s", pszFile); }
// Description: // // Arguments: // // Return: // bool CVisualLog::OpenLogs() { m_sFormat = m_pCVVisualLogImageFormat->GetString(); m_eFormat = GetFormatType( m_sFormat ); m_sLogFolder = m_pCVVisualLogFolder->GetString(); int iLogFolderLen = m_sLogFolder.length(); // Check we have good params to use if ( m_eFormat == EVLF_NONE || iLogFolderLen == 0 ) { GameWarning( "[VisualLog] File format or log folder value invalid" ); return false; } // Create base directory if necessary CryCreateDirectory( m_sLogFolder ); // Figure out next number in sequence m_sLogFolderName/m_sLogFolderNameXXXX, where XXXX is 0000, 0001, etc. int iSeqNum = 0; __finddata64_t fd; intptr_t handle = _findfirst64( PathUtil::Make( m_sLogFolder , "*.*" ), &fd ); if ( handle != -1 ) { do { // Is it a directory with our base name as a prefix? if ( fd.attrib & _A_SUBDIR && fd.name[0]!='.' && !_strnicmp( m_sLogFolder, fd.name, iLogFolderLen ) ) { iSeqNum = max( iSeqNum, atoi( fd.name + iLogFolderLen ) + 1 ); } } while (0 == _findnext64 (handle, &fd)); _findclose(handle); } // Now create directory char sLogPath[256]; _snprintf( sLogPath, sizeof(sLogPath), "%s\\%s%04d", m_sLogFolder.c_str(), m_sLogFolder.c_str(), iSeqNum ); if ( !CryCreateDirectory( sLogPath ) ) { GameWarning( "[VisualLog] Unable to create directory for log files: %s", sLogPath ); return false; } m_sLogPath = sLogPath; m_iLogFolderNum = iSeqNum; char sLogFileName[256]; _snprintf( sLogFileName, sizeof(sLogFileName), "%s\\%s%04d.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum ); char sLogParamsFileName[256]; _snprintf( sLogParamsFileName, sizeof(sLogParamsFileName), "%s\\%s%04d_params.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum ); // Open Log Files m_fLogFile = fxopen(sLogFileName, "w"); m_fLogParamsFile = fxopen(sLogParamsFileName, "w"); if ( !m_fLogFile || !m_fLogParamsFile ) { GameWarning( "[VisualLog] Unable to open log files [%s] [%s]", sLogFileName, sLogParamsFileName ); CloseLogs(); return false; } WriteFileHeaders( sLogFileName, sLogParamsFileName ); return true; }