x264: output headers at start
Some checks are pending
continuous-integration/drone/push Build is running
Some checks are pending
continuous-integration/drone/push Build is running
This commit is contained in:
parent
8a77f16435
commit
def693a23c
|
@ -193,6 +193,10 @@ func NewEncoder(w io.Writer, properties frame.StreamProperties, settings map[str
|
|||
return nil, errors.New("error opening encoder")
|
||||
}
|
||||
|
||||
if err := e.encoderHeaders(); err != nil {
|
||||
return e, err
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
|
@ -230,6 +234,36 @@ func (e *Encoder) Encode(f frame.Frame) error {
|
|||
return e.encoderEncode(e.pictureIn)
|
||||
}
|
||||
|
||||
func (e *Encoder) encoderHeaders() error {
|
||||
if e.params.b_repeat_headers > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var nal *C.x264_nal_t
|
||||
var iNal C.int
|
||||
var frameSize C.int
|
||||
|
||||
if frameSize = C.x264_encoder_headers(e.h, &nal, &iNal); frameSize < 0 {
|
||||
return errors.New("error encoding headers")
|
||||
}
|
||||
|
||||
if frameSize == 0 || iNal == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if iNal != 1 {
|
||||
//return errors.New("more than one NAL present")
|
||||
}
|
||||
|
||||
// All NAL payloads are sequential to each other in memory
|
||||
buf := unsafe.Slice((*byte)(nal.p_payload), int(frameSize))
|
||||
if _, err := e.w.Write(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Encoder) encoderEncode(picture *C.x264_picture_t) error {
|
||||
var nal *C.x264_nal_t
|
||||
var iNal C.int
|
||||
|
|
Loading…
Reference in a new issue