diff --git a/codec/h265/lex.go b/codec/h265/lex.go index d67cf289..f5afa5e6 100644 --- a/codec/h265/lex.go +++ b/codec/h265/lex.go @@ -76,6 +76,7 @@ func (l *Lexer) Lex(dst io.Writer, src io.Reader, delay time.Duration) error { switch err { case nil: // Do nothing. case io.EOF: + fmt.Println("done") return nil default: return fmt.Errorf("source read error: %v\n", err) @@ -150,6 +151,11 @@ func (l *Lexer) handleFragmentation(d []byte) { start := d[2]&0x80 != 0 end := d[2]&0x40 != 0 + var head []byte + if start { + head = []byte{(d[0] & 0x81) | ((d[2] & 0x3f) << 1), d[1]} + } + d = d[3:] if l.donl { d = d[2:] @@ -158,7 +164,8 @@ func (l *Lexer) handleFragmentation(d []byte) { switch { case start && !end: l.frag = true - l.writeWithPrefix(d) + _d := append(head, d...) + l.writeWithPrefix(_d) case !start && end: l.frag = false fallthrough