You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
joy4/examples/rtmp_server_proxy/main.go

31 lines
618 B
Go

package main
import (
"fmt"
"strings"
"gitlab.com/ics_cinnamon/joy4/av/avutil"
"gitlab.com/ics_cinnamon/joy4/format"
"gitlab.com/ics_cinnamon/joy4/format/rtmp"
)
func init() {
format.RegisterAll()
}
func main() {
server := &rtmp.Server{}
server.HandlePlay = func(conn *rtmp.Conn) {
segs := strings.Split(conn.URL.Path, "/")
url := fmt.Sprintf("%s://%s", segs[1], strings.Join(segs[2:], "/"))
src, _ := avutil.Open(url)
avutil.CopyFile(conn, src)
}
server.ListenAndServe()
// ffplay rtmp://localhost/rtsp/192.168.1.1/camera1
// ffplay rtmp://localhost/rtmp/live.hkstv.hk.lxdns.com/live/hks
}