Merge pull request #400 in FS/freeswitch from ~BRADLEYJOKINEN/freeswitch:FS-7983 to master
* commit '723e8a1f9a899564b89e70d5e6c4a8799413579b': FS-7983 Added param for specifying video encoding speed
This commit is contained in:
commit
8577601f5f
|
@ -298,6 +298,13 @@ struct switch_file_interface {
|
|||
struct switch_file_interface *next;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SWITCH_VIDEO_ENCODE_SPEED_DEFAULT;
|
||||
SWITCH_VIDEO_ENCODE_SPEED_SLOW,
|
||||
SWITCH_VIDEO_ENCODE_SPEED_MEDIUM,
|
||||
SWITCH_VIDEO_ENCODE_SPEED_FAST
|
||||
} switch_video_encode_speed_t;
|
||||
|
||||
typedef struct switch_mm_s {
|
||||
int samplerate;
|
||||
int channels;
|
||||
|
@ -308,6 +315,7 @@ typedef struct switch_mm_s {
|
|||
int vh;
|
||||
float fps;
|
||||
int vbuf;
|
||||
switch_video_encode_speed_t vencspd;
|
||||
} switch_mm_t;
|
||||
|
||||
/*! an abstract representation of a file handle (some parameters based on compat with libsndfile) */
|
||||
|
|
|
@ -299,6 +299,20 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
|||
|
||||
if (codec_id == AV_CODEC_ID_H264) {
|
||||
c->ticks_per_frame = 2;
|
||||
|
||||
switch (mm->vencspd) {
|
||||
case SWITCH_VIDEO_ENCODE_SPEED_SLOW:
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
break;
|
||||
case SWITCH_VIDEO_ENCODE_SPEED_MEDIUM:
|
||||
av_opt_set(c->priv_data, "preset", "medium", 0);
|
||||
break;
|
||||
case SWITCH_VIDEO_ENCODE_SPEED_FAST:
|
||||
av_opt_set(c->priv_data, "preset", "ultrafast", 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (codec_id == AV_CODEC_ID_VP8) {
|
||||
|
|
|
@ -84,6 +84,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
|||
fh->mm.channels = 1;
|
||||
fh->mm.keyint = 60;
|
||||
fh->mm.ab = 128;
|
||||
fh->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_DEFAULT;
|
||||
|
||||
if (*file_path == '{') {
|
||||
char *timeout;
|
||||
|
@ -186,6 +187,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid buffer size: %d\n", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "vencspd"))) {
|
||||
if (!strcasecmp(val, "slow")) {
|
||||
fh->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_SLOW;
|
||||
} else if (!strcasecmp(val, "medium")) {
|
||||
fh->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_MEDIUM;
|
||||
} else if (!strcasecmp(val, "fast")) {
|
||||
fh->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_FAST;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid video encode speed: %s\n", val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_directory_exists(file_path, fh->memory_pool) == SWITCH_STATUS_SUCCESS) {
|
||||
|
|
Loading…
Reference in New Issue