Closed Wkkkkk closed 7 months ago
Hi @tobbee, I tried to avoid a different parser for scte35 but found no solution yet. Instead, I removed the buffering by checking the options in mp2ts-info
.
func parse(ctx context.Context, w io.Writer, f io.Reader, o internal.Options) error {
// Parse either general information, or scte35 (by default)
if o.ShowService {
err := internal.ParseInfo(ctx, w, f, o)
if err != nil {
return err
}
} else if o.ShowSCTE35 {
err := internal.ParseSCTE35(ctx, w, f, o)
if err != nil {
return err
}
}
return nil
}
Together with other changes, we might have outputs like the following:
go run . -indent=false ~/Downloads/ts_with_scte35.ts
{"pid":289,"codec":"AVC","type":"video"}
{"pid":545,"codec":"AAC","type":"audio"}
{"pid":546,"codec":"AAC","type":"audio"}
{"pid":53,"codec":"SCTE35","type":"cue"}
{"pid":53,"spliceCommand":{"type":"SpliceInsert","eventId":8,"pts":0}}
{"pid":53,"spliceCommand":{"type":"SpliceInsert","eventId":1,"pts":0,"duration":2700000,"outOfNetwork":true}}
{"pid":53,"spliceCommand":{"type":"SpliceInsert","eventId":1,"pts":0}}
{"pid":53,"spliceCommand":{"type":"SpliceInsert","eventId":2,"pts":0,"duration":4500000,"outOfNetwork":true}}
go run . -indent=false -service ~/Downloads/ts_with_scte35.ts
{"pid":289,"codec":"AVC","type":"video"}
{"pid":545,"codec":"AAC","type":"audio"}
{"pid":546,"codec":"AAC","type":"audio"}
{"pid":53,"codec":"SCTE35","type":"cue"}
{"SDT":[{"serviceId":1,"descriptors":[{"serviceName":"A1Now","providerName":"Sportradar"}]}]}
One possibility is to implement the service table parsing with gots ourselves so that we will have one parsing logic for both SCTE-markers and service tables (or any other PSI tables).
While testing, it was noticed that the PTS in SpliceInsertCommand
is missing. This has been fixed in the last commit.
go run . -indent=false ~/Downloads/80s_with_ad.ts
{"pid":256,"codec":"AVC","type":"video"}
{"pid":257,"codec":"AAC","type":"audio"}
{"pid":1001,"codec":"SCTE35","type":"cue"}
{"pid":1001,"spliceCommand":{"type":"SpliceInsert","eventId":255,"pts":1032000,"duration":1800000,"outOfNetwork":true}}
To break from an error ASAP, we removed the error chain. In case of faulty ts files, we might see errors like follows.