void CAVIGenerator::ReleaseEngine() { Revel_Error revError; int totalSize; revError = Revel_EncodeEnd(encoderHandle, &totalSize); if (revError != REVEL_ERR_NONE) { return; } Revel_DestroyEncoder(encoderHandle); released = true; }
void endRecord(){ // while(!rQueue.empty()){ // processQueue(); // } if(numFrames > 0){ // Encode the audio track. NOTE that each call to Revel_EncodeAudio() // *appends* the new audio data onto the existing audio track. There is // no synchronization between the audio and video tracks! If you want // the audio to start on frame 60, you need to manually insert 60 frames // worth of silence at the beginning of your audio track! // // To demonstrate this, we'll encode the audio buffer twice. Note that // the two chimes play immediately when the movie starts, one after the // other, even though we're encoding them "after" all the video frames. int totalAudioBytes = 0; revError = Revel_EncodeAudio(encoderHandle, audioBuffer, audioBufferSize, &totalAudioBytes); revError = Revel_EncodeAudio(encoderHandle, audioBuffer, audioBufferSize, &totalAudioBytes); if (revError != REVEL_ERR_NONE) { printf("Revel Error while writing audio: %d\n", revError); exit(1); } printf("Encoded %d bytes of audio\n", totalAudioBytes); // Finalize encoding. If this step is skipped, the output movie will be // unviewable! int totalSize; revError = Revel_EncodeEnd(encoderHandle, &totalSize); if (revError != REVEL_ERR_NONE) { printf("Revel Error while ending encoding: %d\n", revError); exit(1); } printf("%s written: %dx%d, %d frames, %d bytes\n", filename, width, height, numFrames, totalSize); // Final cleanup. // Revel_DestroyEncoder(encoderHandle); // if (audioBuffer != NULL) // delete [] audioBuffer; // delete [] (int*)frame.pixels; } }
int main(int argc, char *argv[]) { const char *filename = "checkers.avi"; int numFrames = 64; Revel_Error revError; // Make sure the encoder is valid if (!Revel_IsEncoderValid(encoderHandle)) { return -1; } // Attempt to load some sound data, to encode into the output movie's // audio stream. bool hasAudio = false; char *audioBuffer = NULL; int audioBufferSize = 0; LoadAudio(&hasAudio, &audioBuffer, &audioBufferSize); if (!hasAudio) { printf("Warning: Failed to load audio test file: chimes.raw\n"); printf(" The audio encoding tests will be skipped.\n"); } // Initiate encoding revError = Revel_EncodeStart(encoderHandle, filename); if (revError != REVEL_ERR_NONE) { printf("Revel Error while starting encoding: %d\n", revError); exit(1); } // Draw and encode each frame. Revel_VideoFrame frame; frame.width = width; frame.height = height; frame.bytesPerPixel = 4; frame.pixelFormat = REVEL_PF_RGBA; frame.pixels = new int[width*height]; memset(frame.pixels, 0, width*height*4); for(int i=0; i<numFrames; ++i) { DrawFrame(frame.width, frame.height, 0xFF000000 + 0x000004*i, i, i, (int*)frame.pixels); int frameSize = 0; revError = Revel_EncodeFrame(encoderHandle, &frame, &frameSize); if (revError != REVEL_ERR_NONE) { printf("Revel Error while writing frame: %d\n", revError); exit(1); } printf("Frame %d of %d: %d bytes\n", i+1, numFrames, frameSize); } // Encode the audio track. NOTE that each call to Revel_EncodeAudio() // *appends* the new audio data onto the existing audio track. There is // no synchronization between the audio and video tracks! If you want // the audio to start on frame 60, you need to manually insert 60 frames // worth of silence at the beginning of your audio track! // // To demonstrate this, we'll encode the audio buffer twice. Note that // the two chimes play immediately when the movie starts, one after the // other, even though we're encoding them "after" all the video frames. int totalAudioBytes = 0; revError = Revel_EncodeAudio(encoderHandle, audioBuffer, audioBufferSize, &totalAudioBytes); revError = Revel_EncodeAudio(encoderHandle, audioBuffer, audioBufferSize, &totalAudioBytes); if (revError != REVEL_ERR_NONE) { printf("Revel Error while writing audio: %d\n", revError); exit(1); } printf("Encoded %d bytes of audio\n", totalAudioBytes); // Finalize encoding. If this step is skipped, the output movie will be // unviewable! int totalSize = 0; revError = Revel_EncodeEnd(encoderHandle, &totalSize); if (revError != REVEL_ERR_NONE) { printf("Revel Error while ending encoding: %d\n", revError); exit(1); } printf("%s written: %dx%d, %d frames, %d bytes\n", filename, width, height, numFrames, totalSize); // Final cleanup. Revel_DestroyEncoder(encoderHandle); if (audioBuffer != NULL) delete [] audioBuffer; delete [] (int*)frame.pixels; return 0; }