提交 c8d5058f 编写于 作者: J jp9000

obs-x264: Add option to use variable framerate

This just changes the x264 encoder settings; it doesn't actually change
the framerate of OBS.  OBS will always output at a constant framerate
regardless of whether this option is on or off; this just changes how
the encoder encodes the data.
上级 c53f4f2f
......@@ -9,3 +9,4 @@ Profile="Profile"
Tune="Tune"
None="(None)"
EncoderOptions="x264 Options (separated by space)"
VFR="Variable Framerate"
......@@ -95,6 +95,7 @@ static void obs_x264_defaults(obs_data_t *settings)
obs_data_set_default_int (settings, "buffer_size", 2500);
obs_data_set_default_int (settings, "keyint_sec", 0);
obs_data_set_default_int (settings, "crf", 23);
obs_data_set_default_bool (settings, "vfr", false);
obs_data_set_default_bool (settings, "cbr", true);
obs_data_set_default_string(settings, "preset", "veryfast");
......@@ -115,6 +116,7 @@ static inline void add_strings(obs_property_t *list, const char *const *strings)
#define TEXT_CUSTOM_BUF obs_module_text("CustomBufsize")
#define TEXT_BUF_SIZE obs_module_text("BufferSize")
#define TEXT_USE_CBR obs_module_text("UseCBR")
#define TEXT_VFR obs_module_text("VFR")
#define TEXT_CRF obs_module_text("CRF")
#define TEXT_KEYINT_SEC obs_module_text("KeyframeIntervalSec")
#define TEXT_PRESET obs_module_text("CPUPreset")
......@@ -178,6 +180,8 @@ static obs_properties_t *obs_x264_props(void *unused)
obs_property_list_add_string(list, TEXT_NONE, "");
add_strings(list, x264_tune_names);
obs_properties_add_bool(props, "vfr", TEXT_VFR);
obs_properties_add_text(props, "x264opts", TEXT_X264_OPTS,
OBS_TEXT_DEFAULT);
......@@ -368,6 +372,7 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
int width = (int)obs_encoder_get_width(obsx264->encoder);
int height = (int)obs_encoder_get_height(obsx264->encoder);
bool use_bufsize = obs_data_get_bool(settings, "use_bufsize");
bool vfr = obs_data_get_bool(settings, "vfr");
bool cbr = obs_data_get_bool(settings, "cbr");
if (keyint_sec)
......@@ -377,7 +382,7 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
if (!use_bufsize)
buffer_size = bitrate;
obsx264->params.b_vfr_input = false;
obsx264->params.b_vfr_input = vfr;
obsx264->params.rc.i_vbv_max_bitrate = bitrate;
obsx264->params.rc.i_vbv_buffer_size = buffer_size;
obsx264->params.rc.i_bitrate = bitrate;
......@@ -434,12 +439,14 @@ static void update_params(struct obs_x264 *obsx264, obs_data_t *settings,
"\twidth: %d\n"
"\theight: %d\n"
"\tkeyint: %d\n"
"\tvfr: %s\n"
"\tcbr: %s",
obsx264->params.rc.i_vbv_max_bitrate,
obsx264->params.rc.i_vbv_buffer_size,
voi->fps_num, voi->fps_den,
width, height,
obsx264->params.i_keyint_max,
vfr ? "on" : "off",
cbr ? "on" : "off");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册