go2rtc README

The project's README from github.com/AlexxIT/go2rtc. As one markdown file: README.md.

go2rtc - GitHub

go2rtc - GitHub Stars go2rtc - Docker Pulls go2rtc - GitHub Downloads

go2rtc - Trendshift

Ultimate camera streaming application with support for dozens formats and protocols.

Inspired by


Table of Contents

Installation

  1. Download binary or use Docker or Home Assistant add-on or integration
  2. Open web interface: http://localhost:1984/
  3. 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

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

  1. Settings > Add-ons > Plus > Repositories > Add
    https://github.com/AlexxIT/hassio-addons
    
  2. 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:

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.

go2rtc webui config

The simplest config looks like this:

streams:
  hall-camera: rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0

More information can be found here.

Features

A summary table of all modules and features can be found here.

Core modules

Streaming input

public protocols

private protocols

devices

files

scripts

webrtc

Streaming output

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.

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.

read more

Publish stream

You can publish any stream to streaming services (YouTube, Telegram, etc.) via RTMP/RTMPS.

read more

Preload stream

You can preload any stream on go2rtc start. This is useful for cameras that take a long time to start up.

read more

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.

go2rtc webui net

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:

Some examples:

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*

Audio

Apple devices

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

Codecs negotiation

For example, you want to watch an RTSP stream from a Dahua IPC-K42 camera in your Chrome browser.

Now you have a stream with two sources - RTSP and FFmpeg:

streams:
  dahua:
    - rtsp://admin:[email protected]/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
    - ffmpeg:rtsp://admin:[email protected]/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

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

Distributions

Camera experience

Tips

Using apps for low RTSP delay

Snapshots to Telegram

read more

go2rtc (AlexxIT/go2rtc)

Searching Database…

14.4K ·GitHub
这是干什么的?一个功能强大的摄像头推流应用:它从 IP 摄像头和其他来源拉取视频,再以 WebRTC、HLS、MP4 等低延迟格式提供给浏览器和智能家居平台,既可以作为独立应用运行,也可以嵌入到任何项目中。
它是我自己运行的服务器、桌面应用,还是写代码时调用的库?一个独立的零依赖流媒体服务器,自带网页界面——Windows、macOS、Linux 和 FreeBSD 各只需一个小小的二进制文件。它还提供 HTTP 和 WebSocket API,可以集成到其他项目中。
我怎么把它跑起来?从最新 release 下载一个二进制文件(或者用 Docker 镜像或 Home Assistant 加载项),运行后打开网页界面即可。摄像头在 go2rtc.yaml 配置文件里添加;API 默认监听 1984 端口,RTSP 服务器监听 8554 端口。
我需要另外安装 FFmpeg 或其他东西吗?不需要——它是一个零依赖的单一二进制文件。只有当视频流确实需要转码时才会临时调用 FFmpeg;Docker 镜像里则预装了 FFmpeg 和 Python。
浏览器里的双向语音开箱即用吗?可以通过 WebRTC 实现,但浏览器只允许在 HTTPS 网站上使用麦克风,所以走普通 HTTP 时,你的声音无法传到摄像头。
我能把摄像头画面转推到 YouTube 或 Telegram 吗?可以——任何视频流都能通过 RTMP/RTMPS 直接从 go2rtc 推送到 YouTube、Telegram 这类热门平台。
它怎么接入 Home Assistant?既可以作为 Home Assistant 加载项运行,也可以通过 WebRTC Camera 自定义集成来接入——这个集成能自动下载 go2rtc,或者连接已有的实例,所以加载项不是必需的。它还能把 MP4 录像输出给 Frigate 这类工具。
它能在树莓派或其他小型硬件上运行吗?可以——提供 Linux ARM64、ARM32 版本,甚至有支持初代 Raspberry Pi 和 Raspberry Pi Zero 的 ARMv6 版本,还有面向小米网关 3(Xiaomi Gateway 3)和 Wyze 摄像头等设备的 MIPS 版本。
我能看到谁在看我的视频流吗?WebUI 会显示每个活动连接的详细统计信息:IP 地址、格式、协议、收发的数据包和字节数——也可以通过 HTTP API 以 JSON 格式获取,还附带一个交互式连接图。
Creator
AlexxIT
Size
17.8 MB
Stars
14.4K
Age
4y
Commits · 90 Days