Camera streaming

    RTSP: how camera streams work and how to open one

    Almost every IP camera serves its live video over RTSP. Recorders, video management systems, VLC and AI boxes all pull the same stream from the same kind of address. Once the address is right, everything else follows.

    How RTSP works

    The control channel

    The player connects to the camera on TCP port 554 and asks for the stream with DESCRIBE, SETUP and PLAY, then TEARDOWN at the end. That is RTSP itself, defined in RFC 2326 and updated in RFC 7826.

    The video

    The pictures travel over RTP, with RTCP reports alongside. By default RTP uses its own UDP ports; asked for TCP, the camera sends it inside the RTSP connection instead.

    The codec

    Inside RTP the camera sends H.264 or H.265 video, often with AAC or G.711 audio. The player must decode that codec, which is why some H.265 streams play in one app and not another.

    The RTSP address

    rtsp://user:[email protected]:554/path

    • Credentials go before the @. Special characters in the password must be percent-encoded, so @ becomes %40 and # becomes %23.
    • Port 554 can be left out when it is the default. Some cameras and gateways use 8554.
    • Path is different for every brand and picks the channel and the stream. Our RTSP URL formats page lists them for 15 brands and builds the address for you.
    • Main and sub stream. The main stream carries full resolution for recording; the sub stream is small and light for multi-camera views and phones.

    Open an RTSP stream in VLC

    1. In VLC, open Media, then Open Network Stream (Ctrl+N, or File, Open Network on a Mac).
    2. Paste the address, for example rtsp://admin:[email protected]:554/Streaming/Channels/101.
    3. Press Play. If the picture stutters, tick Show more options and raise Caching to 1000 ms.
    4. If it never starts behind a router or VPN, set Preferences, Input / Codecs, Live555 stream transport to RTP over RTSP (TCP).

    With ffmpeg

    Play over TCP:

    ffplay -rtsp_transport tcp "rtsp://user:[email protected]:554/path"

    Save a minute without re-encoding:

    ffmpeg -rtsp_transport tcp -i "rtsp://user:[email protected]:554/path" -c copy -t 60 clip.mp4

    When the stream does not play

    • 401 Unauthorized. Wrong user or password, or an unencoded special character in it.
    • 404 Not Found. The path is wrong for this brand or firmware; check the formats page or read the address from ONVIF Device Manager.
    • Connects, then nothing. A firewall, router or VPN drops the UDP video. Ask for TCP: the VLC setting above, or -rtsp_transport tcp. More in RTSP ports 554, 8554 and 322.
    • Sound but no picture. The player cannot decode the codec, usually H.265. Switch that stream to H.264 or use a player with HEVC support.
    • Works for one viewer only. Cameras allow a limited number of RTSP sessions. Let the recorder pull once and serve everyone else.

    RTSP in a browser

    Browsers do not speak RTSP. A gateway such as MediaMTX or go2rtc pulls the camera stream and serves it to the page over WebRTC, with a delay well under a second, or over HLS when a few seconds do not matter.

    RTSP and ONVIF

    RTSP carries the video; ONVIF finds and configures the camera and tells the recorder which RTSP address to pull. See ONVIF profiles explained.

    Plan the streams before the install

    Every stream costs bandwidth on the network and space on the recorder. CCTVplanner works out both for each camera from its resolution, codec and frame rate. See the bandwidth calculator and CBR vs VBR.

    RTSP questions

    What is RTSP?

    The Real Time Streaming Protocol, defined in RFC 2326 and updated as RTSP 2.0 in RFC 7826. It sets up and controls a stream from a camera, while the video itself travels over RTP, either over UDP or inside the RTSP connection over TCP.

    What port does RTSP use?

    TCP 554 by default, 8554 as a common alternative, and 322 for RTSP over TLS. The RTP video then uses its own UDP ports unless the client asks for TCP.

    How do I open an RTSP stream in VLC?

    Media, Open Network Stream, paste the rtsp:// address and press Play. Behind a router or VPN, switch Live555 stream transport to RTP over RTSP (TCP) in the preferences.

    Can a web browser play RTSP?

    No. Browsers do not speak RTSP, so a gateway such as MediaMTX or go2rtc pulls the stream and serves it to the browser over WebRTC or HLS.

    What is the difference between RTSP and RTMP?

    A recorder or player pulls RTSP from the camera. RTMP is pushed by an encoder to a streaming server, which is how cameras send live video to YouTube and similar platforms.