mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-25 20:41:59 -08:00
rtmp: always send decoder config before IDR frames
This commit is contained in:
parent
2a0dc3b63d
commit
f620484757
1 changed files with 23 additions and 2 deletions
|
|
@ -337,8 +337,6 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
|
||||
// TODO: send H264DecoderConfig instead of NALUs?
|
||||
|
||||
// wait until we receive an IDR
|
||||
if !videoFirstIDRFound {
|
||||
if !h264.IDRPresent(data.h264NALUs) {
|
||||
|
|
@ -350,6 +348,29 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
|
|||
videoDTSEst = h264.NewDTSEstimator()
|
||||
}
|
||||
|
||||
if h264.IDRPresent(data.h264NALUs) {
|
||||
codec := nh264.Codec{
|
||||
SPS: map[int][]byte{
|
||||
0: videoTrack.SPS(),
|
||||
},
|
||||
PPS: map[int][]byte{
|
||||
0: videoTrack.PPS(),
|
||||
},
|
||||
}
|
||||
b := make([]byte, 128)
|
||||
var n int
|
||||
codec.ToConfig(b, &n)
|
||||
b = b[:n]
|
||||
|
||||
err = c.conn.WritePacket(av.Packet{
|
||||
Type: av.H264DecoderConfig,
|
||||
Data: b,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
avcc, err := h264.EncodeAVCC(data.h264NALUs)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue