diff --git a/stream/flv/encoder.go b/stream/flv/encoder.go index c9281873..21562f98 100644 --- a/stream/flv/encoder.go +++ b/stream/flv/encoder.go @@ -57,11 +57,10 @@ var ( type Encoder struct { dst io.Writer - fps int - audio bool - video bool - header Header - start time.Time + fps int + audio bool + video bool + start time.Time } // NewEncoder retuns a new FLV encoder. @@ -72,20 +71,7 @@ func NewEncoder(dst io.Writer, audio, video bool, fps int) (*Encoder, error) { audio: audio, video: video, } - _, err := dst.Write(e.HeaderBytes()) - if err != nil { - return nil, err - } - return &e, err -} - -// HeaderBytes returns the a -func (e *Encoder) HeaderBytes() []byte { - header := Header{ - HasAudio: e.audio, - HasVideo: e.video, - } - return header.Bytes() + return &e, nil } // getNextTimestamp generates and returns the next timestamp based on current time diff --git a/stream/flv/flv.go b/stream/flv/flv.go index 293b89f8..8ae7e050 100644 --- a/stream/flv/flv.go +++ b/stream/flv/flv.go @@ -71,25 +71,6 @@ func orderPutUint24(b []byte, v uint32) { b[2] = byte(v) } -var flvHeaderCode = []byte{'F', 'L', 'V', version} - -type Header struct { - HasAudio bool - HasVideo bool -} - -func (h *Header) Bytes() []byte { - // See https://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf - // section E.2. - const headerLength = 9 - b := [headerLength]byte{ - 0: 'F', 1: 'L', 2: 'V', 3: version, - 4: btb(h.HasAudio)<<2 | btb(h.HasVideo), - 8: headerLength, // order.PutUint32(b[5:9], headerLength) - } - return b[:] -} - type VideoTag struct { TagType uint8 DataSize uint32