mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
libobs: Subtract packet dts_usec with first packet offset
Ensures that the packet dts_usec vals which are generated for syncing/interleaving use the proper offset relative to where they're supposed to be starting from. The negative DTS of a first video packet could potentially have been applied twice due to this.
This commit is contained in:
parent
346ddd502f
commit
c4657da2f1
@ -424,6 +424,8 @@ void obs_encoder_shutdown(obs_encoder_t *encoder)
|
||||
encoder->info.destroy(encoder->context.data);
|
||||
encoder->context.data = NULL;
|
||||
encoder->paired_encoder = NULL;
|
||||
encoder->first_received = false;
|
||||
encoder->offset_usec = 0;
|
||||
encoder->start_ts = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&encoder->init_mutex);
|
||||
@ -798,9 +800,15 @@ static inline void do_encode(struct obs_encoder *encoder,
|
||||
}
|
||||
|
||||
if (received) {
|
||||
if (!encoder->first_received) {
|
||||
encoder->offset_usec = packet_dts_usec(&pkt);
|
||||
encoder->first_received = true;
|
||||
}
|
||||
|
||||
/* we use system time here to ensure sync with other encoders,
|
||||
* you do not want to use relative timestamps here */
|
||||
pkt.dts_usec = encoder->start_ts / 1000 + packet_dts_usec(&pkt);
|
||||
pkt.dts_usec = encoder->start_ts / 1000 +
|
||||
packet_dts_usec(&pkt) - encoder->offset_usec;
|
||||
|
||||
pthread_mutex_lock(&encoder->callbacks_mutex);
|
||||
|
||||
|
@ -743,7 +743,9 @@ struct obs_encoder {
|
||||
* wait_for_video makes it wait until it's ready to sync up with
|
||||
* video */
|
||||
bool wait_for_video;
|
||||
bool first_received;
|
||||
struct obs_encoder *paired_encoder;
|
||||
int64_t offset_usec;
|
||||
uint64_t start_ts;
|
||||
|
||||
pthread_mutex_t outputs_mutex;
|
||||
|
Loading…
Reference in New Issue
Block a user