コード例 #1
0
ファイル: reveltest.cpp プロジェクト: gesellkammer/lambda
int InitializeEncoder(int width, int height)
{
    Revel_Error revError;

    // 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());
        return 0;
    }

    // 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_Params revParams;
    Revel_InitializeParams(&revParams);
    revParams.width = width;
    revParams.height = height;
    revParams.frameRate = 30.0f;
    revParams.quality = 1.0f;
    revParams.codec = REVEL_CD_XVID;
    revParams.hasAudio = 1; // It's okay to set this to 1 even if we don't call Revel_EncodeAudio() below.
    revParams.audioChannels = audioChannels;
    revParams.audioRate = audioRate;
    revParams.audioBits = audioBits;
    revParams.audioSampleFormat = audioFormat;

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

	return encoderHandle;
}
コード例 #2
0
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];
}