From b1fd9a0109ccfac61fc27f9bd372ea98fab4cad0 Mon Sep 17 00:00:00 2001 From: hexbabe Date: Fri, 7 Feb 2025 11:35:48 -0500 Subject: [PATCH 1/2] Make configurable --- pkg/format/mpeg4_video.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/format/mpeg4_video.go b/pkg/format/mpeg4_video.go index 9874220c..1b74ddff 100644 --- a/pkg/format/mpeg4_video.go +++ b/pkg/format/mpeg4_video.go @@ -17,6 +17,7 @@ import ( // Specification: https://datatracker.ietf.org/doc/html/rfc6416#section-7.1 type MPEG4Video struct { PayloadTyp uint8 + SampleRate int ProfileLevelID int Config []byte @@ -61,7 +62,7 @@ func (f *MPEG4Video) Codec() string { // ClockRate implements Format. func (f *MPEG4Video) ClockRate() int { - return 90000 + return f.SampleRate } // PayloadType implements Format. @@ -71,7 +72,7 @@ func (f *MPEG4Video) PayloadType() uint8 { // RTPMap implements Format. func (f *MPEG4Video) RTPMap() string { - return "MP4V-ES/90000" + return "MP4V-ES/" + strconv.FormatInt(int64(f.SampleRate), 10) } // FMTP implements Format. From 6968b69e65fdd2f508a65134e4aeea30649b4801 Mon Sep 17 00:00:00 2001 From: hexbabe Date: Mon, 10 Feb 2025 11:45:13 -0500 Subject: [PATCH 2/2] Parse and set clock rate in mpeg4 unmarshal --- pkg/format/mpeg4_video.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/format/mpeg4_video.go b/pkg/format/mpeg4_video.go index 1b74ddff..c0176dfe 100644 --- a/pkg/format/mpeg4_video.go +++ b/pkg/format/mpeg4_video.go @@ -28,6 +28,11 @@ func (f *MPEG4Video) unmarshal(ctx *unmarshalContext) error { f.PayloadTyp = ctx.payloadType f.ProfileLevelID = 1 // default value imposed by specification + var err error + if f.SampleRate, err = strconv.Atoi(ctx.clock); err != nil { + return fmt.Errorf("could not parse clock rate: %v", err) + } + for key, val := range ctx.fmtp { switch key { case "profile-level-id":