@@ -21,6 +21,7 @@ import (
2121 "github.com/ossrs/go-oryx-lib/errors"
2222 ohttp "github.com/ossrs/go-oryx-lib/http"
2323 "github.com/ossrs/go-oryx-lib/logger"
24+
2425 // Use v8 because we use Go 1.16+, while v9 requires Go 1.18+
2526 "github.com/go-redis/redis/v8"
2627 "github.com/google/uuid"
@@ -1295,6 +1296,9 @@ type TranscriptSegment struct {
12951296 // Whether user clear the ASR text of this segment.
12961297 UserClearASR bool `json:"uca,omitempty"`
12971298
1299+ // The map that host the pid -> last cc
1300+ OverlayTSLastCC map [uint16 ]uint8 `json:"start_cc,omitempty"`
1301+
12981302 // The cost to transcode the TS file to audio file.
12991303 CostExtractAudio time.Duration `json:"eac,omitempty"`
13001304 // The cost to do ASR, converting speech to text.
@@ -1402,6 +1406,16 @@ func (v *TranscriptQueue) first() *TranscriptSegment {
14021406 return v .Segments [0 ]
14031407}
14041408
1409+ func (v * TranscriptQueue ) find_by (seq_no uint64 ) * TranscriptSegment {
1410+ for i := len (v .Segments ) - 1 ; i >= 0 ; i -- {
1411+ if v .Segments [i ].OverlayFile .SeqNo == seq_no {
1412+ return v .Segments [i ]
1413+ }
1414+ }
1415+
1416+ return nil
1417+ }
1418+
14051419func (v * TranscriptQueue ) clearSubtitle (tsid string ) error {
14061420 v .lock .Lock ()
14071421 defer v .lock .Unlock ()
@@ -1594,7 +1608,7 @@ func (v *TranscriptTask) OnTsSegment(ctx context.Context, msg *SrsOnHlsObject) e
15941608 func () {
15951609 // We must not update the queue, when persistence goroutine is working.
15961610 v .lock .Lock ()
1597- v .lock .Unlock ()
1611+ defer v .lock .Unlock ()
15981612
15991613 v .LiveQueue .enqueue (& TranscriptSegment {
16001614 Msg : msg .Msg ,
@@ -1978,7 +1992,7 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
19781992 args = append (args , strings .Fields (videoCodecParams )... )
19791993 // Generate other parameters for FFmpeg.
19801994 args = append (args , []string {
1981- "-c:a" , "aac " ,
1995+ "-c:a" , "copy " ,
19821996 "-copyts" , // To keep the pts not changed.
19831997 "-y" , overlayFile .File ,
19841998 }... )
@@ -2004,6 +2018,21 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
20042018 }
20052019 overlayFile .Size = uint64 (stats .Size ())
20062020
2021+ // recaculate the continuity_counter of overlayFile
2022+ // 1. get previous segment in overlayQueue
2023+ // 2. adjust current ts segment's continuity_counter
2024+ // 2. change segment.OverlayTSLastCC
2025+ previous_ts_cc := map [uint16 ]uint8 {}
2026+ if previous_segment := v .OverlayQueue .find_by (overlayFile .SeqNo - 1 ); previous_segment != nil {
2027+ previous_ts_cc = previous_segment .OverlayTSLastCC
2028+ }
2029+
2030+ if cc , err := overlayFile .AdjustCC (previous_ts_cc ); err != nil {
2031+ logger .Wf (ctx , "Error when Adjust Overlay TS file %v" , overlayFile .File )
2032+ } else {
2033+ segment .OverlayTSLastCC = cc
2034+ }
2035+
20072036 // Dequeue the segment from live queue and attach to asr queue.
20082037 func () {
20092038 v .lock .Lock ()
0 commit comments