diff --git a/revid/revid.go b/revid/revid.go index c74e1a3d..1345e191 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -188,9 +188,11 @@ func (r *Revid) reset(config Config) error { // to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the // output requires FLV encoding. var sender loadSender + var retry bool for _, out := range r.config.Outputs { switch out { case Http: + retry = true sender = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil) case Rtp: sender, err = newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate) @@ -214,7 +216,10 @@ func (r *Revid) reset(config Config) error { // encoder to revid's encoder slice, and give this encoder the mtsSenders // as a destination. if len(mtsSenders) != 0 { - ms := newMultiSender(r, mtsSenders) + if len(mtsSenders) != 1 && len(flvSenders) != 0 { + retry = false + } + ms := newMultiSender(r, mtsSenders, retry) e := mts.NewEncoder(ms, float64(r.config.FrameRate)) r.encoder = append(r.encoder, e) } @@ -223,7 +228,7 @@ func (r *Revid) reset(config Config) error { // encoder to revid's encoder slice, and give this encoder the flvSenders // as a destination. if len(flvSenders) != 0 { - ms := newMultiSender(r, flvSenders) + ms := newMultiSender(r, flvSenders, false) e, err := flv.NewEncoder(ms, true, true, int(r.config.FrameRate)) if err != nil { return err diff --git a/revid/senders.go b/revid/senders.go index 4a96ad2f..7c2ed9b1 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -61,8 +61,8 @@ type multiSender struct { } // newMultiSender returns a pointer to a new multiSender. -func newMultiSender(owner *Revid, senders []loadSender) *multiSender { - return &multiSender{owner: owner, senders: senders} +func newMultiSender(owner *Revid, senders []loadSender, retry bool) *multiSender { + return &multiSender{owner: owner, senders: senders, retry: retry} } // Write implements io.Writer. The written slice will be sent to each loadSender