mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-04 18:27:36 +00:00
FS-8240 add video profile param for recording 264 and make it default
This commit is contained in:
parent
e7cbb77e54
commit
32b43866f8
@ -305,6 +305,12 @@ typedef enum {
|
|||||||
SWITCH_VIDEO_ENCODE_SPEED_FAST
|
SWITCH_VIDEO_ENCODE_SPEED_FAST
|
||||||
} switch_video_encode_speed_t;
|
} switch_video_encode_speed_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SWITCH_VIDEO_PROFILE_BASELINE,
|
||||||
|
SWITCH_VIDEO_PROFILE_MAIN,
|
||||||
|
SWITCH_VIDEO_PROFILE_HIGH
|
||||||
|
} switch_video_profile_t;
|
||||||
|
|
||||||
typedef struct switch_mm_s {
|
typedef struct switch_mm_s {
|
||||||
int samplerate;
|
int samplerate;
|
||||||
int channels;
|
int channels;
|
||||||
@ -314,7 +320,9 @@ typedef struct switch_mm_s {
|
|||||||
int vw;
|
int vw;
|
||||||
int vh;
|
int vh;
|
||||||
float fps;
|
float fps;
|
||||||
|
float source_fps;
|
||||||
int vbuf;
|
int vbuf;
|
||||||
|
switch_video_profile_t vprofile;
|
||||||
switch_video_encode_speed_t vencspd;
|
switch_video_encode_speed_t vencspd;
|
||||||
} switch_mm_t;
|
} switch_mm_t;
|
||||||
|
|
||||||
|
@ -312,18 +312,34 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
|||||||
if (codec_id == AV_CODEC_ID_H264) {
|
if (codec_id == AV_CODEC_ID_H264) {
|
||||||
c->ticks_per_frame = 2;
|
c->ticks_per_frame = 2;
|
||||||
|
|
||||||
|
switch (mm->vprofile) {
|
||||||
|
case SWITCH_VIDEO_PROFILE_BASELINE:
|
||||||
|
av_opt_set(c->priv_data, "profile", "baseline", 0);
|
||||||
|
c->level = 41;
|
||||||
|
break;
|
||||||
|
case SWITCH_VIDEO_PROFILE_MAIN:
|
||||||
|
av_opt_set(c->priv_data, "profile", "main", 0);
|
||||||
|
av_opt_set(c->priv_data, "level", "5", 0);
|
||||||
|
break;
|
||||||
|
case SWITCH_VIDEO_PROFILE_HIGH:
|
||||||
|
av_opt_set(c->priv_data, "profile", "high", 0);
|
||||||
|
av_opt_set(c->priv_data, "level", "52", 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (mm->vencspd) {
|
switch (mm->vencspd) {
|
||||||
case SWITCH_VIDEO_ENCODE_SPEED_SLOW:
|
case SWITCH_VIDEO_ENCODE_SPEED_SLOW:
|
||||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||||
break;
|
break;
|
||||||
case SWITCH_VIDEO_ENCODE_SPEED_MEDIUM:
|
case SWITCH_VIDEO_ENCODE_SPEED_MEDIUM:
|
||||||
av_opt_set(c->priv_data, "preset", "medium", 0);
|
av_opt_set(c->priv_data, "preset", "medium", 0);
|
||||||
break;
|
break;
|
||||||
case SWITCH_VIDEO_ENCODE_SPEED_FAST:
|
case SWITCH_VIDEO_ENCODE_SPEED_FAST:
|
||||||
av_opt_set(c->priv_data, "preset", "ultrafast", 0);
|
av_opt_set(c->priv_data, "preset", "veryfast", 0);
|
||||||
break;
|
av_opt_set(c->priv_data, "tune", "zerolatency", 0);
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,7 +1163,8 @@ static switch_status_t open_input_file(av_file_context_t *context, switch_file_h
|
|||||||
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
|
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
|
||||||
context->has_video = 1;
|
context->has_video = 1;
|
||||||
}
|
}
|
||||||
context->read_fps = (int)ceil(av_q2d(context->video_st.st->avg_frame_rate));
|
handle->mm.source_fps = ceil(av_q2d(context->video_st.st->avg_frame_rate));
|
||||||
|
context->read_fps = (int)handle->mm.source_fps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,6 +1527,8 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
|
|||||||
handle->samplerate = 44100;
|
handle->samplerate = 44100;
|
||||||
handle->mm.samplerate = 44100;
|
handle->mm.samplerate = 44100;
|
||||||
handle->mm.ab = 128;
|
handle->mm.ab = 128;
|
||||||
|
//handle->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_FAST;
|
||||||
|
handle->mm.vprofile = SWITCH_VIDEO_PROFILE_BASELINE;
|
||||||
|
|
||||||
if (!handle->mm.vb && handle->mm.vw && handle->mm.vh) {
|
if (!handle->mm.vb && handle->mm.vw && handle->mm.vh) {
|
||||||
switch(handle->mm.vh) {
|
switch(handle->mm.vh) {
|
||||||
|
@ -85,6 +85,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
|||||||
fh->mm.keyint = 60;
|
fh->mm.keyint = 60;
|
||||||
fh->mm.ab = 128;
|
fh->mm.ab = 128;
|
||||||
fh->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_DEFAULT;
|
fh->mm.vencspd = SWITCH_VIDEO_ENCODE_SPEED_DEFAULT;
|
||||||
|
fh->mm.vprofile = SWITCH_VIDEO_PROFILE_BASELINE;
|
||||||
|
|
||||||
if (*file_path == '{') {
|
if (*file_path == '{') {
|
||||||
char *timeout;
|
char *timeout;
|
||||||
@ -199,6 +200,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
|||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid video encode speed: %s\n", val);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid video encode speed: %s\n", val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((val = switch_event_get_header(fh->params, "vprofile"))) {
|
||||||
|
if (!strcasecmp(val, "baseline")) {
|
||||||
|
fh->mm.vprofile = SWITCH_VIDEO_PROFILE_BASELINE;
|
||||||
|
} else if (!strcasecmp(val, "main")) {
|
||||||
|
fh->mm.vprofile = SWITCH_VIDEO_PROFILE_MAIN;
|
||||||
|
} else if (!strcasecmp(val, "high")) {
|
||||||
|
fh->mm.vprofile = SWITCH_VIDEO_PROFILE_HIGH;
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid video profile: %s\n", val);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_directory_exists(file_path, fh->memory_pool) == SWITCH_STATUS_SUCCESS) {
|
if (switch_directory_exists(file_path, fh->memory_pool) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user