Plugins: Use new encoder/output size functions
This commit is contained in:
parent
a0f679bc40
commit
f75a1ebf63
@ -49,6 +49,9 @@ struct ffmpeg_data {
|
||||
int frame_size;
|
||||
int total_frames;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
uint64_t start_timestamp;
|
||||
|
||||
int audio_bitrate;
|
||||
@ -185,8 +188,8 @@ static bool create_video_stream(struct ffmpeg_data *data)
|
||||
context->bit_rate = data->video_bitrate * 1000;
|
||||
context->rc_buffer_size = data->video_bitrate * 1000;
|
||||
context->rc_max_rate = data->video_bitrate * 1000;
|
||||
context->width = ovi.output_width;
|
||||
context->height = ovi.output_height;
|
||||
context->width = data->width;
|
||||
context->height = data->height;
|
||||
context->time_base.num = ovi.fps_den;
|
||||
context->time_base.den = ovi.fps_num;
|
||||
context->gop_size = 120;
|
||||
@ -348,7 +351,7 @@ static void ffmpeg_data_free(struct ffmpeg_data *data)
|
||||
}
|
||||
|
||||
static bool ffmpeg_data_init(struct ffmpeg_data *data, const char *filename,
|
||||
int vbitrate, int abitrate)
|
||||
int vbitrate, int abitrate, int width, int height)
|
||||
{
|
||||
bool is_rtmp = false;
|
||||
|
||||
@ -356,6 +359,8 @@ static bool ffmpeg_data_init(struct ffmpeg_data *data, const char *filename,
|
||||
data->filename_test = filename;
|
||||
data->video_bitrate = vbitrate;
|
||||
data->audio_bitrate = abitrate;
|
||||
data->width = width;
|
||||
data->height = height;
|
||||
|
||||
if (!filename || !*filename)
|
||||
return false;
|
||||
@ -711,6 +716,7 @@ static bool try_connect(struct ffmpeg_output *output)
|
||||
const char *filename_test;
|
||||
obs_data_t settings;
|
||||
int audio_bitrate, video_bitrate;
|
||||
int width, height;
|
||||
int ret;
|
||||
|
||||
settings = obs_output_get_settings(output->output);
|
||||
@ -722,8 +728,12 @@ static bool try_connect(struct ffmpeg_output *output)
|
||||
if (!filename_test || !*filename_test)
|
||||
return false;
|
||||
|
||||
width = (int)obs_output_get_width(output->output);
|
||||
height = (int)obs_output_get_height(output->output);
|
||||
|
||||
if (!ffmpeg_data_init(&output->ff_data, filename_test,
|
||||
video_bitrate, audio_bitrate))
|
||||
video_bitrate, audio_bitrate,
|
||||
width, height))
|
||||
return false;
|
||||
|
||||
struct audio_convert_info aci = {
|
||||
|
@ -76,8 +76,11 @@ static void build_flv_meta_data(obs_output_t context,
|
||||
enc_num_val(&enc, end, "duration", 0.0);
|
||||
enc_num_val(&enc, end, "fileSize", 0.0);
|
||||
|
||||
enc_num_val(&enc, end, "width", (double)video_output_get_width(video));
|
||||
enc_num_val(&enc, end, "height",(double)video_output_get_height(video));
|
||||
enc_num_val(&enc, end, "width",
|
||||
(double)obs_encoder_get_width(vencoder));
|
||||
enc_num_val(&enc, end, "height",
|
||||
(double)obs_encoder_get_height(vencoder));
|
||||
|
||||
enc_str_val(&enc, end, "videocodecid", "avc1");
|
||||
enc_num_val(&enc, end, "videodatarate", encoder_bitrate(vencoder));
|
||||
enc_num_val(&enc, end, "framerate", video_output_get_frame_rate(video));
|
||||
|
@ -241,6 +241,8 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t settings,
|
||||
int buffer_size = (int)obs_data_get_int(settings, "buffer_size");
|
||||
int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
|
||||
int crf = (int)obs_data_get_int(settings, "crf");
|
||||
int width = (int)obs_encoder_get_width(obsx264->encoder);
|
||||
int height = (int)obs_encoder_get_height(obsx264->encoder);
|
||||
bool cbr = obs_data_get_bool(settings, "cbr");
|
||||
|
||||
if (keyint_sec)
|
||||
@ -251,8 +253,8 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t settings,
|
||||
obsx264->params.rc.i_vbv_max_bitrate = bitrate;
|
||||
obsx264->params.rc.i_vbv_buffer_size = buffer_size;
|
||||
obsx264->params.rc.i_bitrate = bitrate;
|
||||
obsx264->params.i_width = voi->width;
|
||||
obsx264->params.i_height = voi->height;
|
||||
obsx264->params.i_width = width;
|
||||
obsx264->params.i_height = height;
|
||||
obsx264->params.i_fps_num = voi->fps_num;
|
||||
obsx264->params.i_fps_den = voi->fps_den;
|
||||
obsx264->params.pf_log = log_x264;
|
||||
@ -264,9 +266,12 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t settings,
|
||||
"\tbuffer size: %d\n"
|
||||
"\tfps_num: %d\n"
|
||||
"\tfps_den: %d\n"
|
||||
"\twidth: %d\n"
|
||||
"\theight: %d\n"
|
||||
"\tkeyint: %d\n"
|
||||
"\tcbr: %s",
|
||||
bitrate, buffer_size, voi->fps_num, voi->fps_den,
|
||||
width, height,
|
||||
obsx264->params.i_keyint_max,
|
||||
cbr ? "on" : "off");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user