Convert RTSP to RTMP Stream

A complete guide to relay RTSP streams to RTMP destinations like YouTube, Facebook, or your own server using Happytime RTMP Pusher.

Why Convert RTSP to RTMP?

RTSP (Real Time Streaming Protocol) is commonly used by IP cameras and NVRs for low-latency streaming. However, popular live streaming platforms (YouTube Live, Facebook Live, Twitch) and many media servers (Wowza, nginx-rtmp) use RTMP (Real-Time Messaging Protocol) as their ingest protocol.

Converting RTSP to RTMP allows you to:

  • Push camera feeds to live streaming platforms (YouTube, Facebook, etc.)
  • Relay streams to your own RTMP server for further processing or distribution.
  • Transcode streams to different resolutions or bitrates if needed.
  • Integrate surveillance systems with broader broadcast networks.

This guide shows you how to use Happytime RTMP Pusher to achieve this conversion seamlessly.

Configuration Overview

Configure the RTMP Pusher by editing the rtmppusher.cfg file. Each <pusher> node defines a single stream relay.

Basic Pusher Node

rtmppusher.cfg
<pusher>
    <srcurl>rtsp://192.168.1.3/live</srcurl>
    <dsturl>rtmp://192.168.1.102/myapp/mystream1</dsturl>
    <user>admin</user>
    <pass>admin</pass>
</pusher>

Detailed Configuration Parameters

1. Source Stream (<srcurl>)

Defines the input stream source. Supports various types:

Source Type Description
rtsp://... RTSP stream address (e.g., from an IP camera)
filename Local media file (must be in the same directory)
screenlive Stream your computer's screen
videodevice Stream from a camera (use videodevice0, videodevice1 for multiple)
audiodevice Stream from an audio device
screenlive+audiodevice Stream screen and audio simultaneously
videodevice+audiodevice Stream video from camera and audio from mic

2. Destination Stream (<dsturl>)

The RTMP address where the stream will be pushed. Format: rtmp://[server]/[application]/[stream]

  • YouTube Live: rtmp://a.rtmp.youtube.com/live2/your-stream-key
  • Facebook Live: rtmp://live-api-s.facebook.com:80/rtmp/your-stream-key
  • Custom RTMP Server: rtmp://your-server.com/live/stream1

3. Authentication (<user>, <pass>)

If your RTSP source requires authentication, provide the username and password here.

4. Video Output Parameters

Control the video stream output. Use 0 to inherit the source's value.

Parameter Description Default (if 0)
<width> Output video width (pixels) Source width
<height> Output video height (pixels) Source height
<framerate> Output video frame rate (fps) Source framerate

5. Audio Output Parameters

Control the audio stream output. Use 0 to inherit the source's value.

Parameter Description Default (if 0)
<samplerate> Audio sample rate (Hz) Source sample rate (8000 for device)
<channels> Audio channels (1=mono, 2=stereo) Source channels (2 for device)

Complete Configuration Example

Here's a full rtmppusher.cfg file with multiple pushers and custom settings.

rtmppusher.cfg
<config>
    <!-- Pusher 1: Camera to Local RTMP Server -->
    <pusher>
        <srcurl>rtsp://192.168.1.3:554/live</srcurl>
        <dsturl>rtmp://192.168.1.102/myapp/camera1</dsturl>
        <user>admin</user>
        <pass>password123</pass>
        <video>
            <width>1280</width>
            <height>720</height>
            <framerate>25</framerate>
        </video>
        <audio>
            <samplerate>44100</samplerate>
            <channels>2</channels>
        </audio>
    </pusher>
    
    <!-- Pusher 2: Another Camera to YouTube -->
    <pusher>
        <srcurl>rtsp://192.168.1.4:554/live</srcurl>
        <dsturl>rtmp://a.rtmp.youtube.com/live2/your-youtube-key</dsturl>
        <user>admin</user>
        <pass>password123</pass>
        <video>
            <width>1920</width>
            <height>1080</height>
            <framerate>30</framerate>
        </video>
        <audio>
            <samplerate>44100</samplerate>
            <channels>2</channels>
        </audio>
    </pusher>
</config>

Best Practices

  • Match Platform Requirements: Ensure your output resolution, frame rate, and bitrate meet the requirements of your destination (e.g., YouTube, Facebook).
  • Optimize for Bandwidth: Transcode to a lower resolution/frame rate if your network or destination has limitations.
  • Secure Credentials: Never share your RTMP stream keys publicly. Store them securely.
  • Monitor Performance: Keep an eye on CPU usage and network bandwidth, especially when running multiple pushers.
  • Use Stable Sources: Ensure your RTSP sources (cameras) have a stable network connection.