From aac1d92a9e6ac3a9d5c94bd9ba4e9c1fe502b583 Mon Sep 17 00:00:00 2001 From: Sergey Petrov Date: Mon, 7 Apr 2025 15:37:22 +0500 Subject: [PATCH] Back muxer to the basic version. --- reader/internal/processor/h264-aac_muxer.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/reader/internal/processor/h264-aac_muxer.go b/reader/internal/processor/h264-aac_muxer.go index 59f9aa2..175f494 100644 --- a/reader/internal/processor/h264-aac_muxer.go +++ b/reader/internal/processor/h264-aac_muxer.go @@ -31,9 +31,6 @@ type MpegTSMuxer struct { H264Format *format.H264 Mpeg4AudioFormat *format.MPEG4Audio - idrFrame [][]byte - idrChecker bool - f *os.File b *bufio.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.idrChecker = false - return nil } @@ -104,7 +99,6 @@ func (e *MpegTSMuxer) WriteH264(pts int64, au [][]byte) error { case h264.NALUTypeIDR: idrPresent = true j++ - e.idrFrame = append([][]byte{e.H264Format.SPS, e.H264Format.PPS}, nalu) case h264.NALUTypeNonIDR: nonIDRPresent = true @@ -117,20 +111,14 @@ func (e *MpegTSMuxer) WriteH264(pts int64, au [][]byte) error { au = filteredAU - if !e.idrChecker { - au = append(e.idrFrame, au...) - e.idrChecker = true - //mux.frameChecker = true - } - - if au == nil || ((!nonIDRPresent && !idrPresent) && e.idrFrame == nil) { + if au == nil || (!nonIDRPresent && !idrPresent) { return nil } // Add SPS and PPS before access unit that contains an IDR. - //if idrPresent { - // au = append([][]byte{e.H264Format.SPS, e.H264Format.PPS}, au...) - //} + if idrPresent { + au = append([][]byte{e.H264Format.SPS, e.H264Format.PPS}, au...) + } if e.dtsExtractor == nil { // Skip samples silently until we find one with an IDR.