From 4397b1e8e12580efe93faad26155281f99966594 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 7 Mar 2025 13:57:08 +0100 Subject: [PATCH] awstranscriber2: fix PTS calculation with non-zero segment start The time we get from AWS is a running time, and needs to be brought back to the segment time domain before comparison with segment position and usage as PTS. Part-of: --- net/aws/src/transcriber2/imp.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/net/aws/src/transcriber2/imp.rs b/net/aws/src/transcriber2/imp.rs index 1b7045d3f..9d8194af8 100644 --- a/net/aws/src/transcriber2/imp.rs +++ b/net/aws/src/transcriber2/imp.rs @@ -248,7 +248,23 @@ impl Transcriber { } } - let mut pts = aws_start_time + state.discont_accumulator + lateness; + let rtime = aws_start_time + state.discont_accumulator + lateness; + + let Some(mut pts) = state + .in_segment + .as_ref() + .unwrap() + .position_from_running_time(rtime) + else { + gst::warning!( + CAT, + imp = self, + "received item with running time outside of segment ({})", + rtime + ); + continue; + }; + let duration = aws_end_time.saturating_sub(aws_start_time); if let Some(position) = state.in_segment.as_ref().unwrap().position() {