Update processing HTTP-FLV without video or audio

This commit is contained in:
Alexey Khit
2023-01-24 17:47:26 +03:00
parent 94b089d1e3
commit d2bca8d461
+6 -2
View File
@@ -128,8 +128,10 @@ func (c *Conn) Streams() ([]av.CodecData, error) {
return []av.CodecData{video, audio}, nil return []av.CodecData{video, audio}, nil
} else if video != nil { } else if video != nil {
c.videoIdx = 0 c.videoIdx = 0
c.audioIdx = -1
return []av.CodecData{video}, nil return []av.CodecData{video}, nil
} else if audio != nil { } else if audio != nil {
c.videoIdx = -1
c.audioIdx = 0 c.audioIdx = 0
return []av.CodecData{audio}, nil return []av.CodecData{audio}, nil
} }
@@ -146,10 +148,12 @@ func (c *Conn) ReadPacket() (av.Packet, error) {
switch tag.Type { switch tag.Type {
case flvio.TAG_VIDEO: case flvio.TAG_VIDEO:
if tag.AVCPacketType != flvio.AVC_NALU { if c.videoIdx < 0 || tag.AVCPacketType != flvio.AVC_NALU {
continue continue
} }
//log.Printf("[FLV] %v, len: %d, ts: %10d", h264.Types(tag.Data), len(tag.Data), flvio.TsToTime(ts))
return av.Packet{ return av.Packet{
Idx: c.videoIdx, Idx: c.videoIdx,
Data: tag.Data, Data: tag.Data,
@@ -159,7 +163,7 @@ func (c *Conn) ReadPacket() (av.Packet, error) {
}, nil }, nil
case flvio.TAG_AUDIO: case flvio.TAG_AUDIO:
if tag.SoundFormat != flvio.SOUND_AAC || tag.AACPacketType != flvio.AAC_RAW { if c.audioIdx < 0 || tag.SoundFormat != flvio.SOUND_AAC || tag.AACPacketType != flvio.AAC_RAW {
continue continue
} }