stream/flv: remove unnecessary header write on creation

This commit is contained in:
Dan Kortschak 2019-01-05 17:56:55 +10:30
parent 250da4232a
commit 05e0672e89
2 changed files with 3 additions and 12 deletions

View File

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

View File

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