skdc

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2025 License: BSD-2-Clause Imports: 10 Imported by: 0

README ΒΆ

Install | Go Docs | Examples |

Super Karate Death Car is a SCTE-35 Parser lib written in Go.

Encoder/Decoder for SCTE-35


  • Parses SCTE-35 Cues from MPEGTS or Bytes or Base64 or Hex or Int or Octal or even Base 36.
  • 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
  • Encodes Time Signals and Splice Inserts with Descriptors and Upids.

Super Karate Death Car is fast.

image

Want to parse an MPEGTS video and print the SCTE-35? πŸ›°οΈ
Do it in ten lines.
package main                        

import (                              
        "os"                            
        "github.com/superkabuki/skdc"       
)                                    

func main(){                         
        arg := os.Args[1]             
        stream := skdc.NewStream()    
        stream.Decode(arg)           
}                                    

Documentation

Install skdc
go install github.com/superkabuki/skdc@latest

Quick Demo
  • skdcdemo.go
package main

import (
        "os"
        "fmt"
        "github.com/superkabuki/skdc"
)

func main(){

        arg := os.Args[1]

        stream := skdc.NewStream()
        cues := stream.Decode(arg)
        for _,cue := range cues {
        fmt.Printf("Command is a %v\n", cue.Command.Name)
        }

}



build skdcdemo
go build skdcdemo.go
parse mpegts video for scte35
./skdcdemo a_video_with_scte35.ts
output
Next 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
    }
}


Parse base64 encoded SCTE-35
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main(){

	cue := skdc.NewCue()
	data := "/DA7AAAAAAAAAP/wFAUAAAABf+/+AItfZn4AKTLgAAEAAAAWAhRDVUVJAAAAAX//AAApMuABACIBAIoXZrM="
        cue.Decode(data) 
        fmt.Println("Cue as Json")
        cue.Show()
}
Shadow a Cue struct method
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

type Cue2 struct {
    skdc.Cue               		// Embed skdc.Cue
}
func (cue2 *Cue2) Show() {        	// Override Show
	fmt.Printf("%+v",cue2.Command)
}

func main(){
	var cue2 Cue2
	data := "/DA7AAAAAAAAAP/wFAUAAAABf+/+AItfZn4AKTLgAAEAAAAWAhRDVUVJAAAAAX//AAApMuABACIBAIoXZrM="
        cue2.Decode(data) 
        cue2.Show()
}

Call a shadowed method
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

type Cue2 struct {
    skdc.Cue               		// Embed skdc.Cue
}
func (cue2 *Cue2) Show() {        	// Override Show
	fmt.Println("Cue2.Show()")
	fmt.Printf("%+v",cue2.Command) 
	fmt.Println("\n\nskdc.Cue.Show() from cue2.Show()")
	cue2.Cue.Show()			// Call the Show method from embedded skdc.Cue
}

func main(){
	var cue2 Cue2
	data := "/DA7AAAAAAAAAP/wFAUAAAABf+/+AItfZn4AKTLgAAEAAAAWAhRDVUVJAAAAAX//AAApMuABACIBAIoXZrM="
        cue2.Decode(data) 
        cue2.Show()
	
}


Use Dot notation to access SCTE-35 Cue values

/**
Show  the packet PTS time and Splice Command Name of SCTE-35 Cues
in a MPEGTS stream.
**/
package main

import (
	"os"
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {
	arg := os.Args[1]
	stream := skdc.NewStream()
	cues :=	stream.Decode(arg)
	for _,c := range cues {
		fmt.Printf("PTS: %v, Splice Command: %v\n",c.PacketData.Pts, c.Command.Name )
	}
}

Load JSON and Encode
  • skdc can accept SCTE-35 data as JSON and encode it to Base64, Bytes, or Hex string.
  • The function skdc.Json2Cue() accepts SCTE-35 JSON as input and returns a *skdc.Cue
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {

	js := `{
    "InfoSection": {
        "Name": "Splice Info Section",
        "TableID": "0xfc",
        "SectionSyntaxIndicator": false,
        "Private": false,
        "Reserved": "0x3",
        "SectionLength": 42,
        "ProtocolVersion": 0,
        "EncryptedPacket": false,
        "EncryptionAlgorithm": 0,
        "PtsAdjustment": 0,
        "CwIndex": "0xff",
        "Tier": "0xfff",
        "CommandLength": 15,
        "CommandType": 5
    },
    "Command": {
        "Name": "Splice Insert",
        "CommandType": 5,
        "SpliceEventID": 5690,
        "OutOfNetworkIndicator": true,
        "ProgramSpliceFlag": true,
        "TimeSpecifiedFlag": true,
        "PTS": 23683.480033
    },
    "DescriptorLoopLength": 10,
    "Descriptors": [
        {
            "Length": 8,
            "Identifier": "CUEI",
            "Name": "Avail Descriptor"
        }
    ],
    "Crc32": "0xd7165c79"
}
`
cue :=  skdc.Json2Cue(js)    // 
cue.AdjustPts(28.0)   	 // Apply pts adjustment
fmt.Println("\nBytes:\n\t", cue.Encode())	// Bytes
fmt.Println("\nBase64:\n\t",cue.Encode2B64())  	// Base64
fmt.Println("\nHex:\n\t",cue.Encode2Hex()) 	// Hex

}


  • Output
Bytes:
	[252 48 42 0 0 0 38 115 192 255 255 240 15 5 0 0 22 58 127 207 254 127 12 79 115
	0 0 0 0 0 10 0 8 67 85 69 73 0 0 0 0 236 139 53 78]

Base64:
	 /DAqAAAAJnPA///wDwUAABY6f8/+fwxPcwAAAAAACgAIQ1VFSQAAAADsizVO

Hex:
	 0xfc302a0000002673c0fffff00f050000163a7fcffe7f0c4f7300000000000a00084355454900000000ec8b354e

skdc.Stream

Custom Cue Handling for MPEGTS Streams
Four Steps
  1. Create Stream Instance
  2. Read Bytes from the video stream (in multiples of 188)
  3. Call Stream.DecodeBytes(Bytes)
  4. Process [] *Cue returned by Stream.DecodeBytes
package main

import (
        "fmt"
        "github.com/superkabuki/skdc"
        "os"
)

func main() {

  arg := os.Args[1]
  stream := skdc.NewStream()  //   (1)
  bufSize := 32768 * 188   // Always read in multiples of 188
  file, err := os.Open(arg)
  if err != nil {
    fmt.Printf("Unable to read %v\n", arg)
  }
  buffer := make([]byte, bufSize)
  for {
  	_, err := file.Read(buffer)   //  (2)
	if err != nil {
		break
	}
	cues := stream.DecodeBytes(buffer)  // (3)

	for _, c := range cues {  //   (4)
		fmt.Printf(" %v, %v\n", c.PacketData.Pts, c.Encode2B64())
	}
  }
}

  • Output
60638.745877, /DAWAAAAAAAAAP/wBQb/RUqw1AAAd6OnQA==
 60638.745877, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60640.714511, /DAWAAAAAAAAAP/wBQb/RU1wqAAAoqaOaA==
 60640.714511, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60642.015811, /DAWAAAAAAAAAP/wBQb/RU9F4AAA9Te5ag==
 60642.015811, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60642.749877, /DAWAAAAAAAAAP/wBQb/RVAwfAAAWOLrFQ==
 60642.749877, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60644.718511, /DAWAAAAAAAAAP/wBQb/RVLwUAAAj7/Pgw==
 60644.718511, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60646.720511, /DAWAAAAAAAAAP/wBQb/RVWwJAAA8pm/jg==
 60646.720511, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60648.121911, /DAWAAAAAAAAAP/wBQb/RVec0gAAt0QzqA==
 60648.121911, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60634.208011, /DAWAAAAAAAAAP/wBQb/RUR1fAAAik8gfQ==
 60634.208011, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60634.675144, /DAWAAAAAAAAAP/wBQb/RUUxLAAABQVyEA==
 60634.675144, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
 60636.710511, /DAWAAAAAAAAAP/wBQb/RUfxAAAA0lhWhg==
 60636.710511, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=
Custom Cue Handling for MPEGTS Streams Over Multicast
Need a multicast sender? Try gums
for multicast we use the same four steps,
the only difference is we read the bytes from the network instead of a local file.
  1. Create Stream Instance
  2. Read Bytes from the video stream (in multiples of 188)
  3. Call Stream.DecodeBytes(Bytes)
  4. Process [] *Cue returned by Stream.DecodeBytes
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
	"os"
        "net"
)


func main() {
  arg := os.Args[1]
  stream := skdc.NewStream()  //  (1)
  stream.Quiet = true
  dgram:=1316  // <-- multicast dgram size is 1316 (188*7) for mpegts
  bufSize := 100 * dgram
  addr, _ := net.ResolveUDPAddr("udp", arg)
  l, _ := net.ListenMulticastUDP("udp", nil, addr)  // Multicast Connection 
  l.SetReadBuffer(bufSize)
  for {
	buffer := make([]byte, bufSize)  // (2)
	l.ReadFromUDP(buffer)
	cues := stream.DecodeBytes(buffer)   //  (3)
	for _, c := range cues {      //  (4)
		fmt.Printf(" %v, %v\n", c.PacketData.Pts, c.Encode2B64())
	}
  }
}

Documentation ΒΆ

Index ΒΆ

Examples ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func Hexed ΒΆ

func Hexed(somebites []byte) string

Hexed converts bytes to hex string

func IsIn ΒΆ

func IsIn[T comparable](slice []T, val T) bool

IsIn is a test for slice membership

func MkCrc32 ΒΆ

func MkCrc32(data []byte) string

MkCrc32 generate a 32 bit Crc as hex

Types ΒΆ

type AvailDescriptor ΒΆ

type AvailDescriptor struct {
	TagLenNameId
	ProviderAvailID uint32
}

Avail Descriptor

type BandwidthReservation ΒΆ

type BandwidthReservation struct {
	NameAndType
}

Bandwidth Reservation

type Command ΒΆ

Command

These Splice Command types are consolidated into Command,
this is done to enable dot notation in a SCTE-35 Cue.

    0x0: Splice Null,
    0x5: Splice Insert,
    0x6: Time Signal,
    0x7: Bandwidth Reservation,
    0xff: Private Command,

func (*Command) Json ΒΆ

func (cmd *Command) Json() string

Return Command as JSON

func (*Command) MarshalJSON ΒΆ

func (cmd *Command) MarshalJSON() ([]byte, error)

MarshalJSON trims down a Command instance to a specific type and then turns it into JSON.

func (*Command) Show ΒΆ

func (cmd *Command) Show()

Print Command as JSON

type Cue ΒΆ

type Cue struct {
	InfoSection *InfoSection
	Command     *Command
	Dll         uint16       `json:"DescriptorLoopLength"`
	Descriptors []Descriptor `json:",omitempty"`
	Crc32       string
	PacketData  *packetData `json:",omitempty"`
}

* Cue is a SCTE35 cue.

A Cue contains:

	1 InfoSection
   	1 Crc32
   	1 Command
   	1 Dll  Descriptor loop length
   	0 or more Splice Descriptors
   	1 packetData (if parsed from MPEGTS)

*

func Json2Cue ΒΆ

func Json2Cue(s string) *Cue

Take a JSON string and return a *Cue

Example ΒΆ
package main

import (
	"github.com/superkabuki/skdc"
)

func main() {

	js := `{
    "InfoSection": {
        "Name": "Splice Info Section",
        "TableID": "0xfc",
        "SectionSyntaxIndicator": false,
        "Private": false,
        "Reserved": "0x3",
        "SectionLength": 42,
        "ProtocolVersion": 0,
        "EncryptedPacket": false,
        "EncryptionAlgorithm": 0,
        "PtsAdjustment": 0,
        "CwIndex": "0xff",
        "Tier": "0xfff",
        "CommandLength": 15,
        "CommandType": 5
    },
    "Command": {
        "Name": "Splice Insert",
        "CommandType": 5,
        "SpliceEventID": 5690,
        "OutOfNetworkIndicator": true,
        "ProgramSpliceFlag": true,
        "TimeSpecifiedFlag": true,
        "PTS": 23683.480033
    },
    "DescriptorLoopLength": 10,
    "Descriptors": [
        {
            "Length": 8,
            "Identifier": "CUEI",
            "Name": "Avail Descriptor"
        }
    ]

}
`
	cue := skdc.Json2Cue(js)
	cue.Show()
}
Output:

func NewCue ΒΆ

func NewCue() *Cue

initialize and return a *Cue

Example ΒΆ
package main

import (
	"github.com/superkabuki/skdc"
)

func main() {
	data := "/DCtAAAAAAAAAP/wBQb+Tq9DwQCXAixDVUVJCUvhcH+fAR1QQ1IxXzEyMTYyMTE0MDBXQUJDUkFDSEFFTFJBWSEBAQIsQ1VFSQlL4W9/nwEdUENSMV8xMjE2MjExNDAwV0FCQ1JBQ0hBRUxSQVkRAQECGUNVRUkJTBwVf58BClRLUlIxNjA4NEEQAQECHkNVRUkJTBwWf98AA3clYAEKVEtSUjE2MDg0QSABAdHBXYA="
	cue := skdc.NewCue()
	//	cue.Command = &skdc.Command{}
	cue.Decode(data)
	cue.Show()

}
Output:

func (*Cue) AdjustPts ΒΆ

func (cue *Cue) AdjustPts(seconds float64)

AdjustPts adds seconds to cue.InfoSection.PtsAdjustment

Example ΒΆ
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {
	data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
	cue := skdc.NewCue()
	cue.Decode(data)
	fmt.Println("Before calling Cue.AdjustPts")
	fmt.Println(data)
	cue.InfoSection.Show()
	fmt.Println()
	// Change cue.InfoSection.PtsAdjustment and re-encode cue to bytes
	cue.AdjustPts(33.333)
	fmt.Println("After calling Cue.AdjustPts")
	fmt.Println(cue.Encode2B64())
	cue.InfoSection.Show()

}
Output:

func (*Cue) Decode ΒΆ

func (cue *Cue) Decode(i interface{}) bool

Decode takes Cue data as []byte, base64 or hex string.

Example ΒΆ
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {
	data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
	cue := skdc.NewCue()
	cue.Decode(data)
	fmt.Println("Cue.Decode() parses data and populate the fields in the Cue.")
	cue.Show()
	fmt.Println("\n\nCue values can be accessed via dot notiation,")
	cue.Command.PTS = 987.654321
	fmt.Printf("cue.Command.PTS = %v\n", cue.Command.PTS)
	cue.Show()

}
Output:

func (*Cue) Encode ΒΆ

func (cue *Cue) Encode() []byte

Encode Cue currently works for Splice Inserts and Time Signals

Example ΒΆ
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {
	data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
	cue := skdc.NewCue()
	cue.Decode(data)
	// encode to bytes
	fmt.Println(cue.Encode())

}
Output:

func (*Cue) Encode2B64 ΒΆ

func (cue *Cue) Encode2B64() string

Encode2B64 Encodes cue and returns Base64 string

Example ΒΆ
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {
	data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
	cue := skdc.NewCue()
	cue.Decode(data)
	// encode to base64
	fmt.Println(cue.Encode2B64())
}
Output:

func (*Cue) Encode2Hex ΒΆ

func (cue *Cue) Encode2Hex() string

Encode2Hex encodes cue and returns as a hex string

Example ΒΆ
package main

import (
	"fmt"
	"github.com/superkabuki/skdc"
)

func main() {
	data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
	cue := skdc.NewCue()
	// decode base64 data into cue
	cue.Decode(data)
	// Encode the cue as hex
	hexed := cue.Encode2Hex()
	fmt.Println(hexed)
	// decode the hex back into a Cue
	cue.Decode(hexed)
	cue.Show()
}
Output:

func (*Cue) Show ΒΆ

func (cue *Cue) Show()

Show display SCTE-35 data as JSON.

Example ΒΆ
package main

import (
	"github.com/superkabuki/skdc"
)

func main() {
	dee := "/DA0AAAAAAAAAAAABQb/4zZ7tQAeAhxDVUVJAA6Gjz/TAAESy7EICAAAAAAA0/cuIgAAjFLk9Q=="
	cue := skdc.NewCue()
	cue.Decode(dee)
	cue.Show()
	cue.Showthreefive()

}
Output:

func (*Cue) Six2Five ΒΆ

func (cue *Cue) Six2Five() string

*

	Convert  Cue.Command  from a  Time Signal
	to a Splice Insert and return a base64 string
 	SegmentationTypeIds to trigger CUE-OUTs : 0x22, 0x30, 0x32, 0x34, 0x36, 0x44, 0x46
	SegmentationTypeIds to trigger CUE-INs:  0x23, 0x31, 0x33, 0x35, 0x37, 0x45, 0x47

*

type DTMFDescriptor ΒΆ

type DTMFDescriptor struct {
	TagLenNameId
	PreRoll   uint8
	DTMFCount uint8
	DTMFChars uint64
}

DTMF Descriptor

type Descriptor ΒΆ

*

Descriptor is the combination of all the descriptors
this is to maintain dot notation in the Cue struct.

*

func (*Descriptor) Json ΒΆ

func (dscptr *Descriptor) Json() string

Return Descriptor as JSON

func (*Descriptor) MarshalJSON ΒΆ

func (dscptr *Descriptor) MarshalJSON() ([]byte, error)
	 *
	    Custom MarshalJSON
	        Marshal a Descriptor into

            0x0: AvailDescriptor,
		    0x1: DTMFDescriptor,
		    0x2: SegmentationDescriptor,
		    0x3: TimeDescriptor,
	        or just return the Descriptor

*

func (*Descriptor) Show ΒΆ

func (dscptr *Descriptor) Show()

Print Descriptor as JSON

type InfoSection ΒΆ

type InfoSection struct {
	Name                   string
	TableID                string
	SectionSyntaxIndicator bool
	Private                bool
	SapType                uint8
	SapDetails             string
	SectionLength          uint16
	ProtocolVersion        uint8
	EncryptedPacket        bool
	EncryptionAlgorithm    uint8
	PtsAdjustment          float64
	CwIndex                string
	Tier                   string
	CommandLength          uint16
	CommandType            uint8
}

InfoSection is the splice info section of the SCTE 35 cue.

func (*InfoSection) Json ΒΆ

func (infosec *InfoSection) Json() string

Return InfoSection as JSON

func (*InfoSection) Show ΒΆ

func (infosec *InfoSection) Show()

Print InfoSection as JSON

type NameAndType ΒΆ

type NameAndType struct {
	Name        string
	CommandType uint8
}

Command Name and Type

type Pids ΒΆ

type Pids struct {
	PmtPids    []uint16
	PcrPids    []uint16
	Scte35Pids []uint16
	MaybePids  []uint16
}

Pids holds collections of pids by type for skdc.Stream.

type PrivateCommand ΒΆ

type PrivateCommand struct {
	NameAndType
	PrivateBytes []byte
	Identifier   uint32
}

Private Command

type SegmentationDescriptor ΒΆ

type SegmentationDescriptor struct {
	TagLenNameId
	SegmentationEventID                    string
	SegmentationEventCancelIndicator       bool
	SegmentationEventIDComplianceIndicator bool
	ProgramSegmentationFlag                bool
	SegmentationDurationFlag               bool
	DeliveryNotRestrictedFlag              bool
	WebDeliveryAllowedFlag                 bool
	NoRegionalBlackoutFlag                 bool
	ArchiveAllowedFlag                     bool
	DeviceRestrictions                     string
	SegmentationDuration                   float64
	SegmentationMessage                    string
	SegmentationUpidType                   uint8
	SegmentationUpidLength                 uint8
	SegmentationUpid                       *Upid
	SegmentationTypeID                     uint8
	SegmentNum                             uint8
	SegmentsExpected                       uint8
	SubSegmentNum                          uint8
	SubSegmentsExpected                    uint8
}

Segmentation Descriptor

type SpliceInsert ΒΆ

type SpliceInsert struct {
	NameAndType
	SpliceTime
	SpliceEventID              uint32 `xml:"spliceEventId,attr"`
	SpliceEventCancelIndicator bool   `xml:"spliceEventCancelIndicator,attr"`
	OutOfNetworkIndicator      bool   `xml: "outOfNetworkIndicator,attr"`
	ProgramSpliceFlag          bool
	DurationFlag               bool
	BreakDuration              float64
	BreakAutoReturn            bool
	SpliceImmediateFlag        bool   `xml:"spliceImmediateFlag,attr"`
	EventIDComplianceFlag      bool   `xml:"eventIdComplianceFlag,attr"`
	UniqueProgramID            uint16 `xml:"uniqueProgramId,attr"`
	AvailNum                   uint8  `xml:"availNum,attr"`
	AvailExpected              uint8  `xml: "availsExpected,attr"`
}

Splice Insert

type SpliceNull ΒΆ

type SpliceNull struct {
	NameAndType
}

Splice Null

type SpliceTime ΒΆ

type SpliceTime struct {
	TimeSpecifiedFlag bool    `json:",omitempty"`
	PTS               float64 `json:",omitempty"` //`xml:"pts_time"`
}

SpliceTime is Used by Time Signal and Splice Insert

type Stream ΒΆ

type Stream struct {
	Cues     []*Cue
	Pids     *Pids
	Pid2Prgm map[uint16]uint16 // pid to program map
	Pid2Type map[uint16]uint8  // pid to stream type map
	Programs []uint16
	Prgm2Pcr map[uint16]uint64 // program to pcr map
	Prgm2Pts map[uint16]uint64 // program to pts map

	Quiet bool // Don't call Cue.Show() when a Cue is found.
	// contains filtered or unexported fields
}

Stream for parsing MPEGTS for SCTE-35

func NewStream ΒΆ

func NewStream() *Stream

initialize and return a *Stream

func (*Stream) Decode ΒΆ

func (stream *Stream) Decode(fname string) []*Cue

Decode fname (a file name) for SCTE-35

func (*Stream) DecodeBytes ΒΆ

func (stream *Stream) DecodeBytes(bites []byte) []*Cue

DecodeBytes Parses a chunk of mpegts bytes for SCTE-35

func (*Stream) DecodeMulticast ΒΆ

func (stream *Stream) DecodeMulticast(fname string) []*Cue

Decode Multicast Notes:

  • multicast urls start with udp://@
  • datagram size should be 1316

func (*Stream) DecodeReader ΒΆ

func (stream *Stream) DecodeReader(rdr io.Reader) []*Cue

Decode SCTE-35 Cues from an io.Reader interface

type TagLenNameId ΒΆ

type TagLenNameId struct {
	Tag        uint8
	Length     uint8
	Name       string
	Identifier string
}

Tag, Length , Name and Identifier for Descriptors

type TimeDescriptor ΒΆ

type TimeDescriptor struct {
	TagLenNameId
	TAISeconds uint64
	TAINano    uint32
	UTCOffset  uint16
}

Time Descriptor

type TimeSignal ΒΆ

type TimeSignal struct {
	NameAndType
	SpliceTime
}

Time Signal

type Upid ΒΆ

type Upid struct {
	Name             string `json:",omitempty"`
	UpidType         uint8  `json:",omitempty"`
	Value            string `json:",omitempty"`
	TSID             uint16 `json:",omitempty"`
	Reserved         uint8  `json:",omitempty"`
	EndOfDay         uint8  `json:",omitempty"`
	UniqueFor        uint16 `json:",omitempty"`
	ContentID        []byte `json:",omitempty"`
	Upids            []Upid `json:",omitempty"`
	FormatIdentifier string `json:",omitempty"`
	PrivateData      []byte `json:",omitempty"`
}

Upid is the Struct for Segmentation Upids

Non-standard UPID types are returned as bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL