simplify examples (#389)

This commit is contained in:
Alessandro Ros
2023-08-30 11:23:37 +02:00
committed by GitHub
parent ddec738950
commit fc0c242789
2 changed files with 22 additions and 40 deletions

View File

@@ -18,12 +18,11 @@ type mpegtsMuxer struct {
sps []byte
pps []byte
f *os.File
b *bufio.Writer
w *mpegts.Writer
track *mpegts.Track
dtsExtractor *h264.DTSExtractor
firstIDRReceived bool
f *os.File
b *bufio.Writer
w *mpegts.Writer
track *mpegts.Track
dtsExtractor *h264.DTSExtractor
}
// newMPEGTSMuxer allocates a mpegtsMuxer.
@@ -103,26 +102,18 @@ func (e *mpegtsMuxer) encode(au [][]byte, pts time.Duration) error {
var dts time.Duration
if !e.firstIDRReceived {
if e.dtsExtractor == nil {
// skip samples silently until we find one with a IDR
if !idrPresent {
return nil
}
e.firstIDRReceived = true
e.dtsExtractor = h264.NewDTSExtractor()
}
var err error
dts, err = e.dtsExtractor.Extract(au, pts)
if err != nil {
return err
}
} else {
var err error
dts, err = e.dtsExtractor.Extract(au, pts)
if err != nil {
return err
}
var err error
dts, err = e.dtsExtractor.Extract(au, pts)
if err != nil {
return err
}
// encode into MPEG-TS