deepch / RTSPtoWebRTC

RTSP to WebRTC use Pion WebRTC
MIT License
1.58k stars 419 forks source link

Help pls RTSPtoWebRTC found error WriteHeader unable to start track, codec is not supported by remote but do receive sdp and support H264(update log) #234

Open yuchinchenTW opened 4 months ago

yuchinchenTW commented 4 months ago

our environment:

Yocto kirkstone

Chromium 120.0.6099.224 stable

go version go1.20.14 linux/arm64

has tried rtsp with 
gst-play-1.0 rtsp://admin:0000@192.168.120.7/live/h264 and the view we want has shown this proven our device support h264

when running RTSPtoWebRTC

we found out that the camera view did not comes appeared

here is how we debug:

in the http.go we add log to print

func HTTPAPIServerStreamWebRTC(c *gin.Context) {
        if !Config.ext(c.PostForm("suuid")) {
                log.Println("Stream Not Found")
                return
        }
        Config.RunIFNotRun(c.PostForm("suuid"))
        codecs := Config.coGe(c.PostForm("suuid"))
        if codecs == nil {
                log.Println("Stream Codec Not Found")
                return
        }
log.Println("Codecs:", codecs)
        var AudioOnly bool
        if len(codecs) == 1 && codecs[0].Type().IsAudio() {
                AudioOnly = true
        }
        muxerWebRTC := webrtc.NewMuxer(webrtc.Options{ICEServers: Config.GetICEServers(), ICEUsername: Config.GetICEUsername(), ICECredential: Config.GetICECredential(), PortMin: Config.GetWebRTC>

        sdp := c.PostForm("data")
if sdp == "" {
    log.Println("Error: No SDP data provided")

}

        log.Println("Received SDP data:", sdp)

log.Println("Codec  Supported WebRTC :", codecs[0].Type())

        answer, err := muxerWebRTC.WriteHeader(codecs, c.PostForm("data"))
        if err != nil {
                log.Println("error happened no answer")
                log.Println("WriteHeader", err)
                return
        }

        log.Println("")
        log.Println("Generated SDP answer:", answer)

turns out that

2024/06/24 06:01:02 Codecs: [{[1 66 0 40 255 225 0 22 103 66 0 40 233 0 160 4 13 113 32 1 183 116 0 51 127 152 3 98 4 37 1 0 4 104 206 49 82] {66 0 40 3 [[103 66 0 40 233 0 160 4 13 113 32 1 183 116 0 51 127 152 3 98 4 37]] [[104 206 49 82]]} {0 66 40 0 80 64 0 0 0 0 1280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IG5hY2sgcGxpDQphPXJ0cG1hcDo0MCBydHgvOTAwMDANCmE9Zm10cDo0MCBhcHQ9MzkNCmE9cnRwbWFwOjk4IFZQOS85MDAwMA0KYT1ydGNwLWZiOjk4IGdvb2ctcmVtYg0KYT1ydGNwLWZiOjk4IHRyYW5zcG9ydC1jYw0KYT1ydGNwLWZiOjk4IGNjbSBmaXINCmE9cnRjcC1mYjo5OCBuYWNrDQphPXJ0Y3AtZmI6OTggbmFjayBwbGkNCmE9Zm10cDo5OCBwcm9maWxlLWlkPTANCmE9cnRwbWFwOjk5IHJ0eC85MDAwMA0KYT1mbXRwOjk5IGFwdD05OA0KYT1ydHBtYXA6MTAwIHJlZC85MDAwMA0KYT1ydHBtYXA6MTAxIHJ0eC85MDAwMA0KYT1mbXRwOjEwMSBhcHQ9MTAwDQphPXJ0cG1hcDoxMDIgdWxwZmVjLzkwMDAwDQphPXNzcmMtZ3JvdXA6RklEIDMyNDA4MTQ5NzIgMTI1Mjc3MjMyNA0KYT1zc3JjOjMyNDA4MTQ5NzIgY25hbWU6cHMrN08rUXlZMytQOXphTA0KYT1zc3JjOjMyNDA4MTQ5NzIgbXNpZDotIDU3YjE5YmY1LWY0ZmYtNDcwNS1iM2Y2LWQ5OGYwYTQ0MWYxZQ0KYT1zc3JjOjEyNTI3NzIzMjQgY25hbWU6cHMrN08rUXlZMytQOXphTA0KYT1zc3JjOjEyNTI3NzIzMjQgbXNpZDotIDU3YjE5YmY1LWY0ZmYtNDcwNS1iM2Y2LWQ5OGYwYTQ0MWYxZQ0K
2024/06/24 06:01:02 Codec  Supported WebRTC : H264
2024/06/24 06:01:02 Set ICEServers [stun:stun.l.google.com:19302]
2024/06/24 06:01:02 error happened no answer
2024/06/24 06:01:02 WriteHeader unable to start track, codec is not supported by remote

it seems like its does receive sdp but somehow stuck on answer, err := muxerWebRTC.WriteHeader(codecs, c.PostForm("data"))

does anyone know why?

yuchinchenTW commented 4 months ago

nvm i just answer myself due to https://github.com/chromiumembedded/cef/issues/3559

proprietary_codecs=true
ffmpeg_branding="Chrome"

it seems like the chromium browser does not include codec need to add flag and rebuild for H264