go2rtc

AlexxITMIT活跃维护

把 RTSP、ONVIF、RTMP、HLS、MJPEG 等摄像头流统一转成 WebRTC、HLS、MJPEG 等格式,方便在浏览器和 Home Assistant、HomeKit 里直接看监控画面。

Ultimate camera streaming application

v1.9.15发布于 2026-10-25 12:30 UTC14,617star +14 / 7 天1,491fork同步于 2026-11-10 11:26 UTC

怎么上手

由 README 提炼,执行前请确认
chmod +x go2rtc_xxx_xxx
./go2rtc_xxx_xxx
硬件要求按 README 说明

README 未说明显存或 GPU 要求;提供 Windows、macOS、Linux、FreeBSD 及 ARM/MIPS 等多架构二进制,Docker 镜像支持 386、amd64、arm/v6、arm/v7、arm64。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

零依赖的摄像头流媒体服务,把各种协议和格式的摄像头流统一接入并转出

把 RTSP、ONVIF、RTMP、HLS、MJPEG 等摄像头流统一转成 WebRTC、HLS、MJPEG 等格式,方便在浏览器和 Home Assistant、HomeKit 里直接看监控画面。

核心能力

  • 支持数十种输入输出协议与格式互转
  • 多协议下实现尽可能低的流媒体延迟
  • 按需通过 FFmpeg 实时转码
  • 支持多种格式的双向音频与向摄像头推音
  • 自动匹配客户端支持的流格式与编解码器

容易踩的坑

Linux/macOS 下载二进制后需先 chmod +x 赋予执行权限;默认从当前工作目录读取 go2rtc.yaml,需自行添加 streams 配置;API 默认占用 1984 端口,RTSP 8554,WebRTC 8555,注意端口冲突。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.9.15
  1. v1.9.15v1.9.15 - 2026-10-25最新正式版2026-10-25 · 2026-10-25 12:30 UTC

    Main

    • Update go build version to 1.27 (1cff2562)
    • Update dependencies (eb75edcb)

    Other

    • Add support xiaomi lumi.camera.gwagl01 (7793a558)
    • Add support xiaomi isa.camera.isc5c1 (06cbbe55)
    • Add support xiaomi chuangmi.camera.v2 on old firmwares (a37fdf38)
    • Add support xiaomi chuangmi.camera.ipc019e (8f68f80b)
    • Add support xiaomi isa.camera.df3 on old firmwares (6374366d)
    • Add trace log for xiaomi devices list (6f75b2f7)
    • Add support PCMATapo for MPEG-TS source #2159 by @ludufre (dc1685e9)
    • Add camera.ui link to projects #2349 by @seydx (c245815e)
    • Add support pet feeder to xiaomi source #2078 (e5bb0334)
    • Move kasa source to separate module (44f6f111)
    • Restore fix audio sample rate for some xiaomi cameras #2006 (01c74515)
    • Improve packet loss on old TUTK proto (75bd1f1b)
    • Strip Userinfo from log entries and errors #2051 (de157eb1)
    • Rename mpegts module to mpeg (2735bafd)
    • Fix ice_servers parsing for a list of URLs #2064 by @jmelancondev (d1d7846a)
    • Fix zero channel for xiaomi source #2047 (2f9d1386)
    • Fix unknown msg 0xF0 for cs2 proto (366cbd20)
    • Fix error handling in stream creation and patching tests #2065 by @skrashevich (8d58cc7f)

    Docs and site

    • Add meta info to website (e90f159c)
    • Add sitemap to website (f68c602a)
    • New documentation site #2044 by @skrashevich (7083afe9)
    • Update docs (be4b6c32)
    • Update documentation for clarity and accuracy #2058 by @skrashevich (6085c8aa)
    • Update README #1720 by @felipecrs (6eeba1ae)
    • Propose fix a couple of typos #2054 by @jeis4wpi (a41185c2)
    • Fix links in docs (f3ad4ad9)
    • Fix documentation grammar #2080 by @skrashevich (7f36033b)
    • Fix link to updated JSONSchema #2056 by @martinbjeldbak (c7938558)
  2. v1.9.14v1.9.14 - 2026-01-192026-01-19 · 2026-01-19 09:16 UTC
    查看更新说明

    Xiaomi source improvement

    Support for modern cameras has been significantly improved, and limited support for older Xiaomi cameras has been added.

    • Add support cateye devices to xiaomi source (753d6617)
    • Add TUTK protocol to xiaomi source #2003 (5b1da84a)
    • Add cache to xiaomi cloud logins (9a1eac8e)
    • Add support cs2+tcp protocol for xiaomi source (2f470fa5)
    • BIG rework of xiaomi source (4ffdeb06)
    • Code refactoring for xiaomi source (425fcffb)
    • Improve cs2+udp proto for xiaomi source #2026 #2030 (59161fce) (b19c0816)
    • Fix TCP keepalive to match official Mi Home app #2029 by @Johnnybyzhang (dab9efb7)
    • Fix login to Xiaomi account with captcha #1985 (eb39b808)
    • Fix audio sample rate for some xiaomi cameras #2006 (4dae65a5)
    • Fix two-way audio for cs2+tcp proto for xiaomi source (2f43bfe5)

    Wyze source

    Support for the native Wyze camera protocol has been added. This will require testing and feedback.

    • Native Wyze camera support #2011 by @seydx (8c457710)

    WebUI

    The config editor has been significantly improved. It now has config specification validation, autocompletion, and tooltips.

    • Replace ace editor to Monaco with config hints #1980 by @skrashevich (07fb78d6)
    • Add suggest button to config editor (654e78b7)
    • Move all JS libs to cdn.jsdelivr.net (6d77b175)
    • Move schema.json to www/static (1ec40f2f)
    • Remove unnecessary codecs.html (790fdfbf)

    WebRTC

    I hope this update finally fixes the UDP listener, especially for some users of virtual environments with IPv6.

    • Rewrite webrtc listen logic #1890 #1892 (9b618f45)
    • Add net interfaces list to webrtc debug (3fd1fe26)

    ONVIF improvement

    Some improvements to the ONVIF server for compatibility with different NVRs.

    • Adding onvif name and hardware in info field of onvif discovery #1991 by @FIGIO55 (b65ee278)
    • Improve ONVIF server support #1299 (af819952)
    • Fix ONVIF server support for Unifi Protect #1994 (fc22b208)

    Multitrans source

    New two-way audio protocol for Chinese versions of TP-Link cameras.

    • Add two-way talk support for TP-Link IPC camera #1724 #1995 by @forrestsocool (572f07fc)
    • Add multitrans source to readme (6a5deecf)

    Dev versions

    Now the dev version of the application contains a build number and is easy to distinguish from the release version.

    • Add fetch tags to GitHub actions (79698365)
    • Set app version from git info (079d404e)
    • Update app dev version format (212def9c)

    Readme

    • Add formats and protocols to readme (e960f90a)
    • Add about OS versions to readme (f9f22cdd)
    • Update README with Doorbird support details #2023 by @oeiber (5780bf37)
    • Update OpenAPI (a09e1b2f)
    • Update GitHub Pages site link (d183b99a)
    • Change header levels in readme (6796bdab)
    • Fix relative links in readme (ebe454e3)
    • Fix formats table in readme (e614513b)

    Other

    • Add #timeout param for ffmpeg source #1956 by @felipecrs (05fd0c5c)
    • Add RTSP params (like #backchannel=0) from onvif sources #1992 by @FIGIO55 (c880c37d)
    • Add JPEG snapshot caching #1155 by @skrashevich (38cc05c2)
    • Add EXPOSE to Dockerfile #2010 by @kaysond (9d1e4b11)
    • Add starttimeout setting to exec source #1846 (159fb467)
    • Add "bad conn" for debugging UDP (fd681079)
    • Skip snapshot caching in case of error (54eafe9d)
    • Log all modules with custom loggers (1cd55170)
    • Update dependencies (c64fcc55)
    • Fix parsing SDP with two channels audio #2019 by @binary-person (f85cfdc2)
  3. v1.9.13v1.9.13 - 2025-12-142025-12-14 · 2025-12-14 20:18 UTC
    查看更新说明

    Tuya source

    Read more

    • New Tuya camera support #1730 by @seydx (6d1a95a4)
    • Move tuya docs to separate page (2409bb56)

    Xiaomi source

    Read more

    • Add support xiaomi source (a4d4598a)
    • Add vendor name to xiaomi unsupported vendor message (57b0ace8)
    • Add about xiaomi source to readme (dfda4b11)
    • Fix backchannel audio for xiaomi chuangmi.camera.72ac1 (71193841)
    • Fix backchannel audio for xiaomi isa.camera.hlc6 (b0f46bc9)

    HomeKit updates

    • Add HomeKit QR code to WebUI #1138 by @mnakada (42e7a035)
    • Add custom category_id for HomeKit server #985 by @Minims (290e8fcf)
    • Add 404 error for homekit API request (6c78b5cb)
    • Fix panic for HomeKit server proxy mode #1940 (c72b205d)
    • Remove homekit source params from streams info API (2cd00964)

    Pinggy module

    Read more

    • Add support tunnels via Pinggy #1853 (4934fa4c)
    • Add mod_pinggy example (b47a2ba7)

    Docs

    • Add eseecloud source to readme (df484cc9)
    • Update readme (d734140e)
    • Update documentation for doorbird devices #1966 by @oeiber (7e0c7a81)

    Other

    • Add support HTTP-FLV with H265 from new Reolink cameras #1938 (8f5fce4d)
    • Add support new audio codec for tapo source #1954 (86edd814)
    • Add second STUN server from Cloudflare (7eb5fe03)
    • Add get request to preload endpoint for listing them #1977 by @edenhaus (03941a56)
    • Add PCML/8000 to ffmpeg transcoder (a86e1044)
    • Change ffmpeg transcoder from opus to opus/16000 (8636e963)
    • Improve fetch for exec source (fb31a251)
    • Increase default dial timeout and probe timeout (76a5e160)
    • Remove wrong timeout for http source (248fc7a1)
    • Fix link to per-stream net/node graphs #1942 by @sethyx (b705cadc)
    • Fix WebUI for Hass black theme (e246e2e7)
    • Fix adts producer for VLC player support #1643 (aa0ece2d)
    • Fix timestamp processing for HTTP-FLV (68036b68)

    Misc

    • Add UnmarshalHeader func to OPUS codec (c5277daa)
    • Add aliases to PCMA/PCMU codecs (494daed9)
    • Add custom title to stream page #1957 (fbd52156)
    • Add self-signed cert generator (not used yet) (b6fe8871)
    • Clean go.sum file (eabd7d60)
    • Update dependencies (5a259993 17c1f69f)
    • Update links to icons in resources (35326230)
    • Update title for all WebUI pages (3ebc115c)
  4. v1.9.12v1.9.12 - 2025-11-162025-11-16 · 2025-11-16 16:14 UTC
    查看更新说明

    Security update

    • Add security notes to readme (cb22ae78)
    • Add config local_auth for api module (44d59b16)
    • Add config for the list of modules to init (15ec995e)
    • Add config allow_paths for api module (231cab36)
    • Add config allow_paths for exec module (640db302)
    • Add config allow_paths for echo module (2836fdae)
    • Add insecure sources logic (2133f532)
    • Add check for insecure uri from onvif source (e2c7d067)
    • Add errors output to streams API (ac80f147)
    • Add trace log for ignored api paths (2ce38b44)

    HomeKit server update

    • Add support maxwidth/maxheight settings for homekit source (d053d88c)
    • Add support custom params for hass source (964bb225)
    • Add support uint64 to tlv8 (96919bf9)
    • Code refactoring for HomeKit server (158f9d3a)
    • Improve homekit secure conn buffers (ff18283d)
    • Improve homekit tlv8 parsing (994e0dc5)
    • Rename HomeKit structures according to specs (e4359ac2)
    • Fix HomeKit proxy EVENTs #684 #1923 (81cfcf87)
    • Fix HomeKit proxy for hass source #1353 (5cc32197)
    • Fix API /api/homekit/accessories (bc1a4ac8)

    WebUI update

    • Update WebUI design (1fe60267)

    Other

    • Add api endpoint to return supported schemas #1939 by @edenhaus (c98b0a83)
    • Code refactoring for tapo source (7254bd4f)
    • Restore simple onvif client logic (cc97bc33)
    • Fix onvif client for some cameras (6db4dda5)
    • Fix tapo source for some cameras #1918 (9f407a75)
    • Fix wrong log message for streams module (c10a06d1)
  5. v1.9.11v1.9.11 - 2025-10-212025-10-21 · 2025-10-21 13:21 UTC
    查看更新说明

    Main

    • Add priority for H265 codec in JS client #1642 #1644 by @seydx (dd7130d2)
    • Add support for SwitchBot VideoDoorbell #1823 by @hsakoh (f911936d)
    • Add support Preload Streams #605 #1762 by @seydx (37d7409e)
    • Add support RTSP redirects #1881 #1909 by @eddielth (d59cb99f)
    • Add support RTSP UDP transport #1758 by @seydx (c87885be)
    • Add support secrets management #1744 by @seydx (cca216ac)
    • Optimize ring source #1745 by @seydx (549da025)
    • Update FFmpeg command for encoding H265 (fix profile and level) (2b5f9429)
    • Fix RTP processing for H265 codec (restore VPS,SPS,PPS) (c7119f44)
    • Fix ONVIF client for Tapo cameras #1589 by @seydx (f1971cec)
    • Fix connection issues in conjunction with doorbird backchannel #1895 by @oeiber (6a67fc37)

    Other

    • Add caution note to readme (007e8dbc)
    • Add checks for corrupted data to the H265 handler (fdb31160)
    • Add compiled go2rtc to gitignore #1910 by @felipecrs (dae396a1)
    • Code refactoring for video-rtc.js (7d986220)
    • Improve build.sh #1641 by @felipecrs (f8c88cfb)
    • Move ngrok module docs to another page (5bbc2aaf)
    • Update dependencies (a8d2312c)
    • Update Python to 3.13 in docker image #1752 by @felipecrs (60ef52f4)
    • Fix docker build and push job when running from a fork #1761 by @felipecrs (a107d13e)
    • Fix stack API for new pion version (ec08dfee)
    • Fix probing after #1762 (54b95dce)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

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

    Inspired by

    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:

    namedescription
    go2rtc_win64.zipWindows 10+ 64-bit
    go2rtc_win32.zipWindows 10+ 32-bit
    go2rtc_win_arm64.zipWindows ARM 64-bit
    go2rtc_linux_amd64Linux 64-bit
    go2rtc_linux_i386Linux 32-bit
    go2rtc_linux_arm64Linux ARM 64-bit (ex. Raspberry 64-bit OS)
    go2rtc_linux_armLinux ARM 32-bit (ex. Raspberry 32-bit OS)
    go2rtc_linux_armv6Linux ARMv6 (for old Raspberry 1 and Zero)
    go2rtc_linux_mipselLinux MIPS (ex. Xiaomi Gateway 3, Wyze cameras)
    go2rtc_mac_amd64.zipmacOS 12+ Intel 64-bit
    go2rtc_mac_arm64.zipmacOS ARM 64-bit
    go2rtc_freebsd_amd64.zipFreeBSD 64-bit
    go2rtc_freebsd_arm64.zipFreeBSD 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:

    • Binary: latest master build
    • Docker: alexxit/go2rtc:master or alexxit/go2rtc:master-hardware versions
    • Home Assistant add-on: go2rtc master or go2rtc master hardware versions

    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
    
    • by default go2rtc will search go2rtc.yaml in the current work directory
    • api server will start on default 1984 port (TCP)
    • rtsp server will start on default 8554 port (TCP)
    • webrtc will 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

    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
    devices
    • alsa - A framework for receiving audio from devices on Linux OS.
    • v4l2 - A framework for receiving video from devices on Linux OS.
    files
    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

    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.

    • 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.

    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.

    NameFFmpegRTSPAliases
    Advanced Audio CodingaacMPEG4-GENERIC
    Advanced Video Codingh264H264AVC, H.264
    G.711 PCM (A-law)alawPCMAG711A
    G.711 PCM (µ-law)mulawPCMUG711u
    High Efficiency Video CodinghevcH265HEVC, H.265
    Motion JPEGmpjpegJPEG
    MPEG-1 Audio Layer IIImp3MPA
    Opus CodecopusOPUS
    PCM signed 16-bit big-endians16beL16

    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 above
    • rtsp://192.168.1.123:8554/camera1?video=h264&audio=aac&audio=opus - H264 video codec and two separate audio tracks
    • rtsp://192.168.1.123:8554/camera1?video&audio=all - any video codec and all audio codecs as separate tracks
    • http://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 devices
    • http://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.

    DeviceWebRTCMSEHTTP*HLS
    latencybestmediumbadbad
    Desktop Chrome 136+ Desktop Edge Android Chrome 136+H264, H265* PCMU, PCMA OPUSH264, H265* AAC, FLAC* OPUSH264, H265* AAC, FLAC* OPUS, MP3no
    Desktop FirefoxH264 PCMU, PCMA OPUSH264 AAC, FLAC* OPUSH264 AAC, FLAC* OPUSno
    Desktop Safari 14+ iPad Safari 14+ iPhone Safari 17.1+H264, H265* PCMU, PCMA OPUSH264, H265 AAC, FLAC*no!H264, H265 AAC, FLAC*
    iPhone Safari 14+H264, H265* PCMU, PCMA OPUSno!no!H264, H265 AAC, FLAC*
    macOS Hass AppnononoH264, H265 AAC, FLAC*

    Audio

    • go2rtc supports automatic repackaging of PCMA/PCMU/PCM codecs into FLAC for MSE/MP4/HLS so they'll work almost anywhere
    • WebRTC audio codecs: PCMU/8000, PCMA/8000, OPUS/48000/2
    • OPUS and MP3 inside 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 H264 in camera settings
    • this camera supports codecs AAC, PCMU, PCMA for sending audio (from mic), and you select AAC/16000 in 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/2 codec, because it is higher quality than the PCMU/8000 or PCMA/8000

    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
    
    • 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

    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_1 in 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

    read more