diff --git a/src/guacenc/display.c b/src/guacenc/display.c index baf6845d..21af2183 100644 --- a/src/guacenc/display.c +++ b/src/guacenc/display.c @@ -88,8 +88,8 @@ cairo_operator_t guacenc_display_cairo_operator(guac_composite_mode mask) { guacenc_display* guacenc_display_alloc() { /* STUB: Prepare video encoding */ - guacenc_video* video = - guacenc_video_alloc("/tmp/test.mpg", 640, 480, 25, 400000); + guacenc_video* video = guacenc_video_alloc("/tmp/test.mpg", "mpeg4", + 640, 480, 25, 400000); if (video == NULL) return NULL; diff --git a/src/guacenc/guacenc.c b/src/guacenc/guacenc.c index c5b00efc..79b7d61d 100644 --- a/src/guacenc/guacenc.c +++ b/src/guacenc/guacenc.c @@ -25,6 +25,8 @@ #include "encode.h" #include "log.h" +#include + int main(int argc, char* argv[]) { int i; @@ -39,6 +41,9 @@ int main(int argc, char* argv[]) { return 0; } + /* Prepare libavcodec */ + avcodec_register_all(); + /* Track number of overall failures */ int total_files = argc - 1; int failures = 0; diff --git a/src/guacenc/video.c b/src/guacenc/video.c index 6c803e7a..e7a4dfd3 100644 --- a/src/guacenc/video.c +++ b/src/guacenc/video.c @@ -22,22 +22,32 @@ #include "config.h" #include "buffer.h" +#include "log.h" #include "video.h" +#include +#include #include #include #include #include -guacenc_video* guacenc_video_alloc(const char* path, int width, int height, - int framerate, int bitrate) { +guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, + int width, int height, int framerate, int bitrate) { /* Allocate video structure */ guacenc_video* video = malloc(sizeof(guacenc_video)); if (video == NULL) return NULL; + AVCodec* codec = avcodec_find_encoder_by_name(codec_name); + if (codec == NULL) { + guacenc_log(GUAC_LOG_ERROR, "Failed to locate codec: \"%s\"", + codec_name); + return NULL; + } + /* Init properties of video */ video->width = width; video->height = height; diff --git a/src/guacenc/video.h b/src/guacenc/video.h index f333df70..b5a27498 100644 --- a/src/guacenc/video.h +++ b/src/guacenc/video.h @@ -88,6 +88,10 @@ typedef struct guacenc_video { * @param path * The full path to the file in which encoded video should be written. * + * @param codec_name + * The name of the codec to use for the video encoding, as defined by + * ffmpeg / libavcodec. + * * @param width * The width of the desired video, in pixels. * @@ -102,8 +106,8 @@ typedef struct guacenc_video { * The desired overall bitrate of the resulting encoded video, in kilobits * per second. */ -guacenc_video* guacenc_video_alloc(const char* path, int width, int height, - int framerate, int bitrate); +guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, + int width, int height, int framerate, int bitrate); /** * Advances the timeline of the encoding process to the given timestamp, such