Back muxer to the basic version.

This commit is contained in:
Сергей Петров 2025-04-07 15:37:22 +05:00
parent 692d80fc3e
commit aac1d92a9e

View File

@ -31,9 +31,6 @@ type MpegTSMuxer struct {
H264Format *format.H264 H264Format *format.H264
Mpeg4AudioFormat *format.MPEG4Audio Mpeg4AudioFormat *format.MPEG4Audio
idrFrame [][]byte
idrChecker bool
f *os.File f *os.File
b *bufio.Writer b *bufio.Writer
w *mpegts.Writer w *mpegts.Writer
@ -64,8 +61,6 @@ func (e *MpegTSMuxer) Initialize() error {
e.w = mpegts.NewWriter(e.b, []*mpegts.Track{e.h264Track, e.mpeg4AudioTrack}) e.w = mpegts.NewWriter(e.b, []*mpegts.Track{e.h264Track, e.mpeg4AudioTrack})
e.idrChecker = false
return nil return nil
} }
@ -104,7 +99,6 @@ func (e *MpegTSMuxer) WriteH264(pts int64, au [][]byte) error {
case h264.NALUTypeIDR: case h264.NALUTypeIDR:
idrPresent = true idrPresent = true
j++ j++
e.idrFrame = append([][]byte{e.H264Format.SPS, e.H264Format.PPS}, nalu)
case h264.NALUTypeNonIDR: case h264.NALUTypeNonIDR:
nonIDRPresent = true nonIDRPresent = true
@ -117,20 +111,14 @@ func (e *MpegTSMuxer) WriteH264(pts int64, au [][]byte) error {
au = filteredAU au = filteredAU
if !e.idrChecker { if au == nil || (!nonIDRPresent && !idrPresent) {
au = append(e.idrFrame, au...)
e.idrChecker = true
//mux.frameChecker = true
}
if au == nil || ((!nonIDRPresent && !idrPresent) && e.idrFrame == nil) {
return nil return nil
} }
// Add SPS and PPS before access unit that contains an IDR. // Add SPS and PPS before access unit that contains an IDR.
//if idrPresent { if idrPresent {
// au = append([][]byte{e.H264Format.SPS, e.H264Format.PPS}, au...) au = append([][]byte{e.H264Format.SPS, e.H264Format.PPS}, au...)
//} }
if e.dtsExtractor == nil { if e.dtsExtractor == nil {
// Skip samples silently until we find one with an IDR. // Skip samples silently until we find one with an IDR.