flv: fixed NewEncoder so that we still create encoder even if the HeaderByte write fails

This commit is contained in:
saxon 2019-01-11 18:09:32 +10:30
parent 83f5e9e68d
commit b63c55ae48
2 changed files with 1 additions and 4 deletions

View File

@ -185,7 +185,7 @@ func TestFromFrame(t *testing.T) {
const frameRate = 25 const frameRate = 25
flvEncoder, err := flv.NewEncoder(s, true, true, frameRate) 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) t.Errorf("Failed to create flv encoder with error: %v", err)
} }
err = lex.H264(flvEncoder, bytes.NewReader(videoData), time.Second/time.Duration(frameRate)) err = lex.H264(flvEncoder, bytes.NewReader(videoData), time.Second/time.Duration(frameRate))

View File

@ -73,9 +73,6 @@ func NewEncoder(dst io.Writer, audio, video bool, fps int) (*Encoder, error) {
video: video, video: video,
} }
_, err := dst.Write(e.HeaderBytes()) _, err := dst.Write(e.HeaderBytes())
if err != nil {
return nil, err
}
return &e, err return &e, err
} }