mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-29 22:42:00 -08:00
HLS muxer: support dynamic H264 SPS/PPS
This commit is contained in:
parent
57cb2e99d1
commit
37e22b96cd
2 changed files with 0 additions and 22 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package hls
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
|
|
@ -23,12 +22,6 @@ func NewMuxer(
|
|||
videoTrack *gortsplib.TrackH264,
|
||||
audioTrack *gortsplib.TrackAAC,
|
||||
) (*Muxer, error) {
|
||||
if videoTrack != nil {
|
||||
if videoTrack.SPS() == nil || videoTrack.PPS() == nil {
|
||||
return nil, fmt.Errorf("invalid H264 track: SPS or PPS not provided into the SDP")
|
||||
}
|
||||
}
|
||||
|
||||
primaryPlaylist := newMuxerPrimaryPlaylist(videoTrack, audioTrack)
|
||||
|
||||
streamPlaylist := newMuxerStreamPlaylist(hlsSegmentCount)
|
||||
|
|
|
|||
|
|
@ -119,21 +119,6 @@ func (m *muxerTSGenerator) writeH264(pts time.Duration, nalus [][]byte) error {
|
|||
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
|
||||
}
|
||||
|
||||
for _, nalu := range nalus {
|
||||
typ := h264.NALUType(nalu[0] & 0x1F)
|
||||
switch typ {
|
||||
case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter:
|
||||
// remove existing SPS, PPS, AUD
|
||||
continue
|
||||
|
||||
case h264.NALUTypeIDR:
|
||||
// add SPS and PPS before every IDR
|
||||
filteredNALUs = append(filteredNALUs, m.videoTrack.SPS(), m.videoTrack.PPS())
|
||||
}
|
||||
|
||||
filteredNALUs = append(filteredNALUs, nalu)
|
||||
}
|
||||
|
||||
enc, err := h264.EncodeAnnexB(filteredNALUs)
|
||||
if err != nil {
|
||||
if m.currentSegment.buf.Len() > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue