Browse Source

move hls utils into gortsplib

pull/591/head
aler9 4 years ago
parent
commit
3b0327233e
  1. 1
      Makefile
  2. 2
      go.mod
  3. 4
      go.sum
  4. 3
      internal/core/hls_source_test.go
  5. 2
      internal/core/rtmp_conn.go
  6. 2
      internal/core/rtmp_source.go
  7. 79
      internal/h264/annexb.go
  8. 115
      internal/h264/annexb_test.go
  9. 90
      internal/h264/anticompetition.go
  10. 47
      internal/h264/anticompetition_test.go
  11. 55
      internal/h264/avcc.go
  12. 85
      internal/h264/avcc_test.go
  13. 61
      internal/h264/dtsestimator.go
  14. 32
      internal/h264/dtsestimator_test.go
  15. 88
      internal/h264/nalutype.go
  16. 2
      internal/hls/client.go
  17. 2
      internal/hls/client_test.go
  18. 6
      internal/hls/muxer_ts_generator.go
  19. 4
      internal/hls/muxer_ts_segment.go

1
Makefile

@ -85,7 +85,6 @@ test-internal: @@ -85,7 +85,6 @@ test-internal:
./internal/confenv \
./internal/confwatcher \
./internal/externalcmd \
./internal/h264 \
./internal/hls \
./internal/logger \
./internal/rlimit \

2
go.mod

@ -5,7 +5,7 @@ go 1.16 @@ -5,7 +5,7 @@ go 1.16
require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/aler9/gortsplib v0.0.0-20210923175257-239b71d9754c
github.com/aler9/gortsplib v0.0.0-20210923180721-13c6b69d302d
github.com/asticode/go-astits v1.9.0
github.com/fsnotify/fsnotify v1.4.9
github.com/gin-gonic/gin v1.7.2

4
go.sum

@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo @@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/aler9/gortsplib v0.0.0-20210923175257-239b71d9754c h1:hpRbxh52R+4aQjnuchAqtcMJQbgRWUzInLuLT45CzbE=
github.com/aler9/gortsplib v0.0.0-20210923175257-239b71d9754c/go.mod h1:WCO/ZcqI2R6m1lKV2ZENL0+AvV2NcIVEYtHtgLFjH6A=
github.com/aler9/gortsplib v0.0.0-20210923180721-13c6b69d302d h1:aiMG2qO6tpLgXYeaWH/o/RT9en/tMNco/KZ9XN+QOt0=
github.com/aler9/gortsplib v0.0.0-20210923180721-13c6b69d302d/go.mod h1:DKI+t4Wj5YjkpxmiQhmG3qRG5VMOprDQvto62wMO68c=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc=
github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8=

3
internal/core/hls_source_test.go

@ -11,12 +11,11 @@ import ( @@ -11,12 +11,11 @@ import (
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/asticode/go-astits"
"github.com/gin-gonic/gin"
"github.com/pion/rtp"
"github.com/stretchr/testify/require"
"github.com/aler9/rtsp-simple-server/internal/h264"
)
type testHLSServer struct {

2
internal/core/rtmp_conn.go

@ -12,6 +12,7 @@ import ( @@ -12,6 +12,7 @@ import (
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/aler9/gortsplib/pkg/ringbuffer"
"github.com/aler9/gortsplib/pkg/rtpaac"
"github.com/aler9/gortsplib/pkg/rtph264"
@ -19,7 +20,6 @@ import ( @@ -19,7 +20,6 @@ import (
"github.com/pion/rtp"
"github.com/aler9/rtsp-simple-server/internal/externalcmd"
"github.com/aler9/rtsp-simple-server/internal/h264"
"github.com/aler9/rtsp-simple-server/internal/logger"
"github.com/aler9/rtsp-simple-server/internal/rtcpsenderset"
"github.com/aler9/rtsp-simple-server/internal/rtmp"

2
internal/core/rtmp_source.go

@ -7,11 +7,11 @@ import ( @@ -7,11 +7,11 @@ import (
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/aler9/gortsplib/pkg/rtpaac"
"github.com/aler9/gortsplib/pkg/rtph264"
"github.com/notedit/rtmp/av"
"github.com/aler9/rtsp-simple-server/internal/h264"
"github.com/aler9/rtsp-simple-server/internal/logger"
"github.com/aler9/rtsp-simple-server/internal/rtcpsenderset"
"github.com/aler9/rtsp-simple-server/internal/rtmp"

79
internal/h264/annexb.go

@ -1,79 +0,0 @@ @@ -1,79 +0,0 @@
package h264
import (
"fmt"
)
// DecodeAnnexB decodes NALUs from the Annex-B code stream format.
func DecodeAnnexB(byts []byte) ([][]byte, error) {
bl := len(byts)
// check initial delimiter
n := func() int {
if bl < 3 || byts[0] != 0x00 || byts[1] != 0x00 {
return -1
}
if byts[2] == 0x01 {
return 3
}
if bl < 4 || byts[2] != 0x00 || byts[3] != 0x01 {
return -1
}
return 4
}()
if n < 0 {
return nil, fmt.Errorf("input doesn't start with a delimiter")
}
var ret [][]byte
zeros := 0
start := n
delimStart := 0
for i := n; i < bl; i++ {
switch byts[i] {
case 0:
if zeros == 0 {
delimStart = i
}
zeros++
case 1:
if zeros == 2 || zeros == 3 {
nalu := byts[start:delimStart]
if len(nalu) == 0 {
return nil, fmt.Errorf("empty NALU")
}
ret = append(ret, nalu)
start = i + 1
}
zeros = 0
default:
zeros = 0
}
}
nalu := byts[start:bl]
if len(nalu) == 0 {
return nil, fmt.Errorf("empty NALU")
}
ret = append(ret, nalu)
return ret, nil
}
// EncodeAnnexB encodes NALUs into the Annex-B code stream format.
func EncodeAnnexB(nalus [][]byte) ([]byte, error) {
var ret []byte
for _, nalu := range nalus {
ret = append(ret, []byte{0x00, 0x00, 0x00, 0x01}...)
ret = append(ret, nalu...)
}
return ret, nil
}

115
internal/h264/annexb_test.go

@ -1,115 +0,0 @@ @@ -1,115 +0,0 @@
package h264
import (
"testing"
"github.com/stretchr/testify/require"
)
var casesAnnexB = []struct {
name string
encin []byte
encout []byte
dec [][]byte
}{
{
"2 zeros, single",
[]byte{0x00, 0x00, 0x01, 0xaa, 0xbb},
[]byte{0x00, 0x00, 0x00, 0x01, 0xaa, 0xbb},
[][]byte{
{0xaa, 0xbb},
},
},
{
"2 zeros, multiple",
[]byte{
0x00, 0x00, 0x01, 0xaa, 0xbb, 0x00, 0x00, 0x01,
0xcc, 0xdd, 0x00, 0x00, 0x01, 0xee, 0xff,
},
[]byte{
0x00, 0x00, 0x00, 0x01, 0xaa, 0xbb, 0x00, 0x00,
0x00, 0x01, 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x01,
0xee, 0xff,
},
[][]byte{
{0xaa, 0xbb},
{0xcc, 0xdd},
{0xee, 0xff},
},
},
{
"3 zeros, single",
[]byte{0x00, 0x00, 0x00, 0x01, 0xaa, 0xbb},
[]byte{0x00, 0x00, 0x00, 0x01, 0xaa, 0xbb},
[][]byte{
{0xaa, 0xbb},
},
},
{
"3 zeros, multiple",
[]byte{
0x00, 0x00, 0x00, 0x01, 0xaa, 0xbb, 0x00, 0x00,
0x00, 0x01, 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x01,
0xee, 0xff,
},
[]byte{
0x00, 0x00, 0x00, 0x01, 0xaa, 0xbb, 0x00, 0x00,
0x00, 0x01, 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x01,
0xee, 0xff,
},
[][]byte{
{0xaa, 0xbb},
{0xcc, 0xdd},
{0xee, 0xff},
},
},
}
func TestAnnexBDecode(t *testing.T) {
for _, ca := range casesAnnexB {
t.Run(ca.name, func(t *testing.T) {
dec, err := DecodeAnnexB(ca.encin)
require.NoError(t, err)
require.Equal(t, ca.dec, dec)
})
}
}
func TestAnnexBEncode(t *testing.T) {
for _, ca := range casesAnnexB {
t.Run(ca.name, func(t *testing.T) {
enc, err := EncodeAnnexB(ca.dec)
require.NoError(t, err)
require.Equal(t, ca.encout, enc)
})
}
}
func TestAnnexBDecodeError(t *testing.T) {
for _, ca := range []struct {
name string
enc []byte
}{
{
"empty",
[]byte{},
},
{
"missing initial delimiter",
[]byte{0xaa, 0xbb},
},
{
"empty initial",
[]byte{0x00, 0x00, 0x01},
},
{
"empty 2nd",
[]byte{0x00, 0x00, 0x01, 0xaa, 0x00, 0x00, 0x01},
},
} {
t.Run(ca.name, func(t *testing.T) {
_, err := DecodeAnnexB(ca.enc)
require.Error(t, err)
})
}
}

90
internal/h264/anticompetition.go

@ -1,90 +0,0 @@ @@ -1,90 +0,0 @@
package h264
// AntiCompetitionAdd adds the anti-competition bytes to a NALU.
func AntiCompetitionAdd(nalu []byte) []byte {
var ret []byte
step := 0
start := 0
for i, b := range nalu {
switch step {
case 0:
if b == 0 {
step++
}
case 1:
if b == 0 {
step++
} else {
step = 0
}
case 2:
switch b {
case 3, 2, 1, 0:
ret = append(ret, nalu[start:i-2]...)
ret = append(ret, []byte{0x00, 0x00, 0x03, b}...)
step = 0
start = i + 1
default:
step = 0
}
}
}
ret = append(ret, nalu[start:]...)
return ret
}
// AntiCompetitionRemove removes the anti-competition bytes from a NALU.
func AntiCompetitionRemove(nalu []byte) []byte {
// 0x00 0x00 0x03 0x00 -> 0x00 0x00 0x00
// 0x00 0x00 0x03 0x01 -> 0x00 0x00 0x01
// 0x00 0x00 0x03 0x02 -> 0x00 0x00 0x02
// 0x00 0x00 0x03 0x03 -> 0x00 0x00 0x03
var ret []byte
step := 0
start := 0
for i, b := range nalu {
switch step {
case 0:
if b == 0 {
step++
}
case 1:
if b == 0 {
step++
} else {
step = 0
}
case 2:
if b == 3 {
step++
} else {
step = 0
}
case 3:
switch b {
case 3, 2, 1, 0:
ret = append(ret, nalu[start:i-3]...)
ret = append(ret, []byte{0x00, 0x00, b}...)
step = 0
start = i + 1
default:
step = 0
}
}
}
ret = append(ret, nalu[start:]...)
return ret
}

47
internal/h264/anticompetition_test.go

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
package h264
import (
"testing"
"github.com/stretchr/testify/require"
)
var casesAntiCompetition = []struct {
name string
unproc []byte
proc []byte
}{
{
"base",
[]byte{
0x00, 0x00, 0x00,
0x00, 0x00, 0x01,
0x00, 0x00, 0x02,
0x00, 0x00, 0x03,
},
[]byte{
0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x03, 0x01,
0x00, 0x00, 0x03, 0x02,
0x00, 0x00, 0x03, 0x03,
},
},
}
func TestAntiCompetitionAdd(t *testing.T) {
for _, ca := range casesAntiCompetition {
t.Run(ca.name, func(t *testing.T) {
proc := AntiCompetitionAdd(ca.unproc)
require.Equal(t, ca.proc, proc)
})
}
}
func TestAntiCompetitionRemove(t *testing.T) {
for _, ca := range casesAntiCompetition {
t.Run(ca.name, func(t *testing.T) {
unproc := AntiCompetitionRemove(ca.proc)
require.Equal(t, ca.unproc, unproc)
})
}
}

55
internal/h264/avcc.go

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
package h264
import (
"encoding/binary"
"fmt"
)
// DecodeAVCC encodes NALUs from the AVCC code stream format.
func DecodeAVCC(byts []byte) ([][]byte, error) {
var ret [][]byte
for len(byts) > 0 {
if len(byts) < 4 {
return nil, fmt.Errorf("invalid length")
}
le := binary.BigEndian.Uint32(byts)
byts = byts[4:]
if len(byts) < int(le) {
return nil, fmt.Errorf("invalid length")
}
ret = append(ret, byts[:le])
byts = byts[le:]
}
if len(ret) == 0 {
return nil, fmt.Errorf("no NALUs decoded")
}
return ret, nil
}
// EncodeAVCC encodes NALUs into the AVCC code stream format.
func EncodeAVCC(nalus [][]byte) ([]byte, error) {
le := 0
for _, nalu := range nalus {
le += 4 + len(nalu)
}
ret := make([]byte, le)
pos := 0
for _, nalu := range nalus {
ln := len(nalu)
binary.BigEndian.PutUint32(ret[pos:], uint32(ln))
pos += 4
copy(ret[pos:], nalu)
pos += ln
}
return ret, nil
}

85
internal/h264/avcc_test.go

@ -1,85 +0,0 @@ @@ -1,85 +0,0 @@
package h264
import (
"testing"
"github.com/stretchr/testify/require"
)
var casesAVCC = []struct {
name string
enc []byte
dec [][]byte
}{
{
"single",
[]byte{
0x00, 0x00, 0x00, 0x03,
0xaa, 0xbb, 0xcc,
},
[][]byte{
{0xaa, 0xbb, 0xcc},
},
},
{
"multiple",
[]byte{
0x00, 0x00, 0x00, 0x02,
0xaa, 0xbb,
0x00, 0x00, 0x00, 0x02,
0xcc, 0xdd,
0x00, 0x00, 0x00, 0x02,
0xee, 0xff,
},
[][]byte{
{0xaa, 0xbb},
{0xcc, 0xdd},
{0xee, 0xff},
},
},
}
func TestAVCCDecode(t *testing.T) {
for _, ca := range casesAVCC {
t.Run(ca.name, func(t *testing.T) {
dec, err := DecodeAVCC(ca.enc)
require.NoError(t, err)
require.Equal(t, ca.dec, dec)
})
}
}
func TestAVCCEncode(t *testing.T) {
for _, ca := range casesAVCC {
t.Run(ca.name, func(t *testing.T) {
enc, err := EncodeAVCC(ca.dec)
require.NoError(t, err)
require.Equal(t, ca.enc, enc)
})
}
}
func TestAVCCDecodeError(t *testing.T) {
for _, ca := range []struct {
name string
enc []byte
}{
{
"empty",
[]byte{},
},
{
"invalid length",
[]byte{0x01},
},
{
"invalid length",
[]byte{0x00, 0x00, 0x00, 0x03},
},
} {
t.Run(ca.name, func(t *testing.T) {
_, err := DecodeAVCC(ca.enc)
require.Error(t, err)
})
}
}

61
internal/h264/dtsestimator.go

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
package h264
import (
"time"
)
// DTSEstimator is a DTS estimator.
type DTSEstimator struct {
initializing int
prevDTS time.Duration
prevPTS time.Duration
prevPrevPTS time.Duration
}
// NewDTSEstimator allocates a DTSEstimator.
func NewDTSEstimator() *DTSEstimator {
return &DTSEstimator{
initializing: 2,
}
}
// Feed provides PTS to the estimator, and returns the estimated DTS.
func (d *DTSEstimator) Feed(pts time.Duration) time.Duration {
switch d.initializing {
case 2:
d.initializing--
return 0
case 1:
d.initializing--
d.prevPTS = pts
d.prevDTS = time.Millisecond
return time.Millisecond
}
dts := func() time.Duration {
// P or I frame
if pts > d.prevPTS {
// previous frame was B
// use the DTS of the previous frame
if d.prevPTS < d.prevPrevPTS {
return d.prevPTS
}
// previous frame was P or I
// use two frames ago plus a small quantity
// to avoid non-monotonous DTS with B-frames
return d.prevPrevPTS + time.Millisecond
}
// B Frame
// increase by a small quantity
return d.prevDTS + time.Millisecond
}()
d.prevPrevPTS = d.prevPTS
d.prevPTS = pts
d.prevDTS = dts
return dts
}

32
internal/h264/dtsestimator_test.go

@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
package h264
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestDTSEstimator(t *testing.T) {
est := NewDTSEstimator()
// initial state
dts := est.Feed(0)
require.Equal(t, time.Duration(0), dts)
// b-frame
dts = est.Feed(1*time.Second - 200*time.Millisecond)
require.Equal(t, time.Millisecond, dts)
// b-frame
dts = est.Feed(1*time.Second - 400*time.Millisecond)
require.Equal(t, 2*time.Millisecond, dts)
// p-frame
dts = est.Feed(1 * time.Second)
require.Equal(t, 1*time.Second-400*time.Millisecond, dts)
// p-frame
dts = est.Feed(1*time.Second + 200*time.Millisecond)
require.Equal(t, 1*time.Second-399*time.Millisecond, dts)
}

88
internal/h264/nalutype.go

@ -1,88 +0,0 @@ @@ -1,88 +0,0 @@
package h264
import (
"fmt"
)
// NALUType is the type of a NALU.
type NALUType uint8
// standard NALU types.
const (
NALUTypeNonIDR NALUType = 1
NALUTypeDataPartitionA NALUType = 2
NALUTypeDataPartitionB NALUType = 3
NALUTypeDataPartitionC NALUType = 4
NALUTypeIDR NALUType = 5
NALUTypeSEI NALUType = 6
NALUTypeSPS NALUType = 7
NALUTypePPS NALUType = 8
NALUTypeAccessUnitDelimiter NALUType = 9
NALUTypeEndOfSequence NALUType = 10
NALUTypeEndOfStream NALUType = 11
NALUTypeFillerData NALUType = 12
NALUTypeSPSExtension NALUType = 13
NALUTypePrefix NALUType = 14
NALUTypeSubsetSPS NALUType = 15
NALUTypeReserved16 NALUType = 16
NALUTypeReserved17 NALUType = 17
NALUTypeReserved18 NALUType = 18
NALUTypeSliceLayerWithoutPartitioning NALUType = 19
NALUTypeSliceExtension NALUType = 20
NALUTypeSliceExtensionDepth NALUType = 21
NALUTypeReserved22 NALUType = 22
NALUTypeReserved23 NALUType = 23
)
// String implements fmt.Stringer.
func (nt NALUType) String() string {
switch nt {
case NALUTypeNonIDR:
return "NonIDR"
case NALUTypeDataPartitionA:
return "DataPartitionA"
case NALUTypeDataPartitionB:
return "DataPartitionB"
case NALUTypeDataPartitionC:
return "DataPartitionC"
case NALUTypeIDR:
return "IDR"
case NALUTypeSEI:
return "SEI"
case NALUTypeSPS:
return "SPS"
case NALUTypePPS:
return "PPS"
case NALUTypeAccessUnitDelimiter:
return "AccessUnitDelimiter"
case NALUTypeEndOfSequence:
return "EndOfSequence"
case NALUTypeEndOfStream:
return "EndOfStream"
case NALUTypeFillerData:
return "FillerData"
case NALUTypeSPSExtension:
return "SPSExtension"
case NALUTypePrefix:
return "Prefix"
case NALUTypeSubsetSPS:
return "SubsetSPS"
case NALUTypeReserved16:
return "Reserved16"
case NALUTypeReserved17:
return "Reserved17"
case NALUTypeReserved18:
return "Reserved18"
case NALUTypeSliceLayerWithoutPartitioning:
return "SliceLayerWithoutPartitioning"
case NALUTypeSliceExtension:
return "SliceExtension"
case NALUTypeSliceExtensionDepth:
return "SliceExtensionDepth"
case NALUTypeReserved22:
return "Reserved22"
case NALUTypeReserved23:
return "Reserved23"
}
return fmt.Sprintf("unknown (%d)", nt)
}

2
internal/hls/client.go

@ -13,13 +13,13 @@ import ( @@ -13,13 +13,13 @@ import (
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/aler9/gortsplib/pkg/rtpaac"
"github.com/aler9/gortsplib/pkg/rtph264"
"github.com/asticode/go-astits"
"github.com/grafov/m3u8"
"github.com/aler9/rtsp-simple-server/internal/aac"
"github.com/aler9/rtsp-simple-server/internal/h264"
"github.com/aler9/rtsp-simple-server/internal/logger"
)

2
internal/hls/client_test.go

@ -9,11 +9,11 @@ import ( @@ -9,11 +9,11 @@ import (
"testing"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/asticode/go-astits"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/require"
"github.com/aler9/rtsp-simple-server/internal/h264"
"github.com/aler9/rtsp-simple-server/internal/logger"
)

6
internal/hls/muxer_ts_generator.go

@ -5,10 +5,10 @@ import ( @@ -5,10 +5,10 @@ import (
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/gortsplib/pkg/h264"
"github.com/asticode/go-astits"
"github.com/aler9/rtsp-simple-server/internal/aac"
"github.com/aler9/rtsp-simple-server/internal/h264"
)
const (
@ -117,8 +117,8 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error { @@ -117,8 +117,8 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error {
dts := m.videoDTSEst.Feed(pts-m.startPTS) + pcrOffset
pts = pts - m.startPTS + pcrOffset
// prepend an AUD. This is required by video.js and iOS
filteredNALUs := [][]byte{
// prepend an AUD. This is required by video.js and iOS
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
}
@ -130,7 +130,7 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error { @@ -130,7 +130,7 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error {
continue
}
// add SPS and PPS before IDR
// add SPS and PPS before every IDR
if typ == h264.NALUTypeIDR {
filteredNALUs = append(filteredNALUs, m.h264Conf.SPS)
filteredNALUs = append(filteredNALUs, m.h264Conf.PPS)

4
internal/hls/muxer_ts_segment.go

@ -110,7 +110,7 @@ func (t *muxerTSSegment) writeH264( @@ -110,7 +110,7 @@ func (t *muxerTSSegment) writeH264(
PES: &astits.PESData{
Header: &astits.PESHeader{
OptionalHeader: oh,
StreamID: 224, // = video
StreamID: 224, // video
},
Data: enc,
},
@ -162,7 +162,7 @@ func (t *muxerTSSegment) writeAAC( @@ -162,7 +162,7 @@ func (t *muxerTSSegment) writeAAC(
PTS: &astits.ClockReference{Base: int64(pts.Seconds() * 90000)},
},
PacketLength: uint16(len(enc) + 8),
StreamID: 192, // = audio
StreamID: 192, // audio
},
Data: enc,
},

Loading…
Cancel
Save