From 4bd5289221b1591af608bf6394f31fa414ca6a64 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sun, 30 Jan 2022 11:32:20 +0100 Subject: [PATCH] hls: set audio codec mime according to mpeg4 type --- internal/hls/muxer.go | 2 +- internal/hls/muxer_primary_playlist.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/hls/muxer.go b/internal/hls/muxer.go index 5ae7eb8b..87c9ed45 100644 --- a/internal/hls/muxer.go +++ b/internal/hls/muxer.go @@ -38,7 +38,7 @@ func NewMuxer( } } - primaryPlaylist := newMuxerPrimaryPlaylist(videoTrack, audioTrack, h264Conf) + primaryPlaylist := newMuxerPrimaryPlaylist(videoTrack, audioTrack, h264Conf, aacConf) streamPlaylist := newMuxerStreamPlaylist(hlsSegmentCount) diff --git a/internal/hls/muxer_primary_playlist.go b/internal/hls/muxer_primary_playlist.go index 04f7f2e8..95fb6c85 100644 --- a/internal/hls/muxer_primary_playlist.go +++ b/internal/hls/muxer_primary_playlist.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "io" + "strconv" "strings" "github.com/aler9/gortsplib" @@ -21,6 +22,7 @@ func newMuxerPrimaryPlaylist( videoTrack *gortsplib.Track, audioTrack *gortsplib.Track, h264Conf *gortsplib.TrackConfigH264, + aacConf *gortsplib.TrackConfigAAC, ) *muxerPrimaryPlaylist { p := &muxerPrimaryPlaylist{ videoTrack: videoTrack, @@ -34,8 +36,9 @@ func newMuxerPrimaryPlaylist( codecs = append(codecs, "avc1."+hex.EncodeToString(p.h264Conf.SPS[1:4])) } + // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter if p.audioTrack != nil { - codecs = append(codecs, "mp4a.40.2") + codecs = append(codecs, "mp4a.40."+strconv.FormatInt(int64(aacConf.Type), 10)) } p.cnt = []byte("#EXTM3U\n" +