### Full go2rtc WebRTC Configuration Example Source: https://github.com/alexxit/go2rtc/blob/master/internal/webrtc/README.md A comprehensive example demonstrating all available WebRTC configuration options, including listen address, candidates, ICE servers, and filters. ```yaml webrtc: # fix local TCP or UDP or both ports for WebRTC media listen: ":8555" # address of your local server # add additional host candidates manually # order is important, the first will have a higher priority candidates: - 216.58.210.174:8555 # if you have static public IP-address - stun:8555 # if you have dynamic public IP-address - home.duckdns.org:8555 # if you have domain # add custom STUN and TURN servers # use `ice_servers: []` to remove defaults and leave it empty ice_servers: - urls: [ stun:stun1.l.google.com:19302 ] - urls: [ turn:123.123.123.123:3478 ] username: your_user credential: your_pass # optional filter list for auto-discovery logic # some settings only make sense if you don't specify a fixed UDP port filters: # list of host candidates from auto-discovery to be sent # includes candidates from the `listen` option # use `candidates: []` to remove all auto-discovery candidates candidates: [ 192.168.1.123 ] # enable localhost candidates loopback: true # list of network types to be used for the connection # includes candidates from the `listen` option networks: [udp4, udp6, tcp4, tcp6 ] # list of interfaces to be used for the connection # includes interfaces from unspecified `listen` option (empty host) interfaces: [ eno1 ] # list of host IP addresses to be used for the connection # includes IPs from unspecified `listen` option (empty host) ips: [ 192.168.1.123 ] # range for random UDP ports [min, max] to be used for connection # not related to the `listen` option udp_ports: [ 50000, 50100 ] ``` -------------------------------- ### Frigate NVR Integration Example Source: https://context7.com/alexxit/go2rtc/llms.txt Configuration snippet for integrating go2rtc streams into Frigate NVR. This example sets up the 'front_door' camera for detection and recording roles. ```yaml # Integration with Frigate NVR # frigate.yml: # cameras: # front_door: # ffmpeg: # inputs: # - path: rtsp://192.168.1.123:8554/front_door?video=h264 # roles: # - detect # - record ``` -------------------------------- ### Satellite Configuration Examples Source: https://github.com/alexxit/go2rtc/blob/master/internal/wyoming/README.md Provides configuration examples for setting up Wyoming satellites in different environments, including Windows, Dahua cameras, and external Wyoming microphones. ```APIDOC ## Config examples Satellite on Windows server using FFmpeg and FFplay. ```yaml streams: satellite_win: - exec:ffmpeg -hide_banner -f dshow -i "audio=Microphone (High Definition Audio Device)" -c pcm_s16le -ar 16000 -ac 1 -f wav - - exec:ffplay -hide_banner -nodisp -probesize 32 -f s16le -ar 22050 -#backchannel=1#audio=s16le/22050 wyoming: satellite_win: listen: :10700 name: "Windows Satellite" wake_uri: tcp://192.168.1.23:10400 vad_threshold: 1 ``` Satellite on Dahua camera with two-way audio support. ```yaml streams: dahua_camera: - rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif wyoming: dahua_camera: listen: :10700 name: "Dahua Satellite" wake_uri: tcp://192.168.1.23:10400 vad_threshold: 1 ``` Satellite on external wyoming Microphone and Sound. ```yaml streams: wyoming_external: - wyoming://192.168.1.23:10600 # wyoming-mic-external - wyoming://192.168.1.23:10601?backchannel=1 # wyoming-snd-external wyoming: wyoming_external: listen: :10700 name: "Wyoming Satellite" wake_uri: tcp://192.168.1.23:10400 vad_threshold: 1 ``` ``` -------------------------------- ### Wyze Configuration Example Source: https://github.com/alexxit/go2rtc/blob/master/internal/wyze/README.md Example YAML configuration for Wyze cameras. Requires user credentials and API keys. The password can be plain text or an MD5 triple-hash prefixed with 'md5:'. ```yaml wyze: user@email.com: api_id: "your-api-id" api_key: "your-api-key" password: "yourpassword" # or MD5 triple-hash with "md5:" prefix streams: wyze_cam: wyze://192.168.1.123?uid=WYZEUID1234567890AB&enr=xxx&mac=AABBCCDDEEFF&model=HL_CAM4&dtls=true ``` -------------------------------- ### Configure HomeKit Server Source: https://github.com/alexxit/go2rtc/blob/master/internal/homekit/README.md Minimal and full configuration examples for exporting streams to Apple HomeKit. ```yaml streams: dahua1: rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0 homekit: dahua1: # same stream ID from streams list, default PIN - 19550224 ``` ```yaml streams: dahua1: - rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0 - ffmpeg:dahua1#video=h264#hardware # if your camera doesn't support H264, important for HomeKit - ffmpeg:dahua1#audio=opus # only OPUS audio supported by HomeKit homekit: dahua1: # same stream ID from streams list pin: 12345678 # custom PIN, default: 19550224 name: Dahua camera # custom camera name, default: generated from stream ID device_id: dahua1 # custom ID, default: generated from stream ID device_private: dahua1 # custom key, default: generated from stream ID ``` -------------------------------- ### Configure go2rtc via command line Source: https://github.com/alexxit/go2rtc/blob/master/internal/app/README.md Examples of passing configuration parameters directly through the command line using various formats. ```bash go2rtc -config "{log: {format: text}}" -config /config/go2rtc.yaml -config "{rtsp: {listen: ''}}" -config /usr/local/go2rtc/go2rtc.yaml ``` ```bash go2rtc -c log.format=text -c /config/go2rtc.yaml -c rtsp.listen='' -c /usr/local/go2rtc/go2rtc.yaml ``` -------------------------------- ### ngrok Configuration Example Source: https://github.com/alexxit/go2rtc/blob/master/internal/ngrok/README.md Example ngrok configuration file (ngrok.yaml) for tunneling both API (HTTP) and WebRTC (TCP) traffic. Supports basic authentication for the web interface. ```yaml version: "2" authtoken: eW91IHNoYWxsIG5vdCBwYXNzCnlvdSBzaGFsbCBub3QgcGFzcw tunnels: api: addr: 1984 # use the same port as in the go2rtc config proto: http basic_auth: - admin:password # you can set login/pass for your web interface webrtc: addr: 8555 # use the same port as in the go2rtc config proto: tcp ``` -------------------------------- ### Preload Streams on Startup Source: https://github.com/alexxit/go2rtc/blob/master/internal/streams/README.md Configure streams to initialize when go2rtc starts to reduce latency for slow-starting cameras. ```yaml preload: camera1: # default: video&audio = ANY camera2: "video" # preload only video track camera3: "video=h264&audio=opus" # preload H264 video and OPUS audio streams: camera1: - rtsp://192.168.1.100/stream camera2: - rtsp://192.168.1.101/stream camera3: - rtsp://192.168.1.102/h265stream - ffmpeg:camera3#video=h264#audio=opus#hardware ``` -------------------------------- ### Run ONVIF Client Command Source: https://github.com/alexxit/go2rtc/blob/master/examples/onvif_client/README.md Executes the ONVIF client example using the go2rtc project structure. Requires a valid URL with credentials and a specific ONVIF method. ```shell go run examples/onvif_client/main.go http://admin:password@192.168.10.90 GetAudioEncoderConfigurations ``` -------------------------------- ### Configure Reolink Camera Streams Source: https://github.com/alexxit/go2rtc/blob/master/internal/rtmp/README.md Example configuration for multiple Reolink camera streams using RTMP. ```yaml streams: rtmp-reolink1: rtmp://192.168.10.92/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=password rtmp-reolink2: rtmp://192.168.10.92/bcs/channel0_sub.bcs?channel=0&stream=1&user=admin&password=password rtmp-reolink3: rtmp://192.168.10.92/bcs/channel0_ext.bcs?channel=0&stream=1&user=admin&password=password ``` -------------------------------- ### Install Python Libraries for go2rtc Source: https://github.com/alexxit/go2rtc/wiki/Source-Echo-examples For Docker and Hass Add-on users, install additional Python libraries to a specific folder using pip. This allows custom scripts to be used as sources. ```bash pip install requests -t /config/echo ``` -------------------------------- ### Example Pinggy Proxy URL in go2rtc Logs Source: https://github.com/alexxit/go2rtc/blob/master/internal/pinggy/README.md This is an example of the output you will see in go2rtc logs when a Pinggy tunnel is successfully established. ```text 16:17:43.167 INF [pinggy] proxy url=tcp://abcde-123-123-123-123.a.free.pinggy.link:12345 ``` -------------------------------- ### Python Script for Echo Source Source: https://context7.com/alexxit/go2rtc/llms.txt Example script to fetch and output a stream URL for the echo source. ```python # /config/scripts/get_stream.py import re import sys from urllib.request import urlopen # Fetch webpage and extract HLS URL html = urlopen("https://example.com/live").read().decode("utf-8") url = re.search(r"https://[^\"]+\.m3u8", html)[0] # Output FFmpeg source command print(f"ffmpeg:{url}#video=copy") ``` -------------------------------- ### go2rtc Configuration Example Source: https://context7.com/alexxit/go2rtc/llms.txt Defines camera streams with multiple input sources, API, RTSP, and WebRTC server configurations. Supports environment variables for sensitive data. ```yaml # yaml-language-server: $schema=https://raw.githubusercontent.com/AlexxIT/go2rtc/master/www/schema.json # Define camera streams with multiple input sources streams: # Simple RTSP camera front_door: rtsp://admin:password@192.168.1.100/cam/realmonitor?channel=1&subtype=0 # Camera with multiple sources for codec negotiation living_room: - rtsp://admin:password@192.168.1.101/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif - ffmpeg:living_room#audio=opus # Add OPUS audio via transcoding # TP-Link Tapo camera with two-way audio garage: tapo://cloud-password@192.168.1.102 # Camera using environment variables for credentials backyard: rtsp://admin:${CAMERA_PASSWORD}@192.168.1.103/stream1 # API server configuration api: listen: ":1984" # HTTP API port username: "admin" # Basic auth username password: "secret" # Basic auth password origin: "*" # Enable CORS # RTSP server configuration rtsp: listen: ":8554" # RTSP server port username: "admin" # RTSP auth (disabled for localhost) password: "pass" default_query: "video&audio" # Default codec filter # WebRTC configuration webrtc: listen: ":8555" # TCP/UDP port for WebRTC candidates: - stun:8555 # Auto-detect public IP via STUN ice_servers: - urls: ["stun:stun.l.google.com:19302"] # Logging configuration log: level: "info" # trace, debug, info, warn, error format: "color" # color, json, text ``` -------------------------------- ### Example RTSP Stream URL via Pinggy Tunnel Source: https://github.com/alexxit/go2rtc/blob/master/internal/pinggy/README.md This is an example of a working RTSP stream URL after configuring a Pinggy tunnel. Use this to access your camera remotely. ```text rtsp://admin:password@abcde-123-123-123-123.a.free.pinggy.link:12345/cam/realmonitor?channel=1&subtype=0 ``` -------------------------------- ### GET /api/homekit/accessories Source: https://context7.com/alexxit/go2rtc/llms.txt Retrieves information about HomeKit accessories. ```APIDOC ## GET /api/homekit/accessories ### Description Retrieves information about HomeKit accessories for a specific device. ### Method GET ### Endpoint /api/homekit/accessories ### Parameters #### Query Parameters - **id** (string) - Required - The ID of the device to retrieve accessories for. ``` -------------------------------- ### Build V4L2 components for multiple architectures Source: https://github.com/alexxit/go2rtc/blob/master/pkg/v4l2/device/README.md Installs cross-compilation toolchains and compiles the source code for various Linux architectures. ```bash sudo apt install gcc-x86-64-linux-gnu sudo apt install gcc-i686-linux-gnu sudo apt install gcc-aarch64-linux-gnu binutils sudo apt install gcc-arm-linux-gnueabihf sudo apt install gcc-mipsel-linux-gnu x86_64-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_x86_64 i686-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_i686 aarch64-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_aarch64 arm-linux-gnueabihf-gcc -w -static videodev2_arch.c -o videodev2_armhf mipsel-linux-gnu-gcc -w -static videodev2_arch.c -o videodev2_mipsel -D_TIME_BITS=32 ``` -------------------------------- ### WebRTC Peer Connection Setup Source: https://github.com/alexxit/go2rtc/blob/master/www/webrtc.html Initializes a WebRTC PeerConnection with specified ICE servers and configures media transceivers for sending and receiving video/audio. Use this to set up the connection for streaming. ```javascript async function PeerConnection(media) { const pc = new RTCPeerConnection({ iceServers: [ {urls: ['stun:stun.cloudflare.com:3478', 'stun:stun.l.google.com:19302']} ] }); const localTracks = [] if (/camera|microphone/.test(media)) { const tracks = await getMediaTracks('user', { video: media.indexOf('camera') >= 0, audio: media.indexOf('microphone') >= 0, }); tracks.forEach(track => { pc.addTransceiver(track, {direction: 'sendonly'}); if (track.kind === 'video') localTracks.push(track); }); } if (media.indexOf('display') >= 0) { const tracks = await getMediaTracks('display', { video: true, audio: media.indexOf('speaker') >= 0, }); tracks.forEach(track => { pc.addTransceiver(track, {direction: 'sendonly'}); if (track.kind === 'video') localTracks.push(track); }); } if (/video|audio/.test(media)) { const tracks = ['video', 'audio'] .filter(kind => media.indexOf(kind) >= 0) .map(kind => pc.addTransceiver(kind, {direction: 'recvonly'}).receiver.track); localTracks.push(...tracks); } document.getElementById('video').srcObject = new MediaStream(localTracks); return pc; } ``` -------------------------------- ### Install go2rtc Docker Image Source: https://github.com/alexxit/go2rtc/blob/master/README.md Use the master build of go2rtc for the latest features. This command pulls the Docker image tagged 'master'. ```docker alexxit/go2rtc:master ``` -------------------------------- ### Define Stream Sources in YAML Source: https://github.com/alexxit/go2rtc/blob/master/internal/streams/README.md Use these examples to define various camera and media sources within the go2rtc configuration file. Ensure credentials and IP addresses are updated to match your specific hardware. ```yaml streams: # known RTSP sources rtsp-dahua1: rtsp://admin:password@192.168.10.90/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif rtsp-dahua2: rtsp://admin:password@192.168.10.90/cam/realmonitor?channel=1&subtype=1 rtsp-tplink1: rtsp://admin:password@192.168.10.91/stream1 rtsp-tplink2: rtsp://admin:password@192.168.10.91/stream2 rtsp-reolink1: rtsp://admin:password@192.168.10.92/h264Preview_01_main rtsp-reolink2: rtsp://admin:password@192.168.10.92/h264Preview_01_sub rtsp-sonoff1: rtsp://admin:password@192.168.10.93/av_stream/ch0 rtsp-sonoff2: rtsp://admin:password@192.168.10.93/av_stream/ch1 # known RTMP sources rtmp-reolink1: rtmp://192.168.10.92/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=password rtmp-reolink2: rtmp://192.168.10.92/bcs/channel0_sub.bcs?channel=0&stream=1&user=admin&password=password rtmp-reolink3: rtmp://192.168.10.92/bcs/channel0_ext.bcs?channel=0&stream=1&user=admin&password=password # known HTTP sources http-reolink1: http://192.168.10.92/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=password http-reolink2: http://192.168.10.92/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=admin&password=password http-reolink3: http://192.168.10.92/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=password # known ONVIF sources onvif-dahua1: onvif://admin:password@192.168.10.90?subtype=MediaProfile00000 onvif-dahua2: onvif://admin:password@192.168.10.90?subtype=MediaProfile00001 onvif-dahua3: onvif://admin:password@192.168.10.90?subtype=MediaProfile00000&snapshot onvif-tplink1: onvif://admin:password@192.168.10.91:2020?subtype=profile_1 onvif-tplink2: onvif://admin:password@192.168.10.91:2020?subtype=profile_2 onvif-reolink1: onvif://admin:password@192.168.10.92:8000?subtype=000 onvif-reolink2: onvif://admin:password@192.168.10.92:8000?subtype=001 onvif-reolink3: onvif://admin:password@192.168.10.92:8000?subtype=000&snapshot onvif-openipc1: onvif://admin:password@192.168.10.95:80?subtype=PROFILE_000 onvif-openipc2: onvif://admin:password@192.168.10.95:80?subtype=PROFILE_001 # some EXEC examples exec-h264-pipe: exec:ffmpeg -re -i bbb.mp4 -c copy -f h264 - exec-flv-pipe: exec:ffmpeg -re -i bbb.mp4 -c copy -f flv - exec-mpegts-pipe: exec:ffmpeg -re -i bbb.mp4 -c copy -f mpegts - exec-adts-pipe: exec:ffmpeg -re -i bbb.mp4 -c copy -f adts - exec-mjpeg-pipe: exec:ffmpeg -re -i bbb.mp4 -c mjpeg -f mjpeg - exec-hevc-pipe: exec:ffmpeg -re -i bbb.mp4 -c libx265 -preset superfast -tune zerolatency -f hevc - exec-wav-pipe: exec:ffmpeg -re -i bbb.mp4 -c pcm_alaw -ar 8000 -ac 1 -f wav - exec-y4m-pipe: exec:ffmpeg -re -i bbb.mp4 -c rawvideo -f yuv4mpegpipe - exec-pcma-pipe: exec:ffmpeg -re -i numb.mp3 -c:a pcm_alaw -ar:a 8000 -ac:a 1 -f wav - exec-pcmu-pipe: exec:ffmpeg -re -i numb.mp3 -c:a pcm_mulaw -ar:a 8000 -ac:a 1 -f wav - exec-s16le-pipe: exec:ffmpeg -re -i numb.mp3 -c:a pcm_s16le -ar:a 16000 -ac:a 1 -f wav - # some FFmpeg examples ffmpeg-video-h264: ffmpeg:virtual?video#video=h264 ffmpeg-video-4K: ffmpeg:virtual?video&size=4K#video=h264 ffmpeg-video-10s: ffmpeg:virtual?video&duration=10#video=h264 ffmpeg-video-src2: ffmpeg:virtual?video=testsrc2&size=2K#video=h264 ``` -------------------------------- ### Configure WebRTC Cameras from Home Assistant Source: https://github.com/alexxit/go2rtc/blob/master/internal/hass/README.md Import WebRTC camera streams from Home Assistant. Note that the Nest API provides stream links valid for only 5 minutes. Avoid using this with Frigate due to potential memory issues if streams expire. The 'hass-webrtc1' example links to a Home Assistant Supervised instance, while 'hass-webrtc2' uses an external instance with a Long-Lived Access Token. ```yaml streams: # link to Home Assistant Supervised hass-webrtc1: hass://supervisor?entity_id=camera.nest_doorbell # link to external Home Assistant with Long-Lived Access Tokens hass-webrtc2: hass://192.168.1.123:8123?entity_id=camera.nest_doorbell&token=eyXYZ... ``` -------------------------------- ### Generate HomeKit QR Code Source: https://github.com/alexxit/go2rtc/blob/master/www/links.html This script fetches HomeKit setup information and generates a QR code for easy pairing. It requires the qrcodejs library and dynamically adds it to the document. ```javascript fetch(`api/homekit?id=${src}`, {cache: 'no-cache'}).then(async (r) => { if (!r.ok) return; const div = document.querySelector('#homekit'); div.innerHTML += `
Setup Name: ${data.name} Setup Code: ${data.setup_code} `;
/* global QRCode */
new QRCode('homekit-qrcode', {text: setupURI, width: 128, height: 128});
};
document.head.appendChild(script);
});
```
--------------------------------
### Stream ASCII to Terminal
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mjpeg/README.md
Examples of using curl to stream camera feeds as ASCII art with various styling parameters.
```bash
% curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda"
% curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&color=256"
% curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&back=256&text=%20"
% curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&back=8&text=%20%20"
% curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&text=helloworld"
```
--------------------------------
### Install go2rtc Docker Image with Hardware Acceleration
Source: https://github.com/alexxit/go2rtc/blob/master/README.md
Use the master build of go2rtc with hardware acceleration support. This command pulls the Docker image tagged 'master-hardware'.
```docker
alexxit/go2rtc:master-hardware
```
--------------------------------
### Add go2rtc Repository to Home Assistant
Source: https://github.com/alexxit/go2rtc/blob/master/README.md
Add the go2rtc add-on repository to your Home Assistant supervisor. This is the first step to installing the go2rtc add-on.
```yaml
https://github.com/AlexxIT/hassio-addons
```
--------------------------------
### Wyze Resolution Configuration
Source: https://github.com/alexxit/go2rtc/blob/master/internal/wyze/README.md
Examples demonstrating how to configure Wyze camera resolution using the 'subtype' parameter in the stream URL. Use 'subtype=hd' for high definition or 'subtype=sd' for standard definition.
```yaml
streams:
wyze_hd: wyze://...&subtype=hd
wyze_sd: wyze://...&subtype=sd
```
--------------------------------
### Get MP4 Snapshot from Camera
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mp4/README.md
Use this API endpoint to get a single frame snapshot in MP4 format from a camera stream. Supports H264 and H265 codecs.
```HTTP
http://192.168.1.123:1984/api/frame.mp4?src=camera1
```
--------------------------------
### Configure ICE Servers (STUN/TURN)
Source: https://github.com/alexxit/go2rtc/blob/master/internal/webrtc/README.md
Add custom STUN and TURN servers to the configuration. Use 'ice_servers: []' to remove defaults.
```yaml
webrtc:
ice_servers:
- urls: [stun:stun.l.google.com:19302]
- urls: [turn:123.123.123.123:3478]
username: your_user
credential: your_pass
```
--------------------------------
### Initiate Media Connection
Source: https://github.com/alexxit/go2rtc/blob/master/www/webrtc.html
Parses the 'media' query parameter from the URL and initiates the connection using the connect function. Defaults to 'video+audio' if no parameter is provided.
```javascript
const media = new URLSearchParams(location.search).get('media');
connect(media || 'video+audio');
```
--------------------------------
### Get MP4 Stream from Camera
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mp4/README.md
Use this API endpoint to get a progressive MP4 stream from a camera. Supports H264, H265, and AAC codecs. For unsupported browsers, it redirects to HLS/fMP4.
```HTTP
http://192.168.1.123:1984/api/stream.mp4?src=camera1
```
--------------------------------
### Execute Development and Build Commands
Source: https://github.com/alexxit/go2rtc/blob/master/scripts/README.md
Run these commands to manage Go modules, inspect dependencies, and analyze binary size.
```bash
go get -u
go mod tidy
go mod why github.com/pion/rtcp
go list -deps .\cmd\go2rtc_rtsp\
./goweight
```
--------------------------------
### GET /api/frame.{format}
Source: https://github.com/alexxit/go2rtc/blob/master/pkg/README.md
Endpoints for capturing snapshots from a stream.
```APIDOC
## GET /api/frame.{format}
### Description
Captures a single frame or snapshot from the stream in the specified format.
### Method
GET
### Endpoint
/api/frame.{format}
### Parameters
#### Path Parameters
- **format** (string) - Required - The snapshot format (jpeg, mp4).
```
--------------------------------
### Manage Configuration via API
Source: https://context7.com/alexxit/go2rtc/llms.txt
Retrieve, replace, or merge configuration settings using the HTTP API.
```bash
# Get current configuration
curl http://localhost:1984/api/config
# Replace entire configuration
curl -X POST http://localhost:1984/api/config \
-H "Content-Type: application/yaml" \
-d '
streams:
camera1: rtsp://admin:pass@192.168.1.100/stream
api:
listen: ":1984"
'
# Merge changes into existing config
curl -X PATCH http://localhost:1984/api/config \
-H "Content-Type: application/yaml" \
-d '
streams:
camera2: rtsp://admin:pass@192.168.1.101/stream
'
# Get JSON schema for config validation
curl http://localhost:1984/schema.json
```
--------------------------------
### GET /api/frame.jpeg
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mjpeg/README.md
Retrieve a single JPEG snapshot from a stream.
```APIDOC
## GET /api/frame.jpeg
### Description
Receiving a JPEG snapshot from the specified stream.
### Method
GET
### Endpoint
/api/frame.jpeg
### Parameters
#### Query Parameters
- **src** (string) - Required - The name of the stream source.
- **width** / **w** (integer) - Optional - Width of the snapshot.
- **height** / **h** (integer) - Optional - Height of the snapshot.
- **rotate** (integer) - Optional - Rotation angle (90, 180, 270, -90).
- **hardware** / **hw** (boolean) - Optional - Use hardware acceleration.
- **cache** (string) - Optional - Cache duration (e.g., 1m, 10s).
```
--------------------------------
### Initialize WebTorrent Sources
Source: https://github.com/alexxit/go2rtc/blob/master/www/add.html
Triggers the loading of WebTorrent sources into the specified table element upon user interaction.
```javascript
document.getElementById('webtorrent').addEventListener('click', async ev => { ev.target.nextElementSibling.style.display = 'grid'; await getSources('webtorrent-table', 'api/webtorrent'); });
```
--------------------------------
### GET /api/stream.mjpeg
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mjpeg/README.md
Output a video stream in MJPEG format.
```APIDOC
## GET /api/stream.mjpeg
### Description
Output a stream in MJPEG format.
### Method
GET
### Endpoint
/api/stream.mjpeg
### Parameters
#### Query Parameters
- **src** (string) - Required - The name of the stream source defined in go2rtc configuration.
```
--------------------------------
### GET /api/stream.y4m
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mjpeg/README.md
Output a raw YUV frame stream with YUV4MPEG header.
```APIDOC
## GET /api/stream.y4m
### Description
Output a raw YUV frame stream with YUV4MPEG header.
### Method
GET
### Endpoint
/api/stream.y4m
### Parameters
#### Query Parameters
- **src** (string) - Required - The name of the stream source.
```
--------------------------------
### List Project Dependencies
Source: https://github.com/alexxit/go2rtc/blob/master/scripts/README.md
A hierarchical list of third-party Go packages used by the project.
```text
- gopkg.in/yaml.v3
- github.com/kr/pretty
- github.com/AlexxIT/go2rtc/pkg/hap
- github.com/tadglines/go-pkgs
- golang.org/x/crypto
- github.com/AlexxIT/go2rtc/pkg/mdns
- github.com/miekg/dns
- github.com/AlexxIT/go2rtc/pkg/pcm
- github.com/sigurn/crc16
- github.com/sigurn/crc8
- github.com/pion/ice/v2
- github.com/google/uuid
- github.com/wlynxg/anet
- github.com/rs/zerolog
- github.com/mattn/go-colorable
- github.com/mattn/go-isatty
- github.com/stretchr/testify
- github.com/davecgh/go-spew
- github.com/pmezard/go-difflib
- ???
- golang.org/x/mod
- golang.org/x/net
- golang.org/x/sys
- golang.org/x/tools
```
--------------------------------
### GET /api/stream.ascii
Source: https://github.com/alexxit/go2rtc/blob/master/internal/mjpeg/README.md
Stream a camera feed as animated ASCII art to the terminal.
```APIDOC
## GET /api/stream.ascii
### Description
Stream a camera feed as ASCII art to the terminal. Requires MJPEG codec.
### Method
GET
### Endpoint
/api/stream.ascii
### Parameters
#### Query Parameters
- **src** (string) - Required - The name of the stream source.
- **color** (string) - Optional - Foreground color (8, 256, rgb, or SGR code).
- **back** (string) - Optional - Background color (8, 256, rgb, or SGR code).
- **text** (string) - Optional - Character set (one character, 'block', or list of chars).
```
--------------------------------
### Initialize YAML Linting and Completion
Source: https://github.com/alexxit/go2rtc/blob/master/www/config.html
Sets up the schema tools, registers the completion provider, and schedules linting tasks based on model content changes.
```javascript
emaTools.getPropertySchema(ctx.schema, kv.key) : null; if (kv.isContainer) { stack.push({ indent: kv.indent, schema: propSchema, expected: getExpectedContainerType(propSchema), actual: null, keys: new Map(), childIndent: null, origin: {lineNumber, startColumn: kv.keyStartIndex + 1, endColumn: kv.keyEndIndex + 1}, reportedTypeMismatch: false, }); continue; } if (isBlockScalarHeader(kv.after)) { blockScalarParentIndent = kv.indent; } if (!propSchema) continue; const actual = classifyYamlScalar(kv.after).type; const valueStartColumn = kv.valueStartIndex + 1 + (kv.after.length - kv.after.trimStart().length); checkValueType(propSchema, actual, lineNumber, valueStartColumn, line.length + 1, kv.key); checkValueConstraints(propSchema, actual, kv.after, lineNumber, valueStartColumn, line.length + 1, kv.key); } return markers; }; let schemaTools = null; let completionProvider = null; let hoverProvider = null; const scheduleLint = (() => { let handle = null; return () => { if (handle) clearTimeout(handle); handle = setTimeout(() => { const model = editor.getModel(); if (!model) return; monaco.editor.setModelMarkers(model, 'yaml-lint', lintYamlModel(model, schemaTools)); }, 250); }; })(); editor.onDidChangeModelContent(() => scheduleLint()); const setupYamlHints = (schemaRoot) => { schemaTools = createSchemaTools(schemaRoot); scheduleLint(); const { resolveRef, getObjectProperties, getPropertySchema, getValueSuggestions, } = schemaTools; const buildContextStack = (model, upToLineNumber) => { const stack = [{indent: -1, schema: schemaRoot}]; for (let lineNumber = 1; lineNumber <= upToLineNumber; lineNumber++) { let line = model.getLineContent(lineNumber); if (!line.trim()) continue; line = stripInlineComment(line).trimEnd(); if (!line.trim()) continue; const listItem = parseListItem(line); if (listItem) { while (stack.length > 1 && listItem.indent <= stack[stack.length - 1].indent) stack.pop(); const parent = resolveRef(stack[stack.length - 1].schema); if (parent && parent.type === 'array' && parent.items) { stack.push({indent: listItem.indent, schema: resolveRef(parent.items)}); } else { stack.push({indent: listItem.indent, schema: null}); } const inline = listItem.rest ? parseKey(' '.repeat(listItem.contentIndent) + listItem.rest) : null; if (inline && inline.isContainer) { while (stack.length > 1 && inline.indent <= stack[stack.length - 1].indent) stack.pop(); const ctx = resolveRef(stack[stack.length - 1].schema); const next = ctx ? getPropertySchema(ctx, inline.key) : null; stack.push({indent: inline.indent, schema: next}); } continue; } const kv = parseKey(line); if (!kv) continue; while (stack.length > 1 && kv.indent <= stack[stack.length - 1].indent) stack.pop(); if (!kv.isContainer) continue; const ctx = resolveRef(stack[stack.length - 1].schema); const next = ctx ? getPropertySchema(ctx, kv.key) : null; stack.push({indent: kv.indent, schema: next}); } return stack; }; if (completionProvider) completionProvider.dispose(); completionProvider = monaco.languages.registerCompletionItemProvider('yaml', { triggerCharacters: [':', ' '], provideCompletionItems: (model, position) => { const line = model.getLineContent(position.lineNumber); const lineNoComment = stripInlineComment(line); const lineNoCommentTrimmedEnd = lineNoComment.trimEnd(); const listItem = parseListItem(lineNoCommentTrimmedEnd); const wordUntil = model.getWordUntilPosition(position); const range = new monaco.Range(position.lineNumber, wordUntil.startColumn, position.lineNumber, wordUntil.endColumn); const cursorIndex = position.column - 1; let contentStartIndex = 0; if (listItem) { contentStartIndex = listItem.afterDashIndex; } else { contentStartIndex = countIndent(lineNoComment); } if (cursorIndex < contentStartIndex) return {suggestions: []}; const text = lineNoCommentTrimmedEnd.slice(contentStartIndex); const cursorInText = cursorIndex - contentStartIndex; const colonIndex = text.indexOf(':'); const isValueContext = colonIndex >= 0 && cursorInText > colonIndex; const stack = buildContextStack(model, position.lineNumber - 1); const effectiveIndent = listItem ? listItem.contentIndent : countIndent(lineNoComment); while (stack.length > 1 && effectiveIndent <= stack[stack.length - 1].indent) stack.pop(); let contextSchema = resolveRef(stack[stack.length - 1].schema); if (listItem && cursorIndex >= listItem.afterDashIndex && contextSchema && contextSchema.type === 'array') { contextSchema = resolveRef(contextSchema.items); } if (!contextSchema) return {suggestions: []}; // Scalar array item (e.g. "- tcp4") - suggest values (enum/examples/default) if (listItem && colonIndex === -1 && !isValueContext) { const props = getObjectProperties(contextSchema); if (!props || Object.keys(props).length === 0) { const values = getValueSuggestions(contextSchema); const suggestions = values.map((v) => ({ label: toYamlScalar(v), kind: monaco.languages.CompletionItemKind.Value, insertText: toYamlScalar(v), range, })); return {suggestions}; } } i
```
--------------------------------
### GET /api/frame.jpeg
Source: https://context7.com/alexxit/go2rtc/llms.txt
Capture still JPEG images from a stream with optional resizing and rotation.
```APIDOC
## GET /api/frame.jpeg
### Description
Capture still images from streams. Requires MJPEG codec in the stream.
### Method
GET
### Endpoint
/api/frame.jpeg
### Parameters
#### Query Parameters
- **src** (string) - Required - The name of the stream source.
- **width** (integer) - Optional - Resize width.
- **height** (integer) - Optional - Resize height.
- **rotate** (integer) - Optional - Rotation in degrees.
- **hardware** (string) - Optional - Hardware acceleration type (e.g., vaapi).
```
--------------------------------
### Deploy go2rtc with GPU Acceleration
Source: https://github.com/alexxit/go2rtc/blob/master/docker/README.md
Use the hardware-specific image and the --gpus flag to enable GPU transcoding support.
```bash
docker run -d \
--name go2rtc \
--network host \
--privileged \
--restart unless-stopped \
-e TZ=Atlantic/Bermuda \
--gpus all \
-v ~/go2rtc:/config \
alexxit/go2rtc:latest-hardware
```
--------------------------------
### GET /api/stream.mp4
Source: https://context7.com/alexxit/go2rtc/llms.txt
Stream video in MP4 progressive format with optional codec filtering and transformations.
```APIDOC
## GET /api/stream.mp4
### Description
Get streams in MP4 progressive format for broad compatibility with players and recording software.
### Method
GET
### Endpoint
/api/stream.mp4
### Parameters
#### Query Parameters
- **src** (string) - Required - The name of the stream source.
- **video** (string) - Optional - Codec filter for video (e.g., h264).
- **audio** (string) - Optional - Codec filter for audio (e.g., aac).
- **mp4** (string) - Optional - Specific codec for MP4 container.
- **duration** (integer) - Optional - Duration in seconds for recording.
- **filename** (string) - Optional - Filename for the output file.
- **rotate** (integer) - Optional - Rotation in degrees.
- **scale** (string) - Optional - Resolution scale (e.g., 1280:720).
```
--------------------------------
### GET /api/stream.{format}
Source: https://github.com/alexxit/go2rtc/blob/master/pkg/README.md
Endpoints for consuming media streams via HTTP in various formats.
```APIDOC
## GET /api/stream.{format}
### Description
Retrieves a media stream in the specified format via HTTP.
### Method
GET
### Endpoint
/api/stream.{format}
### Parameters
#### Path Parameters
- **format** (string) - Required - The desired output format (e.g., adts, ascii, flv, m3u8, mjpeg, mp4, ts, y4m).
#### Query Parameters
- **mp4** (boolean) - Optional - Used with m3u8 to request fmp4 format.
```
--------------------------------
### Configure HomeKit Camera Client
Source: https://github.com/alexxit/go2rtc/blob/master/internal/homekit/README.md
Recommended stream configuration for using a HomeKit camera with WebRTC, MSE, MP4, or RTSP.
```yaml
streams:
aqara_g3:
- hass:Camera-Hub-G3-AB12
- ffmpeg:aqara_g3#audio=aac#audio=opus
```
--------------------------------
### Configure Exec Sources
Source: https://context7.com/alexxit/go2rtc/llms.txt
Integrate external applications like GStreamer or camera tools to pipe video data into go2rtc.
```yaml
streams:
# Raspberry Pi camera (pipe output)
picam: exec:libcamera-vid -t 0 --inline -o -
# Raspberry Pi 5 camera
pi5cam: exec:libcamera-vid -t 0 --libav-format h264 -o -
# Raspberry Pi MJPEG
picam_mjpeg: exec:libcamera-vid -t 0 --codec mjpeg -o -
# GStreamer pipeline
gst_cam: exec:gst-launch-1.0 videotestsrc ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5000
# Canon camera via gphoto2
canon: exec:gphoto2 --capture-movie --stdout#killsignal=2#killtimeout=5
# FFmpeg to RTSP (uses {output} placeholder)
ffmpeg_rtsp: exec:ffmpeg -re -i /media/video.mp4 -c copy -rtsp_transport tcp -f rtsp {output}
# Two-way audio with ffplay (backchannel)
two_way:
- exec:ffmpeg -f alsa -i hw:0 -c pcm_alaw -ar 8000 -ac 1 -f wav -
- exec:ffplay -nodisp -f alaw -ar 8000 -#backchannel=1
```
--------------------------------
### Configure RTSP Server
Source: https://github.com/alexxit/go2rtc/blob/master/internal/rtsp/README.md
Set up the RTSP server listener, optional authentication, and default track filtering for outgoing streams.
```yaml
rtsp:
listen: ":8554" # RTSP Server TCP port, default - 8554
username: "admin" # optional, default - disabled
password: "pass" # optional, default - disabled
default_query: "video&audio" # optional, default codecs filters
```
--------------------------------
### Ngrok tunnel output
Source: https://github.com/alexxit/go2rtc/wiki/Tunnel-RTSP-camera-to-Intenet
Example output showing the public address mapped to the local camera stream.
```text
tcp://0.tcp.eu.ngrok.io:11465 -> 192.168.1.123:554
```
--------------------------------
### Play Sound File on Wake Word
Source: https://github.com/alexxit/go2rtc/blob/master/internal/wyoming/README.md
Example of playing a local wav file when a wake word is detected.
```yaml
wyoming:
script_example:
event:
internal-detection: PlayFile('/media/beep.wav') && WriteEvent("run-pipeline", '{"start_stage":"asr","end_stage":"tts"}') && Stream()
```
--------------------------------
### Configure logging levels and format
Source: https://github.com/alexxit/go2rtc/blob/master/internal/app/README.md
Set global log formatting and specific log levels for individual modules.
```yaml
log:
format: "" # empty (default, autodetect color support), color, json, text
level: "info" # disabled, trace, debug, info (default), warn, error
output: "stdout" # empty (only to memory), stderr, stdout (default)
time: "UNIXMS" # empty (disable timestamp), UNIXMS (default), UNIXMICRO, UNIXNANO
api: trace # module name: log level
```
--------------------------------
### Get MP4 Snapshot
Source: https://context7.com/alexxit/go2rtc/llms.txt
Obtains an MP4 snapshot containing a single keyframe. This format is compatible with H264/H265 codecs.
```bash
curl "http://localhost:1984/api/frame.mp4?src=front_door" -o snapshot.mp4
```
```bash
curl "http://localhost:1984/api/frame.mp4?src=front_door&filename=doorbell.mp4" -o doorbell.mp4
```