GUAC-236: Define framerate with macro.
This commit is contained in:
parent
38c431e8a2
commit
c37eda37fd
@ -89,7 +89,7 @@ guacenc_display* guacenc_display_alloc() {
|
|||||||
|
|
||||||
/* STUB: Prepare video encoding */
|
/* STUB: Prepare video encoding */
|
||||||
guacenc_video* video = guacenc_video_alloc("/tmp/test.mpg", "mpeg4",
|
guacenc_video* video = guacenc_video_alloc("/tmp/test.mpg", "mpeg4",
|
||||||
640, 480, 25, 400000);
|
640, 480, 400000);
|
||||||
if (video == NULL)
|
if (video == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
|
guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
|
||||||
int width, int height, int framerate, int bitrate) {
|
int width, int height, int bitrate) {
|
||||||
|
|
||||||
/* Pull codec based on name */
|
/* Pull codec based on name */
|
||||||
AVCodec* codec = avcodec_find_encoder_by_name(codec_name);
|
AVCodec* codec = avcodec_find_encoder_by_name(codec_name);
|
||||||
@ -58,7 +58,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
|
|||||||
context->bit_rate = bitrate;
|
context->bit_rate = bitrate;
|
||||||
context->width = width;
|
context->width = width;
|
||||||
context->height = height;
|
context->height = height;
|
||||||
context->time_base = (AVRational) { 1, framerate };
|
context->time_base = (AVRational) { 1, GUACENC_VIDEO_FRAMERATE };
|
||||||
context->gop_size = 10;
|
context->gop_size = 10;
|
||||||
context->max_b_frames = 1;
|
context->max_b_frames = 1;
|
||||||
context->pix_fmt = AV_PIX_FMT_YUV420P;
|
context->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||||
@ -97,7 +97,6 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
|
|||||||
video->frame = frame;
|
video->frame = frame;
|
||||||
video->width = width;
|
video->width = width;
|
||||||
video->height = height;
|
video->height = height;
|
||||||
video->frame_duration = 1000 / framerate;
|
|
||||||
video->bitrate = bitrate;
|
video->bitrate = bitrate;
|
||||||
|
|
||||||
/* No frames have been written or prepared yet */
|
/* No frames have been written or prepared yet */
|
||||||
@ -164,7 +163,7 @@ int guacenc_video_advance_timeline(guacenc_video* video,
|
|||||||
|
|
||||||
/* Calculate the number of frames that should have been written */
|
/* Calculate the number of frames that should have been written */
|
||||||
int elapsed = (timestamp - video->last_timestamp)
|
int elapsed = (timestamp - video->last_timestamp)
|
||||||
/ video->frame_duration;
|
* GUACENC_VIDEO_FRAMERATE / 1000;
|
||||||
|
|
||||||
/* Keep previous timestamp if insufficient time has elapsed */
|
/* Keep previous timestamp if insufficient time has elapsed */
|
||||||
if (elapsed == 0)
|
if (elapsed == 0)
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The framerate at which video should be encoded, in frames per second.
|
||||||
|
*/
|
||||||
|
#define GUACENC_VIDEO_FRAMERATE 25
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A video which is actively being encoded. Frames can be added to the video
|
* A video which is actively being encoded. Frames can be added to the video
|
||||||
* as they are generated, along with their associated timestamps, and the
|
* as they are generated, along with their associated timestamps, and the
|
||||||
@ -60,11 +65,6 @@ typedef struct guacenc_video {
|
|||||||
*/
|
*/
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
/**
|
|
||||||
* The duration of a single frame in milliseconds.
|
|
||||||
*/
|
|
||||||
int frame_duration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The desired output bitrate of the video, in bits per second.
|
* The desired output bitrate of the video, in bits per second.
|
||||||
*/
|
*/
|
||||||
@ -112,16 +112,12 @@ typedef struct guacenc_video {
|
|||||||
* @param height
|
* @param height
|
||||||
* The height of the desired video, in pixels.
|
* The height of the desired video, in pixels.
|
||||||
*
|
*
|
||||||
* @param framerate
|
|
||||||
* The rate at which frames should be encoded within the video, in frames
|
|
||||||
* per second.
|
|
||||||
*
|
|
||||||
* @param bitrate
|
* @param bitrate
|
||||||
* The desired overall bitrate of the resulting encoded video, in kilobits
|
* The desired overall bitrate of the resulting encoded video, in kilobits
|
||||||
* per second.
|
* per second.
|
||||||
*/
|
*/
|
||||||
guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
|
guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
|
||||||
int width, int height, int framerate, int bitrate);
|
int width, int height, int bitrate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances the timeline of the encoding process to the given timestamp, such
|
* Advances the timeline of the encoding process to the given timestamp, such
|
||||||
|
Loading…
Reference in New Issue
Block a user