Skip to content

Commit

Permalink
obs-outputs/rtmp: delay frame drops
Browse files Browse the repository at this point in the history
Experimental: delay frame drops up to 1 min instead. This replaces the complete disabling of frame drops.
  • Loading branch information
pkviet committed Nov 22, 2017
1 parent d49ef4d commit 2a72a6e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions plugins/obs-outputs/rtmp-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,14 @@ static bool rtmp_stream_start(void *data)
stream->initial_bitrate = bitrate;
stream->dynamic_bitrate = bitrate;
stream->switch_variable_bitrate = obs_data_get_bool(params, "dynamic_variable_bitrate");
stream->disable_frame_drops = obs_data_get_bool(params, "disable_frame_drops");
stream->delay_frame_drops = obs_data_get_bool(params, "delay_frame_drops");
obs_data_release(params);
}
else {
stream->initial_bitrate = 2500;
stream->dynamic_bitrate = 2500;
stream->switch_variable_bitrate = false;
stream->disable_frame_drops = false;
stream->delay_frame_drops = false;
}
stream->last_adjustment_time = os_gettime_ns() / 1000000;
stream->last_congestion = 0;
Expand Down Expand Up @@ -1091,9 +1091,8 @@ static void check_to_drop_frames(struct rtmp_stream *stream, bool pframes)
(float)drop_threshold;
}

if (buffer_duration_usec > drop_threshold) {
if (buffer_duration_usec > (stream->delay_frame_drops? 80 :1 ) * drop_threshold) {
debug("buffer_duration_usec: %" PRId64, buffer_duration_usec);
if (!stream->disable_frame_drops)
drop_frames(stream, name, priority, pframes);
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/obs-outputs/rtmp-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define OPT_BIND_IP "bind_ip"
#define OPT_NEWSOCKETLOOP_ENABLED "new_socket_loop_enabled"
#define OPT_LOWLATENCY_ENABLED "low_latency_mode_enabled"
#define CONGESTION_ARRAY_SIZE 300
#define CONGESTION_ARRAY_SIZE 300 // about 10 sec
//#define TEST_FRAMEDROPS

#ifdef TEST_FRAMEDROPS
Expand Down Expand Up @@ -98,7 +98,7 @@ struct rtmp_stream {
float mean_congestion;
float congestion_array[CONGESTION_ARRAY_SIZE];
size_t congestion_counter;
bool disable_frame_drops;
bool delay_frame_drops;

RTMP rtmp;

Expand Down
4 changes: 2 additions & 2 deletions plugins/obs-x264/obs-x264.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void obs_x264_defaults(obs_data_t *settings)
obs_data_set_default_string(settings, "tune", "");
obs_data_set_default_string(settings, "x264opts", "");
obs_data_set_default_bool (settings, "dynamic_variable_bitrate", false);
obs_data_set_default_bool (settings, "disable_frame_drops", false);
obs_data_set_default_bool (settings, "delay_frame_drops", false);
obs_data_set_default_int (settings, "i_nal_hrd", X264_NAL_HRD_NONE);
}

Expand All @@ -133,7 +133,7 @@ static inline void add_strings(obs_property_t *list, const char *const *strings)
#define TEXT_NONE obs_module_text("None")
#define TEXT_X264_OPTS obs_module_text("EncoderOptions")
#define TEXT_DYN_BITRATE obs_module_text("Dynamic Variable Bitrate")
#define TEXT_DIS_DROP obs_module_text("Disable Frame Drops")
#define TEXT_DIS_DROP obs_module_text("Delay Frame Drops")

static bool use_bufsize_modified(obs_properties_t *ppts, obs_property_t *p,
obs_data_t *settings)
Expand Down

0 comments on commit 2a72a6e

Please sign in to comment.