Top Related Projects
Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS / MPEG-TS / RTP media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS / MPEG-TS / RTP media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181, with codec support for H.264, H.265, AV1, VP9, AAC, Opus, and G.711.
open source、high performance、industrial rtsp streaming server,a lot of optimization on streaming relay,KeyFrame cache,RESTful,and web management,also EasyDarwin support distributed load balancing,a simple streaming media cloud platform architecture.
RTSP Stream to WebBrowser
Pure Go implementation of the WebRTC API
Quick Overview
go2rtc is an innovative WebRTC streaming server written in Go. It's designed to be a universal stream source, capable of handling various protocols and codecs, making it ideal for video surveillance systems and IoT devices. The project aims to simplify the process of streaming video from different sources to web browsers and mobile applications.
Pros
- Supports multiple streaming protocols (RTSP, RTMP, HLS, HTTP-FLV, WebRTC)
- Efficient transcoding capabilities for various video and audio codecs
- Lightweight and cross-platform, suitable for both powerful servers and small devices
- Active development and community support
Cons
- Relatively new project, may have some stability issues
- Documentation could be more comprehensive for advanced use cases
- Limited built-in security features compared to some established streaming solutions
- Requires some technical knowledge to set up and configure properly
Code Examples
Here are a few examples of how to use go2rtc in your Go projects:
- Creating a new RTSPServer:
import "github.com/AlexxIT/go2rtc/pkg/rtsp"
server := rtsp.NewServer(":8554")
server.Start()
- Adding a stream source:
import "github.com/AlexxIT/go2rtc/pkg/streamer"
src, err := streamer.NewSource("rtsp://example.com/stream")
if err != nil {
log.Fatal(err)
}
stream := streamer.NewStream(src)
- Handling WebRTC connections:
import "github.com/AlexxIT/go2rtc/pkg/webrtc"
conn := webrtc.NewConn()
offer := webrtc.Offer{} // Populate with SDP from client
answer, err := conn.CreateAnswer(offer)
if err != nil {
log.Fatal(err)
}
// Send answer back to client
Getting Started
To get started with go2rtc, follow these steps:
- Install Go on your system (version 1.16 or later)
- Clone the repository:
git clone https://github.com/AlexxIT/go2rtc.git - Navigate to the project directory and build:
cd go2rtc go build - Run the server:
./go2rtc - Configure your streams in the
go2rtc.yamlfile - Access the web interface at
http://localhost:1984
For more detailed configuration and usage instructions, refer to the project's documentation on GitHub.
Competitor Comparisons
Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS / MPEG-TS / RTP media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
Pros of mediamtx
- More comprehensive documentation and examples
- Better support for RTSP and SRT protocols
- More active development and frequent updates
Cons of mediamtx
- Larger codebase, potentially more complex to understand and modify
- Less focus on WebRTC functionality compared to go2rtc
- May have higher resource usage due to broader feature set
Code Comparison
mediamtx:
type RTSPServer struct {
rtspAddress string
protocols map[conf.Protocol]struct{}
sessions map[*gortsplib.ServerSession]*rtspSession
mutex sync.Mutex
}
go2rtc:
type RTSPServer struct {
ln net.Listener
tracks []*streamer.Track
clients map[string]*RTSPClient
}
The code snippets show differences in structure and approach. mediamtx appears to have a more complex implementation with additional features, while go2rtc seems more focused on core RTSP functionality.
Both projects serve as media servers with real-time streaming capabilities, but they have different strengths and focuses. mediamtx offers broader protocol support and more extensive documentation, while go2rtc may be simpler to work with for specific use cases, particularly those centered around WebRTC.
Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS / MPEG-TS / RTP media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
Pros of mediamtx
- More comprehensive documentation and examples
- Better support for RTSP and SRT protocols
- More active development and frequent updates
Cons of mediamtx
- Larger codebase, potentially more complex to understand and modify
- Less focus on WebRTC functionality compared to go2rtc
- May have higher resource usage due to broader feature set
Code Comparison
mediamtx:
type RTSPServer struct {
rtspAddress string
protocols map[conf.Protocol]struct{}
sessions map[*gortsplib.ServerSession]*rtspSession
mutex sync.Mutex
}
go2rtc:
type RTSPServer struct {
ln net.Listener
tracks []*streamer.Track
clients map[string]*RTSPClient
}
The code snippets show differences in structure and approach. mediamtx appears to have a more complex implementation with additional features, while go2rtc seems more focused on core RTSP functionality.
Both projects serve as media servers with real-time streaming capabilities, but they have different strengths and focuses. mediamtx offers broader protocol support and more extensive documentation, while go2rtc may be simpler to work with for specific use cases, particularly those centered around WebRTC.
SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181, with codec support for H.264, H.265, AV1, VP9, AAC, Opus, and G.711.
Pros of srs
- More comprehensive streaming server with support for multiple protocols (RTMP, HLS, WebRTC, etc.)
- Highly scalable and suitable for large-scale deployments
- Extensive documentation and active community support
Cons of srs
- More complex setup and configuration compared to go2rtc
- Higher resource requirements due to its comprehensive feature set
- Steeper learning curve for beginners
Code Comparison
srs (C++):
SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, const SrsContextId& cid)
{
server = s;
cid_ = cid;
req = NULL;
sendonly_ = false;
}
go2rtc (Go):
func (c *Conn) WritePacket(packet *rtp.Packet) (err error) {
if c.mtu > 0 && packet.MarshalSize() > c.mtu {
return c.writeLargePacket(packet)
}
return c.writePacket(packet)
}
The code snippets demonstrate different approaches and languages used in these projects. srs uses C++ for its implementation, while go2rtc is written in Go. The srs example shows a constructor for an RTC connection, while the go2rtc snippet handles packet writing with MTU considerations.
open source、high performance、industrial rtsp streaming server,a lot of optimization on streaming relay,KeyFrame cache,RESTful,and web management,also EasyDarwin support distributed load balancing,a simple streaming media cloud platform architecture.
Pros of EasyDarwin
- More mature and established project with a longer development history
- Supports a wider range of streaming protocols, including RTSP, RTMP, and HLS
- Offers more comprehensive documentation and user guides
Cons of EasyDarwin
- Written in C++, which may be less accessible for some developers compared to Go
- Potentially more complex setup and configuration process
- Less active development in recent years compared to go2rtc
Code Comparison
EasyDarwin (C++):
int EasyRTSPClient::Start(int nNetType /*= EASY_RTP_OVER_TCP*/)
{
if(NULL == fRTSPClientHandle)
{
fRTSPClientHandle = EasyRTSP_Create();
}
if(NULL == fRTSPClientHandle) return -1;
go2rtc (Go):
func (s *Stream) Start() error {
s.mu.Lock()
defer s.mu.Unlock()
if s.source != nil {
return nil
}
The code snippets show the initialization process for both projects. EasyDarwin uses C++ and focuses on creating an RTSP client handle, while go2rtc uses Go and implements a more straightforward stream start function.
RTSP Stream to WebBrowser
Pros of RTSPtoWeb
- Simpler setup and configuration for basic RTSP to web streaming
- Longer development history and potentially more stable
- Includes a built-in web UI for stream management
Cons of RTSPtoWeb
- Less flexible in terms of supported protocols and codecs
- Limited active development and updates
- Fewer advanced features compared to go2rtc
Code Comparison
RTSPtoWeb:
type Stream struct {
URL string `json:"url"`
Status bool `json:"status"`
Type string `json:"type"`
Name string `json:"name"`
OnDemand bool `json:"on_demand"`
Channels []Channel `json:"channels"`
}
go2rtc:
type Stream struct {
URL string
Media []*streamer.Media
Tracks []*streamer.Track
Consumers []Consumer
Producers []Producer
}
The code comparison shows that go2rtc has a more complex stream structure, allowing for greater flexibility in handling different media types and streaming protocols. RTSPtoWeb's structure is simpler, focusing primarily on RTSP streams and basic metadata.
Pure Go implementation of the WebRTC API
Pros of webrtc
- More comprehensive WebRTC implementation with broader feature set
- Larger community and more frequent updates
- Better documentation and examples for developers
Cons of webrtc
- Steeper learning curve for beginners
- May be overkill for simple streaming applications
- Requires more setup and configuration for basic use cases
Code Comparison
go2rtc (simplified stream setup):
stream := rtc.NewStream("camera1")
stream.AddSource(rtsp.NewSource("rtsp://example.com/stream"))
stream.AddConsumer(webrtc.NewConsumer())
webrtc (basic peer connection):
peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
if err != nil {
panic(err)
}
// Additional configuration and signaling required
Summary
go2rtc is designed for easy setup of media streaming with WebRTC, RTSP, and other protocols. It's more focused on simplifying the process of creating streaming applications.
webrtc provides a full WebRTC implementation with more flexibility and features, but requires more in-depth knowledge and setup. It's better suited for complex WebRTC applications beyond simple streaming.
Choose go2rtc for quick streaming setups, or webrtc for more comprehensive WebRTC functionality and control.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Ultimate camera streaming application with support for dozens formats and protocols.
- zero-dependency small app for all OS (Windows, macOS, Linux, FreeBSD)
- zero-delay for many supported protocols (lowest possible streaming latency)
- streaming input from dozens formats and protocols
- streaming output in all popular formats
- streaming ingest in a number of popular formats
- publish any source to popular streaming services (YouTube, Telegram)
- on-the-fly transcoding only if necessary via FFmpeg
- two-way audio support for many formats
- streaming audio to all cameras with two-way audio support
- mixing tracks from different sources to single stream
- auto-match client-supported streaming formats and codecs
- streaming stats for all active connections
- can be integrated to any project or be used as standalone app
Inspired by
- series of streaming projects from @deepch
- webrtc go library and whole @pion team
- rtsp-simple-server idea from @aler9
- GStreamer framework pipeline idea
- MediaSoup framework routing idea
- HomeKit Accessory Protocol from @brutella
- creator of the project's logo @v_novoseltsev
Table of Contents
Installation
- Download binary or use Docker or Home Assistant add-on or integration
- Open web interface:
http://localhost:1984/ - Add streams to config
Developers: integrate HTTP API into your smart home platform.
go2rtc: Binary
Download binary for your OS from latest release:
| name | description |
|---|---|
| go2rtc_win64.zip | Windows 10+ 64-bit |
| go2rtc_win32.zip | Windows 10+ 32-bit |
| go2rtc_win_arm64.zip | Windows ARM 64-bit |
| go2rtc_linux_amd64 | Linux 64-bit |
| go2rtc_linux_i386 | Linux 32-bit |
| go2rtc_linux_arm64 | Linux ARM 64-bit (ex. Raspberry 64-bit OS) |
| go2rtc_linux_arm | Linux ARM 32-bit (ex. Raspberry 32-bit OS) |
| go2rtc_linux_armv6 | Linux ARMv6 (for old Raspberry 1 and Zero) |
| go2rtc_linux_mipsel | Linux MIPS (ex. Xiaomi Gateway 3, Wyze cameras) |
| go2rtc_mac_amd64.zip | macOS 11+ Intel 64-bit |
| go2rtc_mac_arm64.zip | macOS ARM 64-bit |
| go2rtc_freebsd_amd64.zip | FreeBSD 64-bit |
| go2rtc_freebsd_arm64.zip | FreeBSD ARM 64-bit |
Don't forget to fix the rights chmod +x go2rtc_xxx_xxx on Linux and Mac.
PS. The application is compiled with the latest versions of the Go language for maximum speed and security. Therefore, the minimum OS versions depend on the Go language.
go2rtc: Docker
The Docker containers alexxit/go2rtc and ghcr.io/alexxit/go2rtc support multiple architectures including 386, amd64, arm/v6, arm/v7 and arm64.
These containers offer the same functionality as the Home Assistant add-on but are designed to operate independently of Home Assistant.
It comes preinstalled with FFmpeg and Python.
go2rtc: Home Assistant add-on
- Settings > Add-ons > Plus > Repositories > Add
https://github.com/AlexxIT/hassio-addons - go2rtc > Install > Start
go2rtc: Home Assistant Integration
WebRTC Camera custom component can be used on any Home Assistant installation, including HassWP on Windows. It can automatically download and use the latest version of go2rtc. Or it can connect to an existing version of go2rtc. Addon installation in this case is optional.
go2rtc: Master version
Latest, but maybe unstable version:
- Binary: latest master build
- Docker:
alexxit/go2rtc:masteroralexxit/go2rtc:master-hardwareversions - Home Assistant add-on:
go2rtc masterorgo2rtc master hardwareversions
Configuration
This is the go2rtc.yaml file in YAML-format.
The configuration can be changed in the WebUI at http://localhost:1984.
The editor provides syntax highlighting and checking.

The simplest config looks like this:
streams:
hall-camera: rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0
- by default go2rtc will search
go2rtc.yamlin the current work directory apiserver will start on default 1984 port (TCP)rtspserver will start on default 8554 port (TCP)webrtcwill use port 8555 (TCP/UDP) for connections
More information can be found here.
Features
A summary table of all modules and features can be found here.
Core modules
app- Reading configs and setting up logs.api- Handle HTTP and WebSocket API.streams- Handle a list of streams.
Streaming input
public protocols
mpjpeg- The legacy but still used MJPEG protocol for real-time media transmission.onvif- A popular ONVIF protocol for receiving media in RTSP format.rtmp- The legacy but still used RTMP protocol for real-time media transmission.rtsp- The most common RTSP protocol for real-time media transmission.webrtc- WebRTC web-compatible protocol for real-time media transmission.yuv4mpegpipe- Raw YUV frame stream with YUV4MPEG header.
private protocols
bubble- Some NVR from dvr163.com and eseecloud.com.doorbird- Doorbird devices with two-way audio.dvrip- DVR-IP NVR, NetSurveillance, Sofia protocol (XMeye SDK).eseecloud- Some NVR from dvr163.com and eseecloud.com.gopro- GoPro cameras, connected via USB or Wi-Fi.hass- Import cameras from Home Assistant config files.homekit- Cameras with Apple HomeKit protocol.isapi- Two-way audio for Hikvision ISAPI protocol.kasa- TP-Link Kasa cameras.multitrans- Two-way audio for Chinese version of TP-Link cameras.nest- Google Nest cameras through user-unfriendly and paid APIs.ring- Ring cameras with two-way audio support.roborock- Roborock vacuums with cameras with two-way audio support.tapo- TP-Link Tapo cameras with two-way audio support.vigi- TP-Link Vigi cameras.tuya- Tuya ecosystem cameras with two-way audio support.webtorrent- Stream from another go2rtc via WebTorrent protocol.wyze- Wyze cameras using native P2P protocolxiaomi- Xiaomi Mi Home ecosystem cameras with two-way audio support.
devices
alsa- A framework for receiving audio from devices on Linux OS.v4l2- A framework for receiving video from devices on Linux OS.
files
adts- Audio stream in AAC codec with Audio Data Transport Stream headers.flv- The legacy but still used Flash Video format.h264- AVC/H.264 bitstream.hevc- HEVC/H.265 bitstream.hls- A popular HTTP Live Streaming format.mjpeg- A continuous sequence of JPEG frames (without HTTP headers).mpegts- The legacy MPEG transport stream format.wav- Audio stream in Waveform Audio File format.
scripts
echo- If the source has a dynamic link, you can use a bash or python script to get it.exec- You can run an external application (ffmpeg,gstreamer,rpicam, etc.) and receive a media stream from it.expr- If the source has a dynamic link, you can use Expr language to get it.ffmpeg- Use FFmpeg as a stream source. Hardware-accelerated transcoding and streaming from USB devices are supported.
webrtc
creality- Creality 3D printer cameras.kinesis- Amazon Kinesis video streams.openipc- Cameras on open-source OpenIPC firmware.switchbot- SwitchBot cameras.whep- WebRTC/WHEP is replaced by WebRTC/WISH standard for WebRTC video/audio viewers.wyze- Legacy method to connect to Wyze cameras via docker-wyze-bridge.
Streaming output
adts- Output stream in ADTS format with AAC audio.ascii- Just for fun stream as ASCII to Terminal.flv- Output stream in Flash Video format.hls- Output stream in HTTP Live Streaming format.homekit- Output stream to Apple Home using HomeKit protocol.jpeg- Output snapshots in JPEG format.mpjpeg- Output a stream in MJPEG format.mp4- Output as MP4 stream or Media Source Extensions (MSE) compatible format.mpegts- Output stream in MPEG transport stream format.onvif- Output stream using ONVIF protocol.rtmp- Output stream using Real-Time Messaging protocol.rtsp- Output stream using Real-Time Streaming protocol.webrtc- Output stream using Web Real-Time Communication API.webtorrent- Output stream using WebTorrent protocol.yuv4mpegpipe- Output in raw YUV frame stream with YUV4MPEG header.
Streaming ingest
Supported for:
flv,
mjpeg,
mpegts,
rtmp,
rtsp,
webrtc.
This is a feature when go2rtc expects to receive an incoming stream from an external application. The stream transmission is started and stopped by an external application.
- You can push data only to an existing stream (create a stream with empty source in config).
- You can push multiple incoming sources to the same stream.
- You can push data to a non-empty stream, so it will have additional codecs inside.
Two-way audio
Supported for:
doorbird,
dvrip,
exec,
isapi,
multitrans,
ring,
roborock,
rtsp,
tapo,
tuya,
webrtc,
wyze,
xiaomi.
Two-way audio can be used in browser with WebRTC technology. The browser will give access to the microphone only for HTTPS sites (read more).
Stream to camera
You can play audio files or live streams on any camera with two-way audio support.
Publish stream
You can publish any stream to streaming services (YouTube, Telegram, etc.) via RTMP/RTMPS.
Preload stream
You can preload any stream on go2rtc start. This is useful for cameras that take a long time to start up.
Streaming stats
WebUI provides detailed information about all active connections, including IP-addresses, formats, protocols, number of packets and bytes transferred.
Via the HTTP API in json or dot format on an interactive connection map.

Codecs
If you have questions about why video or audio is not displayed, you need to read the following sections.
| Name | FFmpeg | RTSP | Aliases |
|---|---|---|---|
| Advanced Audio Coding | aac | MPEG4-GENERIC | |
| Advanced Video Coding | h264 | H264 | AVC, H.264 |
| G.711 PCM (A-law) | alaw | PCMA | G711A |
| G.711 PCM (µ-law) | mulaw | PCMU | G711u |
| High Efficiency Video Coding | hevc | H265 | HEVC, H.265 |
| Motion JPEG | mpjpeg | JPEG | |
| MPEG-1 Audio Layer III | mp3 | MPA | |
| Opus Codec | opus | OPUS | |
| PCM signed 16-bit big-endian | s16be | L16 |
Codecs filters
go2rtc can automatically detect which codecs your device supports for WebRTC and MSE technologies.
But it cannot be done for RTSP, HTTP progressive streaming, HLS technologies. You can manually add a codec filter when you create a link to a stream. The filters work the same for all three technologies. Filters do not create a new codec, they only select the suitable codec from existing sources. You can add new codecs to the stream using the FFmpeg transcoding.
Without filters:
- RTSP will provide only the first video and only the first audio (any codec)
- MP4 will include only compatible codecs (H264, H265, AAC)
- HLS will output in the legacy TS format (H264 without audio)
Some examples:
rtsp://192.168.1.123:8554/camera1?mp4- useful for recording as MP4 files (e.g. Home Assistant or Frigate)rtsp://192.168.1.123:8554/camera1?video=h264,h265&audio=aac- full version of the filter abovertsp://192.168.1.123:8554/camera1?video=h264&audio=aac&audio=opus- H264 video codec and two separate audio tracksrtsp://192.168.1.123:8554/camera1?video&audio=all- any video codec and all audio codecs as separate trackshttp://192.168.1.123:1984/api/stream.m3u8?src=camera1&mp4- HLS stream with MP4 compatible codecs (HLS/fMP4)http://192.168.1.123:1984/api/stream.m3u8?src=camera1&mp4=flac- HLS stream with PCMA/PCMU/PCM audio support (HLS/fMP4), won't work on old deviceshttp://192.168.1.123:1984/api/stream.mp4?src=camera1&mp4=flac- MP4 file with PCMA/PCMU/PCM audio support, won't work on old devices (ex. iOS 12)http://192.168.1.123:1984/api/stream.mp4?src=camera1&mp4=all- MP4 file with non-standard audio codecs, won't work on some players
Codecs madness
AVC/H.264 video can be played almost anywhere. But HEVC/H.265 has many limitations in supporting different devices and browsers.
| Device | WebRTC | MSE | HTTP* | HLS |
|---|---|---|---|---|
| latency | best | medium | bad | bad |
| Desktop Chrome 136+ Desktop Edge Android Chrome 136+ | H264, H265* PCMU, PCMA OPUS | H264, H265* AAC, FLAC* OPUS | H264, H265* AAC, FLAC* OPUS, MP3 | no |
| Desktop Firefox | H264 PCMU, PCMA OPUS | H264 AAC, FLAC* OPUS | H264 AAC, FLAC* OPUS | no |
| Desktop Safari 14+ iPad Safari 14+ iPhone Safari 17.1+ | H264, H265* PCMU, PCMA OPUS | H264, H265 AAC, FLAC* | no! | H264, H265 AAC, FLAC* |
| iPhone Safari 14+ | H264, H265* PCMU, PCMA OPUS | no! | no! | H264, H265 AAC, FLAC* |
| macOS Hass App | no | no | no | H264, H265 AAC, FLAC* |
HTTP*- HTTP Progressive Streaming, not related to progressive download, because the file has no size and no endWebRTC H265- supported in Chrome 136+, supported in Safari 18+MSE iPhone- supported in iOS 17.1+
Audio
- go2rtc supports automatic repackaging of
PCMA/PCMU/PCMcodecs intoFLACfor MSE/MP4/HLS so they'll work almost anywhere - WebRTC audio codecs:
PCMU/8000,PCMA/8000,OPUS/48000/2 OPUSandMP3inside MP4 are part of the standard, but some players do not support them anyway (especially Apple)
Apple devices
- all Apple devices don't support HTTP progressive streaming
- old iPhone firmwares don't support MSE technology because it competes with the HTTP Live Streaming (HLS) technology, invented by Apple
- HLS is the worst technology for live streaming, it still exists only because of iPhones
Built-in transcoding
There are no plans to embed complex transcoding algorithms inside go2rtc. FFmpeg source does a great job with this. Including hardware acceleration support.
But go2rtc has some simple algorithms. They are turned on automatically; you do not need to set them up additionally.
PCM for MSE/MP4/HLS
Go2rtc can pack PCMA, PCMU and PCM codecs into an MP4 container so that they work in all browsers and all built-in players on modern devices. Including Apple QuickTime:
PCMA/PCMU => PCM => FLAC => MSE/MP4/HLS
Resample PCMA/PCMU for WebRTC
By default WebRTC supports only PCMA/8000 and PCMU/8000. But go2rtc can automatically resample PCMA and PCMU codecs with a different sample rate. Also, go2rtc can transcode PCM codec to PCMA/8000, so WebRTC can play it:
PCM/xxx => PCMA/8000 => WebRTC
PCMA/xxx => PCMA/8000 => WebRTC
PCMU/xxx => PCMU/8000 => WebRTC
Important
- FLAC codec not supported in an RTSP stream. If you are using Frigate or Home Assistant for recording MP4 files with PCMA/PCMU/PCM audio, you should set up transcoding to the AAC codec.
- PCMA and PCMU are VERY low-quality codecs. They support only 256! different sounds. Use them only when you have no other options.
Codecs negotiation
For example, you want to watch an RTSP stream from a Dahua IPC-K42 camera in your Chrome browser.
- this camera supports two-way audio standard ONVIF Profile T
- this camera supports codecs H264, H265 for sending video, and you select
H264in camera settings - this camera supports codecs AAC, PCMU, PCMA for sending audio (from mic), and you select
AAC/16000in camera settings - this camera supports codecs AAC, PCMU, PCMA for receiving audio (to speaker), you don't need to select them
- your browser supports codecs H264, VP8, VP9, AV1 for receiving video, you don't need to select them
- your browser supports codecs OPUS, PCMU, PCMA for sending and receiving audio, you don't need to select them
- you can't get the camera audio directly because its audio codecs don't match your browser's codecs
- so you decide to use transcoding via FFmpeg and add this setting to the config YAML file
- you have chosen
OPUS/48000/2codec, because it is higher quality than thePCMU/8000orPCMA/8000
Now you have a stream with two sources - RTSP and FFmpeg:
streams:
dahua:
- rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
- ffmpeg:rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0#audio=opus
go2rtc automatically matches codecs for your browser across all of your stream sources. This is called multi-source two-way codec negotiation, and it's one of the main features of this app.
PS. You can select PCMU or PCMA codec in camera settings and not use transcoding at all. Or you can select AAC codec for main stream and PCMU codec for second stream and add both RTSP to YAML config, this also will work fine.
Security
[!IMPORTANT] If an attacker gains access to the API, you are in danger. Through the API, an attacker can use insecure sources such as echo and exec. And get full access to your server.
For maximum (paranoid) security, go2rtc has special settings:
app:
# use only allowed modules
modules: [api, rtsp, webrtc, exec, ffmpeg, mjpeg]
api:
# use only allowed API paths
allow_paths: [/api, /api/streams, /api/webrtc, /api/frame.jpeg]
# enable auth for localhost (used together with username and password)
local_auth: true
exec:
# use only allowed exec paths
allow_paths: [ffmpeg]
By default, go2rtc starts the Web interface on port 1984 and RTSP on port 8554, as well as uses port 8555 for WebRTC connections. The three ports are accessible from your local network. So anyone on your local network can watch video from your cameras without authorization. The same rule applies to the Home Assistant add-on.
This is not a problem if you trust your local network as much as I do. But you can change this behaviour with a go2rtc.yaml config:
api:
listen: "127.0.0.1:1984" # localhost
rtsp:
listen: "127.0.0.1:8554" # localhost
webrtc:
listen: ":8555" # external TCP/UDP port
- local access to RTSP is not a problem for FFmpeg integration, because it runs locally on your server
- local access to API is not a problem for the Home Assistant add-on, because Home Assistant runs locally on the same server, and the add-on web UI is protected with Home Assistant authorization (Ingress feature)
- external access to WebRTC TCP port is not a problem, because it is used only for transmitting encrypted media data
- anyway you need to open this port to your local network and to the Internet for WebRTC to work
If you need web interface protection without the Home Assistant add-on, you need to use a reverse proxy, like Nginx, Caddy, etc.
PS. Additionally, WebRTC will try to use the 8555 UDP port to transmit encrypted media. It works without problems on the local network, and sometimes also works for external access, even if you haven't opened this port on your router (read more). But for stable external WebRTC access, you need to open the 8555 port on your router for both TCP and UDP.
Projects using go2rtc
- Home Assistant 2024.11+ - top open-source smart home project
- Frigate 0.12+ - open-source NVR built around real-time AI object detection
- Advanced Camera Card - custom card for Home Assistant
- OpenIPC - alternative IP camera firmware from an open community
- wz_mini_hacks - custom firmware for Wyze cameras
- EufyP2PStream - a small project that provides a video/audio stream from Eufy cameras that don't directly support RTSP
- ioBroker.euSec - ioBroker adapter for controlling Eufy security devices
- MMM-go2rtc - MagicMirror² module
- ring-mqtt - Ring-to-MQTT bridge
- lightNVR
Distributions
Camera experience
- Dahua - reference implementation streaming protocols, a lot of settings, high stream quality, multiple streaming clients
- EZVIZ - awful RTSP protocol implementation, many bugs in SDP
- Hikvision - a lot of proprietary streaming technologies
- Reolink - some models have an awful, unusable RTSP implementation and not the best RTMP alternative (I recommend that you contact Reolink support for new firmware), few settings
- Sonoff - very low stream quality, no settings, not the best protocol implementation
- TP-Link - few streaming clients, packet loss?
- Cheap noname cameras, Wyze Cams, Xiaomi cameras with hacks (usually have
/live/ch00_1in RTSP URL) - awful but usable RTSP protocol implementation, low stream quality, few settings, packet loss?
Tips
Using apps for low RTSP delay
ffplay -fflags nobuffer -flags low_delay "rtsp://192.168.1.123:8554/camera1"- VLC > Preferences > Input / Codecs > Default Caching Level: Lowest Latency
Snapshots to Telegram
Top Related Projects
Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS / MPEG-TS / RTP media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS / MPEG-TS / RTP media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181, with codec support for H.264, H.265, AV1, VP9, AAC, Opus, and G.711.
open source、high performance、industrial rtsp streaming server,a lot of optimization on streaming relay,KeyFrame cache,RESTful,and web management,also EasyDarwin support distributed load balancing,a simple streaming media cloud platform architecture.
RTSP Stream to WebBrowser
Pure Go implementation of the WebRTC API
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot