Exemple #1
0
HRESULT CAVIGenerator::InitEngine()
{
	Revel_Error revError;
	Revel_Params revParams;

	Revel_InitializeParams(&revParams);
    revParams.width = m_bih.biWidth;
    revParams.height =m_bih.biHeight;
    revParams.frameRate = 10.0f;
    revParams.quality = 0.5f;
    revParams.codec = REVEL_CD_XVID;
    revParams.hasAudio = 0;

	
    revError = Revel_CreateEncoder(&encoderHandle);
    if (revError != REVEL_ERR_NONE)
    {
	   return -1;
    }
  int len = wcslen(m_sFile);
  char t[1024];
  
  WideCharToMultiByte(CP_ACP, 0, m_sFile, len,
                      t, len, NULL, NULL);
  t[len]='\0';


	revError = Revel_EncodeStart(encoderHandle, t, &revParams);

	if (revError != REVEL_ERR_NONE)
    {
		return -1;
	}

	return 1;

}
void initRecord(){

	// Attempt to load some sound data, to encode into the output movie's
	// audio stream.
	bool hasAudio = false;

	audioBuffer = NULL;
	LoadAudio(&hasAudio, &audioBits, &audioChannels, &audioFormat, &audioRate,
		&audioBuffer, &audioBufferSize);
	if (!hasAudio)
	{
		printf("Warning: Failed to load audio test file: chimes.raw\n");
		printf("         The audio encoding tests will be skipped.\n");
	}

	// Make sure the API version of Revel we're compiling against matches the
	// header files!  This is terribly important!
	if (REVEL_API_VERSION != Revel_GetApiVersion())
	{
		printf("ERROR: Revel version mismatch!\n");
		printf("Headers: version %06x, API version %d\n", REVEL_VERSION,
			REVEL_API_VERSION);
		printf("Library: version %06x, API version %d\n", Revel_GetVersion(),
			Revel_GetApiVersion());
		exit(1);
	}

	// Create an encoder
	revError = Revel_CreateEncoder(&encoderHandle);
	if (revError != REVEL_ERR_NONE)
	{
		printf("Revel Error while creating encoder: %d\n", revError);
		exit(1);
	}

	// Set up the encoding parameters.  ALWAYS call Revel_InitializeParams()
	// before filling in your application's parameters, to ensure that all
	// fields (especially ones that you may not know about) are initialized
	// to safe values.

	Revel_InitializeParams(&revParams);
	revParams.width = width;
	revParams.height = height;
	revParams.frameRate = 25.0f;
	revParams.quality = 1.0f;
	revParams.codec = REVEL_CD_XVID;

	revParams.hasAudio = hasAudio ? 1 : 0;
	revParams.audioChannels = audioChannels;
	revParams.audioRate = audioRate;
	revParams.audioBits = audioBits;
	revParams.audioSampleFormat = audioFormat;

	// Initiate encoding
	revError = Revel_EncodeStart(encoderHandle, filename, &revParams);
	if (revError != REVEL_ERR_NONE)
	{
		printf("Revel Error while starting encoding: %d\n", revError);
		exit(1);
	}

	// Draw and encode each frame.

	frame.width = width;
	frame.height = height;
	frame.bytesPerPixel = 4;
	frame.pixelFormat = REVEL_PF_RGBA;
	frame.pixels = new int[width*height];
}
Exemple #3
0
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;
}