[FFmpeg-user] RTSP to HLS

Thomas Schmiedl thomas.schmiedl at web.de
Tue Nov 17 22:53:06 EET 2020


Hello again,

maybe someone could help a ffmpeg-newbie to get the correct hls-settings
(hope there is something possible without re-encoding). The GOP is
IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 31 CLOSED (got it from this script
https://gist.github.com/ragnraok/638023456771dc596e6f953b47061f0e).

Thanks,
Thomas

Am 14.11.2020 um 01:35 schrieb Thomas Schmiedl:
> 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.
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- 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