From 05e0672e8972d89c30697abca19dad21c5dcece2 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Sat, 5 Jan 2019 17:56:55 +1030 Subject: [PATCH] stream/flv: remove unnecessary header write on creation --- revid/revid.go | 5 +---- stream/flv/encoder.go | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index 62e22d64..51a14c91 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -292,10 +292,7 @@ func (r *Revid) reset(config Config) error { r.encoder = mts.NewEncoder(&r.packer, float64(r.config.FrameRate)) case Flv: r.config.Logger.Log(logger.Info, pkg+"using FLV packetisation") - r.encoder, err = flv.NewEncoder(&r.packer, true, true, int(r.config.FrameRate)) - if err != nil { - return err - } + r.encoder = flv.NewEncoder(&r.packer, true, true, int(r.config.FrameRate)) } return nil diff --git a/stream/flv/encoder.go b/stream/flv/encoder.go index e15552df..cb663fe6 100644 --- a/stream/flv/encoder.go +++ b/stream/flv/encoder.go @@ -66,19 +66,13 @@ type Encoder struct { } // NewEncoder retuns a new FLV encoder. -func NewEncoder(dst io.Writer, audio, video bool, fps int) (*Encoder, error) { - e := Encoder{ +func NewEncoder(dst io.Writer, audio, video bool, fps int) *Encoder { + return &Encoder{ dst: dst, fps: fps, audio: audio, video: video, } - // TODO(kortschak): Do this lazily. - _, err := e.dst.Write(e.HeaderBytes()) - if err != nil { - return nil, err - } - return &e, nil } // HeaderBytes returns the a