GUAC-236: Perform codec lookup via libavcodec.

This commit is contained in:
Michael Jumper 2016-03-10 17:44:07 -08:00
parent d94915c515
commit a8cba53537
4 changed files with 25 additions and 6 deletions

View File

@ -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;

View File

@ -25,6 +25,8 @@
#include "encode.h"
#include "log.h"
#include <libavcodec/avcodec.h>
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;

View File

@ -22,22 +22,32 @@
#include "config.h"
#include "buffer.h"
#include "log.h"
#include "video.h"
#include <libavcodec/avcodec.h>
#include <guacamole/client.h>
#include <guacamole/timestamp.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
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;

View File

@ -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