libgwavi  0.0
libgwavi is a tiny C library aimed at creating AVI files.
 All Files Functions Pages
gwavi.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gwavi.h"
#include "gwavi_private.h"
#include "avi-utils.h"
#include "fileio.h"

Functions

struct gwavi_t * gwavi_open (char *filename, unsigned int width, unsigned int height, char *fourcc, unsigned int fps, struct gwavi_audio_t *audio)
 This is the first function you should call when using gwavi library. More...
 
int gwavi_add_frame (struct gwavi_t *gwavi, unsigned char *buffer, size_t len)
 This function allows you to add an encoded video frame to the AVI file. More...
 
int gwavi_add_audio (struct gwavi_t *gwavi, unsigned char *buffer, size_t len)
 This function allows you to add the audio track to your AVI file. More...
 
int gwavi_close (struct gwavi_t *gwavi)
 This function should be called when the program is done adding video and/or audio frames to the AVI file. More...
 
int gwavi_set_framerate (struct gwavi_t *gwavi, unsigned int fps)
 This function allows you to reset the framerate. More...
 
int gwavi_set_codec (struct gwavi_t *gwavi, char *fourcc)
 This function allows you to reset the video codec. More...
 
int gwavi_set_size (struct gwavi_t *gwavi, unsigned int width, unsigned int height)
 This function allows you to reset the video size. More...
 

Function Documentation

int gwavi_add_audio ( struct gwavi_t *  gwavi,
unsigned char *  buffer,
size_t  len 
)

This function allows you to add the audio track to your AVI file.

Parameters
gwaviMain gwavi structure initialized with gwavi_open()-
bufferAudio buffer size.
lenAudio buffer length.
Returns
0 on success, -1 on error.
int gwavi_add_frame ( struct gwavi_t *  gwavi,
unsigned char *  buffer,
size_t  len 
)

This function allows you to add an encoded video frame to the AVI file.

Parameters
gwaviMain gwavi structure initialized with gwavi_open()-
bufferVideo buffer size.
lenVideo buffer length.
Returns
0 on success, -1 on error.
int gwavi_close ( struct gwavi_t *  gwavi)

This function should be called when the program is done adding video and/or audio frames to the AVI file.

It frees memory allocated for gwavi_open() for the main gwavi_t structure. It also properly closes the output file.

Parameters
gwaviMain gwavi structure initialized with gwavi_open()-
Returns
0 on success, -1 on error.
struct gwavi_t* gwavi_open ( char *  filename,
unsigned int  width,
unsigned int  height,
char *  fourcc,
unsigned int  fps,
struct gwavi_audio_t *  audio 
)

This is the first function you should call when using gwavi library.

It allocates memory for a gwavi_t structure and returns it and takes care of initializing the AVI header with the provided information.

When you're done creating your AVI file, you should call gwavi_close() function to free memory allocated for the gwavi_t structure and properly close the output file.

Parameters
filenameThis is the name of the AVI file which will be generated by this library.
widthWidth of a frame.
heightHeight of a frame.
fourccFourCC representing the codec of the video encoded stream. a FourCC is a sequence of four chars used to uniquely identify data formats. For more information, you can visit www.fourcc.org.
fpsNumber of frames per second of your video.
audioThis parameter is optionnal. It is used for the audio track. If you do not want to add an audio track to your AVI file, simply pass NULL for this argument.
Returns
Structure containing required information in order to create the AVI file. If an error occured, NULL is returned.
int gwavi_set_codec ( struct gwavi_t *  gwavi,
char *  fourcc 
)

This function allows you to reset the video codec.

In a standard use case, you should not need to call it. However, if you need to, you can call it to reset the video codec after you are done adding frames to your AVI file and before you call gwavi_close().

Parameters
gwaviMain gwavi structure initialized with gwavi_open()-
fourccFourCC representing the codec of the video encoded stream. a
Returns
0 on success, -1 on error.
int gwavi_set_framerate ( struct gwavi_t *  gwavi,
unsigned int  fps 
)

This function allows you to reset the framerate.

In a standard use case, you should not need to call it. However, if you need to, you can call it to reset the framerate after you are done adding frames to your AVI file and before you call gwavi_close().

Parameters
gwaviMain gwavi structure initialized with gwavi_open()-
fpsNumber of frames per second of your video.
Returns
0 on success, -1 on error.
int gwavi_set_size ( struct gwavi_t *  gwavi,
unsigned int  width,
unsigned int  height 
)

This function allows you to reset the video size.

In a standard use case, you should not need to call it. However, if you need to, you can call it to reset the video height and width set in the AVI file after you are done adding frames to your AVI file and before you call gwavi_close().

Parameters
gwaviMain gwavi structure initialized with gwavi_open()-
widthWidth of a frame.
heightHeight of a frame.
Returns
0 on success, -1 on error.