diff --git a/cmd/ffmpeg/README.md b/cmd/ffmpeg/README.md index 028439e0..6d19340d 100644 --- a/cmd/ffmpeg/README.md +++ b/cmd/ffmpeg/README.md @@ -1,3 +1,17 @@ +## FFplay output + +[FFplay](https://stackoverflow.com/questions/27778678/what-are-mv-fd-aq-vq-sq-and-f-in-a-video-stream) `7.11 A-V: 0.003 fd= 1 aq= 21KB vq= 321KB sq= 0B f=0/0`: + +- `7.11` - master clock, is the time from start of the stream/video +- `A-V` - av_diff, difference between audio and video timestamps +- `fd` - frames dropped +- `aq` - audio queue (0 - no delay) +- `vq` - video queue (0 - no delay) +- `sq` - subtitle queue +- `f` - timestamp error correction rate (Not 100% sure) + +`M-V`, `M-A` means video stream only, audio stream only respectively. + ## Devices Windows ``` diff --git a/pkg/homekit/client.go b/pkg/homekit/client.go index 67b3a26b..195bbf9a 100644 --- a/pkg/homekit/client.go +++ b/pkg/homekit/client.go @@ -163,7 +163,7 @@ func (c *Client) Start() error { switch track.Codec.Name { case streamer.CodecH264: vs.Track = track - case streamer.CodecAAC: + case streamer.CodecELD: as.Track = track } } @@ -233,14 +233,6 @@ func (c *Client) getMedias() []*streamer.Media { Channels: uint16(hkCodec.Parameters.Channels), } - switch hkCodec.Type { - case rtp.AudioCodecType_AAC_ELD: - codec.Name = streamer.CodecAAC - default: - fmt.Printf("unknown codec: %d", hkCodec.Type) - continue - } - switch hkCodec.Parameters.Samplerate { case rtp.AudioCodecSampleRate8Khz: codec.ClockRate = 8000 @@ -252,6 +244,16 @@ func (c *Client) getMedias() []*streamer.Media { panic(fmt.Sprintf("unknown clockrate: %d", hkCodec.Parameters.Samplerate)) } + switch hkCodec.Type { + case rtp.AudioCodecType_AAC_ELD: + codec.Name = streamer.CodecELD + // only this value supported by FFmpeg + codec.FmtpLine = "profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=F8EC3000" + default: + fmt.Printf("unknown codec: %d", hkCodec.Type) + continue + } + media := &streamer.Media{ Kind: streamer.KindAudio, Direction: streamer.DirectionSendonly, Codecs: []*streamer.Codec{codec}, diff --git a/pkg/streamer/media.go b/pkg/streamer/media.go index c7dd30c3..a737ebef 100644 --- a/pkg/streamer/media.go +++ b/pkg/streamer/media.go @@ -33,6 +33,8 @@ const ( CodecOpus = "OPUS" // payloadType: 111 CodecG722 = "G722" CodecMPA = "MPA" // payload: 14 + + CodecELD = "ELD" // AAC-ELD ) const PayloadTypeMP4 byte = 255 @@ -41,7 +43,7 @@ func GetKind(name string) string { switch name { case CodecH264, CodecH265, CodecVP8, CodecVP9, CodecAV1, CodecJPEG: return KindVideo - case CodecPCMU, CodecPCMA, CodecAAC, CodecOpus, CodecG722, CodecMPA: + case CodecPCMU, CodecPCMA, CodecAAC, CodecOpus, CodecG722, CodecMPA, CodecELD: return KindAudio } return "" @@ -187,13 +189,19 @@ func MarshalSDP(medias []*Media) ([]byte, error) { } codec := media.Codecs[0] + + name := codec.Name + if name == CodecELD { + name = CodecAAC + } + md := &sdp.MediaDescription{ MediaName: sdp.MediaName{ Media: media.Kind, Protos: []string{"RTP", "AVP"}, }, } - md.WithCodec(payloadType, codec.Name, codec.ClockRate, codec.Channels, codec.FmtpLine) + md.WithCodec(payloadType, name, codec.ClockRate, codec.Channels, codec.FmtpLine) sd.MediaDescriptions = append(sd.MediaDescriptions, md)