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
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.