@@ -21,6 +21,7 @@ import (
21
21
"github.com/ossrs/go-oryx-lib/errors"
22
22
ohttp "github.com/ossrs/go-oryx-lib/http"
23
23
"github.com/ossrs/go-oryx-lib/logger"
24
+
24
25
// Use v8 because we use Go 1.16+, while v9 requires Go 1.18+
25
26
"github.com/go-redis/redis/v8"
26
27
"github.com/google/uuid"
@@ -1295,6 +1296,9 @@ type TranscriptSegment struct {
1295
1296
// Whether user clear the ASR text of this segment.
1296
1297
UserClearASR bool `json:"uca,omitempty"`
1297
1298
1299
+ // The map that host the pid -> last cc
1300
+ OverlayTSLastCC map [uint16 ]uint8 `json:"overlay_ts_last_cc,omitempty"`
1301
+
1298
1302
// The cost to transcode the TS file to audio file.
1299
1303
CostExtractAudio time.Duration `json:"eac,omitempty"`
1300
1304
// The cost to do ASR, converting speech to text.
@@ -1402,6 +1406,16 @@ func (v *TranscriptQueue) first() *TranscriptSegment {
1402
1406
return v .Segments [0 ]
1403
1407
}
1404
1408
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
+
1405
1419
func (v * TranscriptQueue ) clearSubtitle (tsid string ) error {
1406
1420
v .lock .Lock ()
1407
1421
defer v .lock .Unlock ()
@@ -1594,7 +1608,7 @@ func (v *TranscriptTask) OnTsSegment(ctx context.Context, msg *SrsOnHlsObject) e
1594
1608
func () {
1595
1609
// We must not update the queue, when persistence goroutine is working.
1596
1610
v .lock .Lock ()
1597
- v .lock .Unlock ()
1611
+ defer v .lock .Unlock ()
1598
1612
1599
1613
v .LiveQueue .enqueue (& TranscriptSegment {
1600
1614
Msg : msg .Msg ,
@@ -1978,7 +1992,7 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
1978
1992
args = append (args , strings .Fields (videoCodecParams )... )
1979
1993
// Generate other parameters for FFmpeg.
1980
1994
args = append (args , []string {
1981
- "-c:a" , "aac " ,
1995
+ "-c:a" , "copy " ,
1982
1996
"-copyts" , // To keep the pts not changed.
1983
1997
"-y" , overlayFile .File ,
1984
1998
}... )
@@ -2004,6 +2018,21 @@ func (v *TranscriptTask) DriveFixQueue(ctx context.Context) error {
2004
2018
}
2005
2019
overlayFile .Size = uint64 (stats .Size ())
2006
2020
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
+ previousTSCC := map [uint16 ]uint8 {}
2026
+ if previousSegment := v .OverlayQueue .find_by (overlayFile .SeqNo - 1 ); previousSegment != nil {
2027
+ previousTSCC = previousSegment .OverlayTSLastCC
2028
+ }
2029
+
2030
+ if cc , err := overlayFile .AdjustCC (previousTSCC ); err != nil {
2031
+ logger .Wf (ctx , "Error when Adjust Overlay TS file %v" , overlayFile .File )
2032
+ } else {
2033
+ segment .OverlayTSLastCC = cc
2034
+ }
2035
+
2007
2036
// Dequeue the segment from live queue and attach to asr queue.
2008
2037
func () {
2009
2038
v .lock .Lock ()
0 commit comments