From b63c55ae48ef46962ed16f17b72aeadd345fbccb Mon Sep 17 00:00:00 2001 From: saxon Date: Fri, 11 Jan 2019 18:09:32 +1030 Subject: [PATCH] flv: fixed NewEncoder so that we still create encoder even if the HeaderByte write fails --- rtmp/rtmp_test.go | 2 +- stream/flv/encoder.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/rtmp/rtmp_test.go b/rtmp/rtmp_test.go index 6585c96f..3efbdec8 100644 --- a/rtmp/rtmp_test.go +++ b/rtmp/rtmp_test.go @@ -185,7 +185,7 @@ func TestFromFrame(t *testing.T) { const frameRate = 25 flvEncoder, err := flv.NewEncoder(s, true, true, frameRate) - if err != nil { + if err != nil && err != errTinyPacket { t.Errorf("Failed to create flv encoder with error: %v", err) } err = lex.H264(flvEncoder, bytes.NewReader(videoData), time.Second/time.Duration(frameRate)) diff --git a/stream/flv/encoder.go b/stream/flv/encoder.go index 46d0eacb..4772a151 100644 --- a/stream/flv/encoder.go +++ b/stream/flv/encoder.go @@ -73,9 +73,6 @@ func NewEncoder(dst io.Writer, audio, video bool, fps int) (*Encoder, error) { video: video, } _, err := dst.Write(e.HeaderBytes()) - if err != nil { - return nil, err - } return &e, err }