AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.49k stars 361 forks source link

How to control RTSP source #1191

Open dnjooiopa opened 3 months ago

dnjooiopa commented 3 months ago

Can anyone suggest a method to control an RTSP source, such as sending a PLAY command with a Scale header or sending a PAUSE command?

AlexxIT commented 3 months ago

This is out of design. It's easier just to break RTSP connection and create new one after pause.

dnjooiopa commented 3 months ago

This is out of design. It's easier just to break RTSP connection and create new one after pause.

I attempted to add a PlayWithScale method in pkg/rtsp/client.go and called this method instead of Play, but the stream from the source doesn’t play at scale*X speed. I’m not sure if I’m approaching this correctly.

func (c *Conn) PlayWithScale(scale float64) (err error) {
    req := &tcp.Request{
        Method: MethodPlay,
        URL:    c.URL,
        Header: map[string][]string{
            "Scale": {fmt.Sprintf("%.3f", scale)},
        },
    }
    return c.WriteRequest(req)
}

ref: https://www.rfc-editor.org/rfc/rfc2326.html#section-12.34

AlexxIT commented 3 months ago

This is also out of design. Go2rtc about real time. Scale is not about real time.