- Parses SCTE-35 Cues from MPEGTS or Bytes or Base64
- Parses SCTE-35 Cues spread over multiple MPEGTS packets
- Supports multi-packet PAT and PMT tables
- Supports multiple MPEGTS Programs and multiple SCTE-35 streams
go install github.com/futzu/cuei@latest| Use this | To do this |
|---|---|
| cuei.Cue | Parse SCTE-35 from a Base64 or Byte string. |
| cuei.Stream | Parse SCTE35 Cues from MPEGTS packets. |
| cuei.Scte35Parser | Parse SCTE-35 from MPEGTS packets from a external demuxer. |
- cueidemo.go
package main
import (
"os"
"fmt"
"github.com/futzu/cuei"
)
func main(){
args := os.Args[1:]
for i := range args{
fmt.Printf( "\nNext File: %s\n\n",args[i] )
var stream cuei.Stream
stream.Decode(args[i])
}
}
go build cueidemo.go./cueidemo a_video_with_scte35.tsNext File: mpegts/out.ts
{
"Name": "Splice Info Section",
"TableID": "0xfc",
"SectionSyntaxIndicator": false,
"Private": false,
"Reserved": "0x3",
"SectionLength": 49,
"ProtocolVersion": 0,
"EncryptedPacket": false,
"EncryptionAlgorithm": 0,
"PtsAdjustment": 0,
"CwIndex": "0x0",
"Tier": "0xfff",
"SpliceCommandLength": 20,
"SpliceCommandType": 5,
"DescriptorLoopLength": 12,
"Command": {
"Name": "Splice Insert",
"CommandType": 5,
"SpliceEventID": "0x5d",
"OutOfNetworkIndicator": true,
"ProgramSpliceFlag": true,
"DurationFlag": true,
"BreakDuration": 90.023266,
"TimeSpecifiedFlag": true,
"PTS": 38113.135577
},
"Descriptors": [
{
"Tag": 1,
"Length": 10,
"Identifier": "CUEI",
"Name": "DTMF Descriptor",
"PreRoll": 177,
"DTMFCount": 4,
"DTMFChars": 4186542473
}
],
"Packet": {
"PacketNumber": 73885,
"Pid": 515,
"Program": 51,
"Pcr": 38104.526277,
"Pts": 38105.268588
}
}
package main
import (
"fmt"
"github.com/futzu/cuei"
)
func main(){
var cue cuei.Cue
data := cuei.DeB64("/DA7AAAAAAAAAP/wFAUAAAABf+/+AItfZn4AKTLgAAEAAAAWAhRDVUVJAAAAAX//AAApMuABACIBAIoXZrM=")
cue.Decode(data)
fmt.Println("Cue as Json")
cue.Show()
}- Scte35Parser is for incorporating with another MPEGTS parser.
- Example
import(
"github.com/futzu/cuei"
)
scte35parser := cuei.NewScte35Parser()
// Each time your parser/demuxer finds a SCTE-35 packet (stream type 0x86)
// do something like
cue := scte35parser.Parse(aScte35Packet)
if cue != nil {
// do something with the cue
}-
If the MPEGTS SCTE-35 packet contains a complete cue message
- The cue message is decoded into a Cue and returned.
-
If the MPEGTS SCTE-35 packet is a partial cue message
-
It will be stored and aggregated with the next MPEGTS SCTE-35 packet until complete.
-
Completed cue messages are decoded into a Cue and returned.
-
package main
import (
"fmt"
"github.com/futzu/cuei"
)
type Cue2 struct {
cuei.Cue // Embed cuei.Cue
}
func (cue2 *Cue2) Show() { // Override Show
fmt.Printf("%+v",cue2.Command)
}
func main(){
var cue2 Cue2
data := cuei.DeB64("/DA7AAAAAAAAAP/wFAUAAAABf+/+AItfZn4AKTLgAAEAAAAWAhRDVUVJAAAAAX//AAApMuABACIBAIoXZrM=")
cue2.Decode(data)
cue2.Show()
}package main
import (
"fmt"
"github.com/futzu/cuei"
)
type Cue2 struct {
cuei.Cue // Embed cuei.Cue
}
func (cue2 *Cue2) Show() { // Override Show
fmt.Println("Cue2.Show()")
fmt.Printf("%+v",cue2.Command)
fmt.Println("\n\ncuei.Cue.Show() from cue2.Show()")
cue2.Cue.Show() // Call the Show method from embedded cuei.Cue
}
func main(){
var cue2 Cue2
data := cuei.DeB64("/DA7AAAAAAAAAP/wFAUAAAABf+/+AItfZn4AKTLgAAEAAAAWAhRDVUVJAAAAAX//AAApMuABACIBAIoXZrM=")
cue2.Decode(data)
cue2.Show()
}
/**
Show the packet PTS time and Splice Command Name of SCTE-35 Cues
in a MPEGTS stream.
**/
package main
import (
"os"
"fmt"
"github.com/futzu/cuei"
)
func main() {
args := os.Args[1:]
for _,arg := range args {
fmt.Printf("\nNext File: %s\n\n", arg)
var stream cuei.Stream
stream.Decode(arg)
for _,c:= range stream.Cues {
fmt.Printf("PTS: %v, Splice Command: %v\n",c.PacketData.Pts, c.Command.Name )
}
}
}