[FFmpeg-user] RTSP to HLS
Thomas Schmiedl
thomas.schmiedl at web.de
Sat Nov 14 02:35:50 EET 2020
Hello,
I try to local restream https://herberts.meinekameras.de:10169
(rtsp-over-websocket) with this workflow: Go-script (proxy websocket to
rtsp) -> ffmpeg (rtsp to hls) -> xupnpd2 mediaserver -> vlc or TV.
It works good in vlc, but on the TV it plays too fast and there are
pauses. I tested all 4 hls-handlers (hls, hls2, hls3, hls4) in xupnpd2
with the same result.
ffmpeg command:
ffmpeg -re -rtsp_transport tcp -i
"rtsp://localhost:8554/axis-media/media.amp?overview=0&camera=1&resolution=1280x720&videoframeskipmode=empty&Axis-Orig-Sw=true&fps=15"
-c copy -f hls /home/user/lighttpd-install/htdocs/stream.m3u8
Hope that someone could test the workflow and maybe optimize the
ffmpeg-command.
Thanks,
Thomas
PS: I never had this issue in xupnpd2 when receiving hls-streams
directly from the internet.
-------------- next part --------------
package main
import (
"net"
"fmt"
"crypto/tls"
"net/http"
"github.com/gorilla/websocket"
)
func handleConn(tcpConn net.Conn) {
d := websocket.Dialer{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
wsConn, _, err := d.Dial("wss://herberts.meinekameras.de:10169/rtsp-over-websocket", http.Header{
"Sec-WebSocket-Protocol": []string{"binary"},
})
if err != nil {
panic(err)
}
go func() {
defer tcpConn.Close()
buf := make([]byte, 10 * 1024)
for {
n, err := tcpConn.Read(buf)
if err != nil {
return
}
wsConn.WriteMessage(websocket.BinaryMessage, buf[:n])
}
}()
go func() {
defer wsConn.Close()
for {
_, buf, err := wsConn.ReadMessage()
if err != nil {
return
}
tcpConn.Write(buf)
}
}()
}
func main() {
l, err := net.Listen("tcp", ":8554")
if err != nil {
panic(err)
}
fmt.Println("ready")
for {
tcpConn, err := l.Accept()
if err != nil {
panic(err)
}
go handleConn(tcpConn)
}
}
More information about the ffmpeg-user
mailing list