3d0c / gmf

Go Media Framework
MIT License
889 stars 170 forks source link

add fn for Packet and CodecCtx #135

Closed kaisawind closed 3 years ago

kaisawind commented 3 years ago

h264 raw stream to rtmp, so i need SetExtradata to set sps and pps, alse need SetData to set h264 raw data to packet.

We must have extradata to generate AVCDecoderConfigurationRecord.

//sps_pps = []byte{ 0x00, 0x00, 0x01, 0x67, 0x4d, 0x00, 0x1f, 0x9d, 0xa8, 0x14, 0x01, 0x6e, 0x9b, 0x80, 0x80, 0x80, 0x81, 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x3c, 0x80 }
    extradata := pkt.PacketBuffer[:index]
    cc.SetHeight(int(pkt.Height)).
        SetWidth(int(pkt.Width)).
        SetFrameRate(gmf.AVR{
            Num: int(pkt.FrameRate),
            Den: 1,
        }).
        SetPixFmt(gmf.AV_PIX_FMT_YUV420P).
        SetExtradata(extradata)
kaisawind commented 3 years ago

close it for more fixed