Since it comes up so often during the course of my week, I want to share a few simple options with interested parties for publishing your streams to Red5. This covers all the drones and IP cameras that I’ve had exposure to over the years that do not already have a means to egress via RTMP. While Flash Player is “dead,” RTMP as a protocol certainly is not.
Using GStreamer for Stream Processing
First up is to download the GStreamer application, a powerful multimedia framework that can handle the conversion and streaming process. To learn more about it, read our previous blog on using GStreamer for low-latency streaming.
Discovering Your Stream Format
If you don’t know the format of the video and/or audio (if present) on your drone, the discoverer application can be used to see what you’re working with:
gst-discoverer-1.0 rtsp://10.0.0.10:554/stream
Replace 10.0.0.10:554 in the RTSP stream URL with your drone or camera IP address and port.
Video-Only Streams
When the source only provides video, this is the pipeline you’d use (assuming H.264):
gst-launch-1.0 rtspsrc location="rtsp://10.0.0.10:554/stream" latency=0 name=rtsp ! rtph264depay ! h264parse ! video/x-h264 ! queue ! flvmux name=mux ! rtmpsink location="rtmp://10.0.0.35:1935/live/drone1 live=1"
Audio-Only Streams
If the source is just audio, use this pipeline assuming an AAC codec:
gst-launch-1.0 rtspsrc location="rtsp://10.0.0.221:554/stream" latency=0 name=rtsp ! rtpmp4gdepay ! aacparse ! audio/mpeg ! queue ! flvmux name=mux ! rtmpsink location="rtmp://10.0.0.35:1935/live/remotemic1 live=1"
Combined Audio and Video Streams
Finally, for sources providing both audio and video:
gst-launch-1.0 -v rtspsrc location="rtsp://10.0.0.10:554/stream" latency=0 name=rtsp rtsp. ! rtph264depay ! h264parse ! video/x-h264 ! queue ! mux.video rtsp. ! rtpmp4gdepay ! aacparse ! audio/mpeg ! queue ! mux.audio flvmux name=mux ! rtmpsink location="rtmp://10.0.0.35:1935/live/audvid1 live=1"
Alternative: Red5 Restream API
This example demonstrates the simplest means to get your source devices providing egress via RTSP into Red5 without RTMP, using the Red5 Restream API via curl:
curl -X POST http://10.0.0.35:5080/live/restream \
-H "Content-Type: application/json" \
-d '{
"guid":"live/audvid1",
"context":"live",
"name":"audvid1",
"level":0,
"parameters":{
"type":"ipcam",
"action":"create",
"remoteContextPath":"stream",
"remoteStreamName":"",
"host":"10.0.0.10",
"port":554
}
}'
Final Notes
These examples use a non-routable network, and you can change the fields to fit your devices and environment. For more detailed information and advanced configurations, see our documentation. Whether you’re working with consumer drones, professional camera equipment, or IP security cameras, these methods should help you get your RTSP streams flowing into Red5 for further distribution and processing.
Top comments (0)