diff --git a/plugins/obs-outputs/flv-output.c b/plugins/obs-outputs/flv-output.c index 9d2159964a57de..9681f279474992 100644 --- a/plugins/obs-outputs/flv-output.c +++ b/plugins/obs-outputs/flv-output.c @@ -51,7 +51,7 @@ struct flv_output { pthread_mutex_t mutex; - bool got_first_video; + bool got_first_packet; int32_t start_dts_offset; }; @@ -500,7 +500,7 @@ static bool flv_output_start(void *data) if (!obs_output_initialize_encoders(stream->output, 0)) return false; - stream->got_first_video = false; + stream->got_first_packet = false; stream->sent_headers = false; os_atomic_set_bool(&stream->stopping, false); @@ -579,10 +579,10 @@ static void flv_output_data(void *data, struct encoder_packet *packet) } if (packet->type == OBS_ENCODER_VIDEO) { - if (!stream->got_first_video) { + if (!stream->got_first_packet) { stream->start_dts_offset = get_ms_time(packet, packet->dts); - stream->got_first_video = true; + stream->got_first_packet = true; } switch (stream->video_codec[packet->track_idx]) { @@ -616,6 +616,12 @@ static void flv_output_data(void *data, struct encoder_packet *packet) } obs_encoder_packet_release(&parsed_packet); } else { + if (!stream->got_first_packet) { + stream->start_dts_offset = + get_ms_time(packet, packet->dts); + stream->got_first_packet = true; + } + if (packet->track_idx != 0) { write_audio_packet_ex(stream, packet, false, packet->track_idx); diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index aa4f84de63ceec..190d80aac18c7b 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -1314,7 +1314,7 @@ static bool init_connect(struct rtmp_stream *stream) stream->total_bytes_sent = 0; stream->dropped_frames = 0; stream->min_priority = 0; - stream->got_first_video = false; + stream->got_first_packet = false; settings = obs_output_get_settings(stream->output); dstr_copy(&stream->path, @@ -1761,10 +1761,10 @@ static void rtmp_stream_data(void *data, struct encoder_packet *packet) } if (packet->type == OBS_ENCODER_VIDEO) { - if (!stream->got_first_video) { + if (!stream->got_first_packet) { stream->start_dts_offset = get_ms_time(packet, packet->dts); - stream->got_first_video = true; + stream->got_first_packet = true; } switch (stream->video_codec[packet->track_idx]) { @@ -1788,6 +1788,12 @@ static void rtmp_stream_data(void *data, struct encoder_packet *packet) break; } } else { + if (!stream->got_first_packet) { + stream->start_dts_offset = + get_ms_time(packet, packet->dts); + stream->got_first_packet = true; + } + obs_encoder_packet_ref(&new_packet, packet); } diff --git a/plugins/obs-outputs/rtmp-stream.h b/plugins/obs-outputs/rtmp-stream.h index 580607111a7d1d..3ef0cf9a4f121a 100644 --- a/plugins/obs-outputs/rtmp-stream.h +++ b/plugins/obs-outputs/rtmp-stream.h @@ -60,7 +60,7 @@ struct rtmp_stream { struct deque packets; bool sent_headers; - bool got_first_video; + bool got_first_packet; int64_t start_dts_offset; volatile bool connecting;