Compare commits

...

337 Commits

Author SHA1 Message Date
Sergey Krashevich 1fc40aa7db Quote host names in DOT output
Wrap host identifiers with quotes when generating Graphviz DOT to avoid invalid identifiers if hostnames contain punctuation or spaces. Updated node declaration and both producer/consumer edges to use %q for host formatting in internal/streams/dot.go; other fields (IDs, labels, titles) remain unchanged.
2026-03-21 16:19:38 +03:00
Alex X dc1685e9cf Merge pull request #2159 from ludufre/fix/mpegts-pcma-pcmu-probe
Add support PCMATapo for MPEG-TS source
2026-03-17 17:29:03 +03:00
Luan Freitas 65af579770 fix: remove PCMU, keep only PCMA (always 8000 Hz per G.711 spec) 2026-03-17 10:27:23 -03:00
Luan Freitas d9af354de8 fix: add PCMU to StreamType() mapping 2026-03-16 20:23:01 -03:00
Luan Freitas 31c19a0e7d fix: incoming pcma and pcmu 2026-03-16 18:33:01 -03:00
Alex X 01c7451556 Restore fix audio sample rate for some xiaomi cameras #2006 2026-02-13 10:59:38 +03:00
Alex X f68c602a7d Add sitemap to website 2026-02-08 14:00:55 +03:00
Alex X 7f36033bff Merge pull request #2080 from skrashevich/260208-fix-grammar
Fix documentation grammar
2026-02-08 13:04:29 +03:00
Sergey Krashevich 6304987a26 Review uncommitted changes 2026-02-08 08:50:18 +03:00
Alex X 2735bafd86 Rename mpegts module to mpeg 2026-02-08 07:10:30 +03:00
Alex X 44f6f111c4 Move kasa source to separate module 2026-02-08 07:01:14 +03:00
Alex X e5bb03349b Add support pet feeder to xiaomi source #2078 2026-02-07 16:14:10 +03:00
Alex X e90f159c68 Add meta info to website 2026-02-07 13:19:11 +03:00
Alex X be4b6c3271 Update docs 2026-02-07 09:12:31 +03:00
Alex X f3ad4ad977 Fix links in docs 2026-02-07 00:08:47 +03:00
Alex X 7083afe9b2 Merge pull request #2044 from skrashevich/documentation-site
(website): new documentation site
2026-02-06 21:49:35 +03:00
Alex X d01b99d105 BIG docs refactoring 2026-02-06 21:45:55 +03:00
Alex X d1d7846aed Merge pull request #2064 from jmelancondev/webrtc/ice-server-urls-list
webrtc: Fix ice_servers parsing for a list of URLs
2026-02-03 13:42:13 +03:00
Alex X 8d58cc7f97 Merge pull request #2065 from skrashevich/260201-small-fixes
Fix error handling in stream creation and patching tests
2026-02-03 13:15:16 +03:00
Sergey Krashevich f1d61bf15a fix: handle errors in stream creation and patching in tests 2026-02-01 04:18:04 +03:00
José Mélançon d2c4e44844 webrtc: Fix ice_servers parsing for a list of URLs 2026-01-31 14:25:13 -05:00
Sergey Krashevich 5bf5327a45 Merge branch 'AlexxIT:master' into documentation-site 2026-01-29 00:38:10 +03:00
Sergey Krashevich 4bf0aef124 Merge branch 'documentation-site' of https://github.com/skrashevich/go2rtc into documentation-site 2026-01-26 17:06:11 +03:00
Sergey Krashevich 8e01d5cfa9 🔧 chore(gh-pages): change default branch for deployment 2026-01-26 17:05:55 +03:00
Alex X 6085c8aabe Merge pull request #2058 from skrashevich/260126-fix-spelling
📝 docs(README): update documentation for clarity and accuracy
2026-01-26 11:23:35 +03:00
Sergey Krashevich 8d4869fd08 Merge branch 'AlexxIT:master' into documentation-site 2026-01-26 04:22:35 +03:00
Sergey Krashevich 5970dd2fe4 📝 docs(README): update documentation for clarity and accuracy 2026-01-26 00:40:48 +03:00
Alex X a41185c22a Merge pull request #2054 from jeis4wpi/master
Propose fix a couple of typos
2026-01-25 21:41:31 +03:00
Alex X c793855800 Merge pull request #2056 from martinbjeldbak/patch-1
docs: fix link to updated JSONSchema
2026-01-25 14:46:33 +03:00
Martin Bjeldbak Madsen a556bca7bd docs: fix link to updated JSONSchema 2026-01-25 19:57:58 +11:00
John E 051aa664cd Propose fix a couple of typos
Signed-off-by: John E <jeis4wpi@outlook.com>
2026-01-23 17:17:53 -05:00
Alex X 6374366da5 Add support xiaomi isa.camera.df3 on old firmwares 2026-01-21 22:26:16 +03:00
Alex X de157eb144 Strip Userinfo from log entries and errors #2051 2026-01-21 17:15:36 +03:00
Sergey Krashevich 72ec880300 Merge branch 'AlexxIT:master' into documentation-site 2026-01-21 15:56:17 +03:00
Alex X 6eeba1ae4c Merge pull request #1720 from felipecrs/update-readme
Update README
2026-01-21 07:23:37 +03:00
Alex X 8f68f80bff Add support xiaomi chuangmi.camera.ipc019e 2026-01-20 20:51:40 +03:00
Alex X 2f9d138692 Fix zero channel for xiaomi source #2047 2026-01-20 17:05:14 +03:00
Alex X 366cbd200d Fix unknown msg 0xF0 for cs2 proto 2026-01-20 14:24:27 +03:00
Alex X 6f75b2f75e Add trace log for xiaomi devices list 2026-01-20 14:19:51 +03:00
Alex X 75bd1f1b2b Improve packet loss on old TUTK proto 2026-01-20 14:19:18 +03:00
Alex X 7793a55853 Add support xiaomi lumi.camera.gwagl01 2026-01-20 14:18:03 +03:00
Alex X 06cbbe5543 Add support xiaomi isa.camera.isc5c1 2026-01-19 21:55:07 +03:00
Felipe Santos 861bc9728b Fix some other markdownlint violations 2026-01-19 14:24:59 -03:00
Felipe Santos ae0646ea9e Remove outdated section about Tuya cameras 2026-01-19 14:16:12 -03:00
Felipe Santos c8412eb067 Merge branch 'master' of https://github.com/AlexxIT/go2rtc into update-readme 2026-01-19 14:12:00 -03:00
Alex X a37fdf38d8 Add support xiaomi chuangmi.camera.v2 on old firmwares 2026-01-19 18:17:38 +03:00
Alex X b5948cfb25 Update version to 1.9.14 2026-01-19 11:59:09 +03:00
Alex X c64fcc55a5 Update dependencies 2026-01-19 11:28:09 +03:00
Sergey Krashevich ba9fb70929 feat(vitepress): enhance title extraction from files
📝 docs(ffmpeg): add title to ffmpeg README
2026-01-19 02:40:02 +03:00
Sergey Krashevich 1d9bb27f58 Update GitHub Pages workflow to use website directory
The workflow now copies built docs into the 'website' directory using rsync and uploads 'website' as the artifact instead of '.vitepress/dist'. This allows for additional processing or customization of the deployment directory.
2026-01-19 02:07:23 +03:00
Sergey Krashevich 55c1f5890b Refactor GitHub Pages workflow to separate build and deploy
Split the workflow into distinct 'build' and 'deploy' jobs. The build job handles checkout, install, and documentation build steps, while the deploy job depends on build and manages deployment to GitHub Pages. This improves workflow clarity and separation of concerns.
2026-01-19 01:53:55 +03:00
Sergey Krashevich d98059f069 Add VitePress documentation site setup
Introduces VitePress configuration and theme files for documentation, updates the GitHub Pages workflow to build and deploy the new docs, and updates .gitignore for VitePress and Node artifacts. Adds necessary dependencies and scripts to package.json, and updates the ONVIF client example README title.
2026-01-19 01:35:31 +03:00
Alex X fc22b20896 Fix ONVIF server support for Unifi Protect #1994 2026-01-18 22:47:04 +03:00
Alex X af819952e8 Improve ONVIF server support #1299 2026-01-18 21:51:05 +03:00
Alex X 159fb4675c Add starttimeout setting to exec source #1846 2026-01-18 16:07:46 +03:00
Alex X 54eafe9d0a Skip snapshot caching in case of error 2026-01-18 15:48:56 +03:00
Sergey Krashevich 38cc05c22d feat(jpeg): Add keyframe caching with expiration mechanism to JPEG http handler (#1155)
* feat(mjpeg): add keyframe caching with expiration and cleanup goroutine

* mjpeg: make keyframe cache duration and default usage configurable

* mjpeg: document and add config options for MJPEG snapshot caching

* mjpeg: fix errors after rebase

* Code refactoring for frame.jpeg cache #1155

---------

Co-authored-by: Alex X <alexey.khit@gmail.com>
2026-01-18 14:23:50 +03:00
Alex X 8c457710bd Merge pull request #2011 from seydx/wyze
Native Wyze camera support
2026-01-18 08:39:37 +03:00
Alex X 514188201a Move tutk dtls to separate package #2011 2026-01-18 08:38:38 +03:00
Alex X b65ee278cd Merge pull request #1991 from FIGIO55/onvif_info
Adding onvif name and hardware in info field of onvif discovery
2026-01-18 07:55:20 +03:00
Alex X 66225973ae Code refactoring for onvif device discovery #1991 2026-01-18 07:54:48 +03:00
seydx d40f6064d9 refactor dtls 2026-01-17 23:28:03 +01:00
seydx 9365fef7b3 move HL extraction to wyze client 2026-01-17 22:44:09 +01:00
seydx b220959e41 cleanup 2026-01-17 22:12:36 +01:00
seydx c493087876 fix intercom 2026-01-17 20:50:57 +01:00
seydx af90b4c12c update readme 2026-01-17 20:31:25 +01:00
seydx 679454aedb Merge branch 'master' into wyze 2026-01-17 20:31:05 +01:00
seydx 160695857e refactor 2026-01-17 20:22:08 +01:00
Alex X 6a5deecfcc Add multitrans source to readme 2026-01-17 21:53:37 +03:00
forrestsocool 572f07fcce Add two-way talk support for tp-link ipc camera (#1995)
* add tplink multitrans support

* 已经能成功播放音频了

* 初步能通讯了

* finish

* add tplink multitrans support

* 已经能成功播放音频了

* 初步能通讯了

* cleanup

* clean up

* Code refactoring for #1995

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Alex X <alexey.khit@gmail.com>
2026-01-17 21:39:49 +03:00
Aram Akhavan 9d1e4b11d7 Add EXPOSE to Dockerfile (#2010)
* Expose ports 1984 and 8554 in Dockerfile

* Update Dockerfile

* Update hardware.Dockerfile

* Expose additional ports in Rockchip Dockerfile

* Move docker expose ports to single line

---------

Co-authored-by: Alex X <alexey.khit@gmail.com>
2026-01-17 19:14:07 +03:00
Alex X f85cfdc214 Merge pull request #2019 from binary-person/patch-1
fix typo for inability to set channels for backchannel
2026-01-17 19:06:00 +03:00
Alex X 5780bf3720 Merge pull request #2023 from oeiber/patch-1
Update README with Doorbird support details
2026-01-17 18:41:28 +03:00
Alex X 338a3a6f03 Move doorbird docs to separate file 2026-01-17 18:40:18 +03:00
Alex X 6796bdabe2 Change header levels in readme 2026-01-17 18:30:06 +03:00
Alex X ebe454e3be Fix relative links in readme 2026-01-17 18:24:24 +03:00
seydx c03cd9f156 minor improvements 2026-01-17 12:09:38 +01:00
Alex X 1ec40f2fc3 Move schema.json to www/static 2026-01-17 13:57:05 +03:00
Alex X 790fdfbf7a Remove unnecessary codecs.html 2026-01-17 13:56:40 +03:00
Alex X 6d77b175d8 Move all JS libs to cdn.jsdelivr.net 2026-01-17 13:47:21 +03:00
seydx 8e6b8b32d6 Merge branch 'AlexxIT:master' into wyze 2026-01-17 09:40:49 +01:00
Alex X 425fcffbe1 Code refactoring for xiaomi source 2026-01-17 10:06:13 +03:00
Alex X 9a1eac8ef4 Add cache to xiaomi cloud logins 2026-01-17 09:41:41 +03:00
Alex X 4ffdeb06d0 Merge branch 'xiaomi'
# Conflicts:
#	pkg/xiaomi/miss/client.go
#	pkg/xiaomi/miss/cs2/conn.go
#	pkg/xiaomi/producer.go
2026-01-17 09:23:23 +03:00
Alex X 6b4eb8ffb6 Big rewrite tutk proto support 2026-01-17 09:05:54 +03:00
seydx cea524074a Merge branch 'wyze' of https://github.com/seydx/go2rtc into wyze 2026-01-15 22:52:04 +01:00
seydx 7498d0fba5 copy audio payload before processing in handleAudio function 2026-01-15 22:51:58 +01:00
seydx 50d9aab0d7 change pcm to pcml 2026-01-15 22:50:46 +01:00
seydx 3983ce3f4f Update Wyze Video Doorbell v2 details in README
Added model and version information for Wyze Video Doorbell v2.
2026-01-15 14:50:01 +01:00
seydx 0066da94f7 update wyze readme 2026-01-15 12:13:03 +01:00
seydx 4dbf53122e enable video and audio in buildK10002 again 2026-01-15 12:12:08 +01:00
seydx f96a074957 refactor timestamp handling 2026-01-15 01:25:35 +01:00
seydx dbd04cb972 refactor frame handling 2026-01-15 01:11:16 +01:00
seydx 0d035e5bce update ack hangling to improve streaming 2026-01-15 01:11:06 +01:00
seydx 7241759fea disable video and audio by default in buildK10002; start them later in probe 2026-01-15 01:10:41 +01:00
seydx b067c408c0 add missing codecs 2026-01-14 19:12:04 +01:00
seydx a99590823b allow to specify custom port 2026-01-14 19:11:53 +01:00
seydx 3bf2b316d7 Merge branch 'AlexxIT:master' into wyze 2026-01-13 21:50:10 +01:00
Alex X 2f43bfe5dc Fix two-way audio for cs2+tcp proto for xiaomi source 2026-01-13 21:26:01 +03:00
Alex X 59161fcef2 Improve cs2+udp proto for xiaomi source #2026 #2030 2026-01-13 21:25:30 +03:00
seydx 9ca9f96ea2 cleanup and update readme 2026-01-13 17:24:36 +01:00
seydx bc0c8d5577 use random session id in auth process 2026-01-13 16:48:41 +01:00
Alex X fd68107940 Add "bad conn" for debugging UDP 2026-01-13 12:15:48 +03:00
Alex X b19c081642 Improve cs2+udp proto for xiaomi source 2026-01-13 12:13:58 +03:00
seydx 039e916030 cleanup 2026-01-12 19:57:38 +01:00
seydx 3a587c9cee simplify SID generation 2026-01-12 13:56:52 +01:00
seydx 25e3125a89 Skip unsupported cameras (gwell based) 2026-01-12 11:22:25 +01:00
seydx 439dccf4bd cleanup 2026-01-12 11:03:53 +01:00
seydx 5fcb33c0cd Enhance video resolution handling by adding model-specific logic and updating subtype parsing 2026-01-12 11:00:28 +01:00
seydx c5311cdd94 Add keepalive command and sequence handling to new protocol 2026-01-12 10:34:05 +01:00
seydx 3dcb6dfc48 Merge branch 'AlexxIT:master' into wyze 2026-01-12 03:21:35 +01:00
seydx 406159cce5 refactor 2026-01-12 03:15:48 +01:00
seydx 659a042c42 Implement new authentication commands and improve PSK handling 2026-01-12 02:13:00 +01:00
Alex X e614513b97 Fix formats table in readme 2026-01-11 19:57:52 +03:00
Alex X f9f22cdd0b Add about OS versions to readme 2026-01-11 19:56:45 +03:00
Alex X dab9efb7d0 Merge pull request #2029 from Johnnybyzhang/master
xiaomi/cs2: fix TCP keepalive to match official Mi Home app
2026-01-11 19:55:23 +03:00
Alex X eb39b80883 Fix login to Xiaomi account with captcha #1985 2026-01-11 16:46:23 +03:00
Johnnybyzhang ff04a0d4b2 xiaomi/cs2: reduce TCP keepalive interval to 1 second
Based on PCAP analysis of official Mi Home app traffic:
- Official app sends PING every ~1 second
- Previous 5-second interval was too slow, causing connection resets

Simply reduce keepalive timeout from 5s to 1s.
2026-01-11 20:26:34 +08:00
Johnnybyzhang c4b32e3a0b xiaomi/cs2: fix TCP keepalive to match official Mi Home app
Based on PCAP analysis of official Mi Home app traffic, the keepalive
mechanism was incorrect:

Before (broken):
- Sent PING every 5s only when receiving data
- Responded to PING with PONG

After (fixed):
- Send PING every 1 second independently via dedicated goroutine
- Don't respond to PING with PONG (official app doesn't either)
- Both sides send PING bidirectionally as heartbeats

The official app sends 199 PING messages and 0 PONG messages in a
typical session. This fix matches that behavior.

Fixes connection resets after prolonged streaming sessions with
Xiaomi cameras using the CS2 P2P protocol.
2026-01-11 14:57:50 +08:00
seydx 58d8a86a92 cleanup 2026-01-10 10:46:26 +01:00
seydx 29f966f280 Fix intercom for new firmware 2026-01-10 03:13:41 +01:00
seydx cbaa147469 Update README.md for Wyze cameras 2026-01-10 02:44:27 +01:00
seydx c55fa87827 Update README.md to include details on NEW Protocol (0xCC51) for Wyze cameras 2026-01-10 02:44:07 +01:00
seydx 84e13d9d22 Add support for latest wyze firmware 2026-01-10 02:42:47 +01:00
oeiber c6733bf4f1 Update README with Doorbird support details
Added information about Doorbird device support and user permissions.
2026-01-07 22:20:40 +01:00
Alex X e960f90a97 Add formats and protocols to readme 2026-01-05 10:17:08 +03:00
Simon Cheng 3207f9e783 fix typo for inability to set channels for backchannel 2026-01-04 18:45:03 -05:00
seydx 263579fa01 cleanup 2026-01-03 16:12:37 +01:00
seydx 90c0b513e9 cleanup 2026-01-03 15:41:37 +01:00
seydx cfbba5a52c comments 2026-01-02 16:52:55 +01:00
seydx c74a39a30d cleanup 2026-01-02 16:51:23 +01:00
Alex X d4dc670cb5 Add support two-way audio for Dafang camera 2026-01-02 10:19:58 +03:00
seydx 4cff72c9a3 Refactor discovery and session setup logic 2026-01-02 02:22:14 +01:00
seydx f923487546 Improve error logging for video playback 2026-01-01 11:46:17 +01:00
seydx f47a041ece Improve error logging for video playback 2026-01-01 11:37:44 +01:00
Alex X e77210f916 Improve support tutk vendor for xiaomi source 2026-01-01 09:28:02 +03:00
Alex X 44da81774c Add recv/send counters to xiaomi source 2026-01-01 08:42:36 +03:00
seydx 7d4b3fe65b Merge branch 'AlexxIT:master' into wyze 2026-01-01 05:25:58 +01:00
seydx a42ab88dbd add wyze support 2026-01-01 05:24:45 +01:00
Alex X 4dae65a535 Fix audio sample rate for some xiaomi cameras #2006 2025-12-31 17:55:47 +03:00
Alex X a09e1b2f90 Update openapi 2025-12-27 17:50:40 +03:00
Alex X d183b99a44 Update GitHub Pages site link 2025-12-27 15:43:07 +03:00
Alex X 654e78b7c5 Add suggest button to config editor 2025-12-27 12:34:08 +03:00
Alex X 1cd5517026 Log all modules with custom loggers 2025-12-27 12:17:40 +03:00
Alex X 07fb78d661 Merge pull request #1980 from skrashevich/monaco-editor-141225
Replace ace editor to Monaco with config hints
2025-12-27 12:10:15 +03:00
Alex X 86f9f114b5 Code refactoring for #1980 2025-12-27 12:08:39 +03:00
Sergey Krashevich 7e38b4fe89 Add enum and pattern constraint checks to YAML linter
Enhances the YAML linter to validate scalar values against enum and pattern constraints defined in the schema. Adds utility functions for value comparison, schema constraint collection, and applies these checks during linting to provide more precise error messages for invalid values.
2025-12-27 12:00:47 +03:00
Sergey Krashevich 0fd2217bd2 Trigger suggestions for property completions
Adds logic to trigger the suggestion widget when completing a property if it expects a block or has value suggestions, improving the user experience in the config editor.
2025-12-27 10:26:15 +03:00
Sergey Krashevich 76bdc7e065 Refactor block scalar handling in config parser
Simplifies the logic for handling block scalar content by restructuring the conditional checks for blockScalarParentIndent. This improves readability and ensures correct processing of indented lines.
2025-12-27 09:56:52 +03:00
Sergey Krashevich 3bd433c950 Improve null checks and object handling in config.html
Replaces optional chaining with explicit null checks and more robust object property access throughout the file. Refactors destructuring and object spreading to use Object.assign for better compatibility. These changes improve code reliability and compatibility with older browsers or environments lacking support for newer JavaScript features.
2025-12-27 09:09:32 +03:00
Sergey Krashevich 4c50a2c00c Remove redundant min-height property from #config
Deleted an unnecessary 'min-height: 0;' CSS rule from the #config selector, as a fixed min-height is already set.
2025-12-27 08:50:00 +03:00
Sergey Krashevich 0e65bd05c4 Disable word-based suggestions in editor config
Updated the editor configuration in config.html to set wordBasedSuggestions to false and disable word suggestions in the suggestion widget. This change aims to refine the suggestion behavior for a more focused coding experience.
2025-12-27 08:49:26 +03:00
Alex X 05fd0c5cca Merge pull request #1956 from felipecrs/ffmpeg-timeout
Add `#timeout` param for ffmpeg source
2025-12-27 08:38:38 +03:00
Alex X a3a4276c15 Code refactoring for #1956 2025-12-27 08:36:40 +03:00
Sergey Krashevich 0f4607a070 Improve YAML language detection in config.html
Refactored the logic for detecting the YAML language in Monaco editor to handle cases where getLanguages may not be available or Monaco is not loaded. This increases robustness and prevents potential runtime errors.
2025-12-27 08:08:28 +03:00
Sergey Krashevich 11ad1129ed Add hover provider for YAML editor
Introduces a hover provider to the YAML editor using Monaco, displaying property descriptions from the schema when hovering over keys. This enhances the editor's usability by providing inline documentation for YAML properties.
2025-12-27 08:05:42 +03:00
Sergey Krashevich da0b19026c Improve YAML linter with indentation and block scalar checks
Adds detection for inconsistent indentation and unexpected indentation at the document root. Enhances block scalar handling by tracking parent indentation and skipping content lines accordingly. Also improves error reporting for missing map keys or list items.
2025-12-27 07:59:22 +03:00
Alex X c880c37d37 Merge pull request #1992 from FIGIO55/rtsp_onvif_params
Allow rtsp params (like #backchannel=0) from onvif sources
2025-12-26 23:06:30 +03:00
Alex X c4fb66a818 Code refactoring for #1992 2025-12-26 23:05:58 +03:00
Alex X 9b618f45d0 Rewrite webrtc listen logic #1890 #1892 2025-12-26 22:56:39 +03:00
Alex X 3fd1fe2622 Add net interfaces list to webrtc debug 2025-12-26 14:09:22 +03:00
Alex X 2f470fa518 Add support cs2+tcp protocol for xiaomi source 2025-12-26 12:53:52 +03:00
Alex X 212def9ceb Update app dev version format 2025-12-22 17:22:22 +03:00
Alex X 79698365bb Add fetch tags to GitHub actions 2025-12-22 12:24:00 +03:00
Alex X 5b1da84ae2 Add TUTK protocol to xiaomi source 2025-12-22 00:00:33 +03:00
Sergey Krashevich 247d4063ed Merge branch 'monaco-editor-141225' of github.com:skrashevich/go2rtc into monaco-editor-141225 2025-12-21 00:06:29 +03:00
Sergey Krashevich 7ada6d81eb Add YAML schema-based linting and validation
Integrates js-yaml for parsing and adds comprehensive YAML linting with schema-based type checking, duplicate key detection, and improved error reporting. Refactors and extends parsing utilities, enhances completion logic, and introduces a schema tools abstraction for type and property resolution.
2025-12-21 00:02:49 +03:00
Sergey Krashevich eda92afffe Merge branch 'AlexxIT:master' into monaco-editor-141225 2025-12-20 12:54:14 -08:00
Davide Figini ff19885790 Add rtsp params pass through from onvif sources 2025-12-19 15:32:01 +01:00
Davide Figini bbb9466845 Add onvif name and hardware in info field of onvif discovery 2025-12-19 15:12:18 +01:00
Alex X 079d404ed0 Set app version from git info 2025-12-18 19:02:10 +03:00
Alex X 753d6617ab Add support cateye devices to xiaomi source 2025-12-15 21:41:05 +03:00
Alex X dfe47559d1 Update version to 1.9.13 2025-12-14 23:05:24 +03:00
Alex X eabd7d60cd Clean go.sum file 2025-12-14 22:43:18 +03:00
Alex X dfda4b11ff Add about xiaomi source to readme 2025-12-14 22:41:00 +03:00
Alex X 353262307b Update links to icons in resources 2025-12-14 22:35:58 +03:00
Alex X d734140eaf Update reamde 2025-12-14 22:31:13 +03:00
Alex X 2409bb56d7 Move tuya docs to separate page 2025-12-14 21:54:06 +03:00
Alex X df484cc904 Add eseecloud source to readme 2025-12-14 21:45:44 +03:00
Alex X 7e0c7a8173 Merge pull request #1966 from oeiber/master
Update documentation for doorbird devices
2025-12-14 21:29:38 +03:00
Alex X 7eaa4a1b55 Code refactoring for #1966 2025-12-14 21:28:37 +03:00
Alex X 03941a5691 Merge pull request #1977 from edenhaus/preload-list
Add get request to preload endpoint for listing them
2025-12-14 20:20:22 +03:00
Alex X 28821c41e0 Code refactoring for #1977 2025-12-14 20:17:13 +03:00
Alex X 8636e96379 Change ffmpeg transcoder from opus to opus/16000 2025-12-14 17:59:07 +03:00
Alex X 7119384184 Fix backchannel audio for xiaomi chuangmi.camera.72ac1 2025-12-14 17:58:17 +03:00
Alex X 57b0ace802 Add vendor name to xiaomi unsupported vendor message 2025-12-14 17:18:25 +03:00
Alex X b0f46bc919 Fix backchannel audio for xiaomi isa.camera.hlc6 2025-12-14 17:17:52 +03:00
Alex X a4d4598a13 Add support xiaomi source 2025-12-14 13:07:45 +03:00
Sergey Krashevich d041c89c5c schema improvements 2025-12-14 05:20:59 +03:00
Sergey Krashevich ce9138b354 update monaco to 0.55.1 2025-12-14 04:52:35 +03:00
Sergey Krashevich 1e5def35c9 monaco initial 2025-12-14 04:47:27 +03:00
Alex X 17c1f69f66 Update dependencies 2025-12-13 14:25:51 +03:00
Alex X fb31a251b8 Improve fetch for exec source 2025-12-13 14:00:16 +03:00
Alex X c5277daa45 Add UnmarshalHeader func to OPUS codec 2025-12-11 22:01:36 +03:00
Alex X 76a5e160c2 Increase default dial timeout and probe timeout 2025-12-11 22:00:35 +03:00
Alex X 494daed937 Add aliases to PCMA/PCMU codecs 2025-12-11 21:59:57 +03:00
Alex X a86e10446a Add PCML/8000 to ffmpeg transcoder 2025-12-11 21:59:25 +03:00
Robert Resch 209b73a0f1 Add get request to preload endpoint for listing them 2025-12-10 23:30:08 +01:00
oeiber 54473ff1de Update documentation for doorbird devices 2025-12-03 17:04:40 +01:00
Alex X 7eb5fe0355 Add second STUN server from Cloudflare 2025-12-01 14:19:48 +03:00
Alex X fbd5215669 Add custom title to stream page #1957 2025-11-26 11:24:57 +03:00
Alex X 3ebc115cc5 Update title for all WebUI pages 2025-11-26 11:24:57 +03:00
Felipe Santos 31962181cb Add #timeout param for ffmpeg source 2025-11-25 16:37:08 -03:00
Alex X 6d1a95a4e3 Merge pull request #1730 from seydx/tuya-new
New Tuya camera support
2025-11-25 20:36:13 +03:00
Alex X 4ec2849008 Fix WebUI for tuya source 2025-11-25 20:14:00 +03:00
Alex X 4ef6a147a6 Fix panic on login for tuya source 2025-11-25 20:13:45 +03:00
Alex X 94df080bf7 Fix MQTT url for tuya source for some regions 2025-11-25 20:13:22 +03:00
Alex X 86edd814c9 Add support new audio codec for tapo source #1954 2025-11-25 15:51:55 +03:00
Alex X 5a259993d8 Update dependencies 2025-11-22 20:04:05 +03:00
Alex X b6fe8871df Add self-signed cert generator (not used yet) 2025-11-22 20:00:34 +03:00
Alex X b47a2ba73c Add mod_pinggy example 2025-11-22 19:59:46 +03:00
Alex X 4934fa4cc1 Add support tunnels via Pinggy #1853 2025-11-22 19:59:10 +03:00
seydx 61f74820bc Merge branch 'AlexxIT:master' into tuya-new 2025-11-20 21:00:41 +01:00
Alex X 248fc7a11a Remove wrong timeout for http source 2025-11-20 20:03:34 +03:00
Alex X aa0ece2d1e Fix adts producer for VLC player support #1643 2025-11-20 17:52:08 +03:00
Alex X 68036b68c1 Fix timestamp processing for HTTP-FLV 2025-11-19 12:58:23 +03:00
seydx 319dbf2c63 Refactor after merge 2025-11-19 00:10:13 +01:00
seydx 4b419309a8 Merge branch 'master' of https://github.com/AlexxIT/go2rtc into tuya-new 2025-11-19 00:09:34 +01:00
Alex X 42e7a03534 Add HomeKit QR code to WebUI #1138 by @mnakada 2025-11-18 20:55:17 +03:00
Alex X 290e8fcfda Add custom category_id for HomeKit server #985 by @Minims 2025-11-18 20:52:32 +03:00
Alex X 6c78b5cb53 Add 404 error for homekit API request 2025-11-18 20:40:30 +03:00
Alex X c72b205d87 Fix panic for HomeKit server proxy mode #1940 2025-11-18 20:38:04 +03:00
Alex X 2cd009646a Remove homekit source params from streams info API 2025-11-18 19:17:26 +03:00
Alex X 8f5fce4d73 Add support HTTP-FLV with H265 from new Reolink cameras #1938 2025-11-18 16:05:51 +03:00
Alex X b705cadc04 Merge pull request #1942 from sethyx/fix/network-url
Fix link to per-stream net/node graphs
2025-11-18 11:17:04 +03:00
Gergely Szell 2523a5ac38 Fix link to per-stream net/node graphs 2025-11-18 09:12:38 +01:00
Alex X e246e2e756 Fix WebUI for Hass black theme 2025-11-17 12:21:45 +03:00
Alex X 2dc0d58ba7 Update version to 1.9.12 2025-11-16 19:08:34 +03:00
Alex X cb22ae7833 Add security notes to readme 2025-11-16 19:07:03 +03:00
Alex X c98b0a83c4 Merge pull request #1939 from edenhaus/supportedSchemas
Add api endpoint to return supported schemas
2025-11-16 19:04:24 +03:00
Alex X 0bae158e41 Code refactoring for #1939 2025-11-16 19:03:19 +03:00
Robert Resch e2b63a4f6c Remove duplicate code 2025-11-16 16:40:04 +01:00
Robert Resch 3897f10a4d Add api endpoint to return supported schema 2025-11-16 16:33:09 +01:00
Alex X ac80f1470e Add errors output to streams API 2025-11-16 18:20:53 +03:00
Alex X 1fe602679e Update WebUI design 2025-11-15 21:08:00 +03:00
Alex X e2c7d06730 Add check for insecure uri from onvif source 2025-11-11 17:34:01 +03:00
Alex X 2133f5323c Add insecure sources logic 2025-11-11 17:33:15 +03:00
Alex X c10a06d199 Fix wrong log message for streams module 2025-11-11 17:29:10 +03:00
Alex X d053d88ce9 Add support maxwidth/maxheight settings for homekit source 2025-11-11 15:48:12 +03:00
Alex X 2ce38b4486 Add trace log for ignored api paths 2025-11-11 15:43:49 +03:00
Alex X 44d59b1696 Add config local_auth for api module 2025-11-11 15:22:28 +03:00
Alex X 15ec995ecc Add config for the list of modules to init 2025-11-11 15:10:24 +03:00
Alex X 231cab36b2 Add config allow_paths for api module 2025-11-11 15:01:27 +03:00
Alex X 640db3029e Add config allow_paths for exec module 2025-11-11 15:00:58 +03:00
Alex X 2836fdae13 Add config allow_paths for echo module 2025-11-11 14:59:05 +03:00
Alex X 964bb225fa Add support custom params for hass source 2025-11-11 10:54:13 +03:00
Alex X 5cc32197b8 Fix HomeKit proxy for hass source 2025-11-10 15:35:07 +03:00
Alex X bc1a4ac8e4 Fix API /api/homekit/accessories 2025-11-10 15:34:39 +03:00
Alex X 158f9d3a08 Code refactoring for HomeKit server 2025-11-09 21:58:44 +03:00
Alex X 81cfcf877a Fix HomeKit proxy EVENTs 2025-11-09 21:28:53 +03:00
Alex X 96919bf9e3 Add support uint64 to tlv8 2025-11-09 21:25:23 +03:00
Alex X e4359ac217 Rename HomeKit structures according to specs 2025-11-09 21:24:47 +03:00
seydx 56d7a6fee4 Add comments and improve repackaging 2025-10-28 14:54:54 +01:00
seydx 292b32af99 Optimize audio frame size handling in AddTrack to reduce latency for Tuya cameras 2025-10-28 13:53:42 +01:00
seydx 33e4527042 Revert repackaging for backchannel 2025-10-28 12:58:00 +01:00
seydx 62a9046f01 Revert configurable packet size for RepackG711 2025-10-28 12:50:36 +01:00
seydx 25e7ac531e Cleanup and update comments 2025-10-28 11:12:44 +01:00
seydx 0f27bb1124 Update SendOffer to include token and fix mqtt close 2025-10-27 23:57:54 +01:00
seydx 0ff3bf67e1 Comment out MQTT speaker message sending in AddTrack function 2025-10-27 23:57:14 +01:00
seydx 6d3d45e337 Handle speaker messages 2025-10-27 21:48:44 +01:00
seydx c6940eb0f3 Refactor AddTrack to use GetSenderTrack and improve audio handling 2025-10-27 21:48:35 +01:00
seydx 8142d2fc43 Refactor RepackG711 to use configurable packet size 2025-10-27 21:48:15 +01:00
seydx 721ed98afb webrtc: export GetSenderTrack 2025-10-27 21:47:52 +01:00
seydx fb8c6e1b1b Update comments 2025-10-26 22:21:56 +01:00
seydx 80ab32379c Merge branch 'AlexxIT:master' into tuya-new 2025-10-26 16:57:54 +01:00
seydx 863174839c Fix video/audio ssrc and low power cameras 2025-10-26 16:39:59 +01:00
Alex X ff18283d11 Improve homekit secure conn buffers 2025-10-26 15:46:11 +03:00
Alex X 994e0dc526 Improve homekit tlv8 parsing 2025-10-26 15:46:11 +03:00
Felipe Santos d16d260679 Use relative links (git tag-aware) 2025-10-24 12:22:41 -03:00
Felipe Santos d4190290b7 Change back to "when" 2025-10-24 12:20:54 -03:00
Felipe Santos 5660311bb2 Merge branch 'master' of https://github.com/AlexxIT/go2rtc into update-readme 2025-10-24 12:18:30 -03:00
Alex X 7254bd4fbc Code refactoring for tapo source 2025-10-24 17:54:55 +03:00
Alex X 9f407a754d Fix tapo source for some cameras #1918 2025-10-24 17:54:37 +03:00
Alex X cc97bc33c4 Restore simple onvif client logic 2025-10-24 17:28:49 +03:00
seydx bd8e4fa298 Merge branch 'AlexxIT:master' into tuya-new 2025-10-24 13:10:12 +02:00
Alex X 6db4dda535 Fix onvif client for some cameras 2025-10-23 14:42:38 +03:00
seydx 7abc963a50 Merge branch 'AlexxIT:master' into tuya-new 2025-10-17 03:15:43 +02:00
Felipe Santos 4924cf2256 Merge branch 'master' of https://github.com/AlexxIT/go2rtc into update-readme 2025-10-11 15:54:53 -03:00
Felipe Santos 56bf53208e Merge branch 'master' of https://github.com/AlexxIT/go2rtc into update-readme 2025-10-01 11:31:34 -03:00
seydx ee5e31d3b3 Merge branch 'master' of https://github.com/AlexxIT/go2rtc into tuya-new 2025-09-30 19:14:43 +02:00
seydx 5c01cbad9e Merge branch 'AlexxIT:master' into tuya-new 2025-09-26 15:07:52 +02:00
Felipe Santos 7c3d97b0a2 Remove mentions of RTSPtoWebRTC 2025-07-10 16:28:37 -03:00
Felipe Santos 88a2f33b71 Fix table 2025-07-10 16:19:48 -03:00
Felipe Santos b7557d750e Apply suggestions from code review 2025-07-10 16:16:50 -03:00
Felipe Santos ce4bee3be7 Update README.md 2025-07-10 16:15:42 -03:00
Felipe Santos 5e746e3367 Update README.md 2025-07-10 16:15:14 -03:00
seydx e9611769be deps 2025-07-10 16:12:07 +02:00
seydx c5dfa84ff2 readme 2025-07-10 16:09:18 +02:00
seydx da68101c09 Optimize URL decoding and update MQTT keep-alive 2025-07-10 16:09:18 +02:00
seydx 30c418542c readme 2025-07-10 16:09:18 +02:00
seydx b58c1a7ed6 Update README.md
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2025-07-10 16:09:18 +02:00
seydx 47e87281a1 increase timeout 2025-07-10 16:09:18 +02:00
seydx 60b6b93ff8 fix concurrent writes and improve mqtt 2025-07-10 16:09:18 +02:00
seydx 3149b6f750 Update README.md
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2025-07-10 16:09:18 +02:00
seydx e44f1ad53e Update README.md
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2025-07-10 16:09:18 +02:00
seydx c38c8a7fce readme 2025-07-10 16:09:18 +02:00
seydx 9efc717633 ... 2025-07-10 16:09:18 +02:00
seydx a2d422f5cb format 2025-07-10 16:09:18 +02:00
seydx 3036dd7cfe refactor 2025-07-10 16:09:18 +02:00
seydx 5be5d9247c refactor, simplify api, add support for email/password auth 2025-07-10 16:09:18 +02:00
seydx 42b7eea852 fix: correct transceiver direction check in getSender method 2025-07-10 16:09:18 +02:00
seydx 7ee3f6e4f7 Update README.md
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2025-07-10 16:09:18 +02:00
seydx fbd8d995ed refactor and increase timeout 2025-07-10 16:09:18 +02:00
seydx 998c85d6f5 - support adding cameras via interface
- support qr code auth
- support resolution change
- support h265
- refactor code
2025-07-10 16:09:18 +02:00
seydx 67dfc942a0 update useful links 2025-07-10 16:09:18 +02:00
seydx 1cc8b373de change query 2025-07-10 16:09:18 +02:00
seydx f045f3fccd dont expose raw url in stream info 2025-07-10 16:09:18 +02:00
seydx 691f6d9cdd update README 2025-07-10 16:09:18 +02:00
seydx 8a8fb66eeb Update README.md
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2025-07-10 16:09:18 +02:00
seydx e7044a93f6 fix video/audio and minor improvements 2025-07-10 16:09:18 +02:00
seydx a9bcb46f38 refactor 2025-07-10 16:09:18 +02:00
seydx 16a812c8b8 revert webrtc 2025-07-10 16:09:18 +02:00
seydx 27fe2622ec revert demuxer 2025-07-10 16:09:18 +02:00
seydx 3d222136f9 support h265 2025-07-10 16:09:18 +02:00
seydx 524cdb7176 demuxer: support hvc and pcm 2025-07-10 16:09:18 +02:00
seydx 499dc10390 comments 2025-07-10 16:09:18 +02:00
seydx e7bd3d401f wip h265 datachannel 2025-07-10 16:09:18 +02:00
seydx 5ec942cb5e fix stream mode 2025-07-10 16:09:18 +02:00
seydx 6c255cd2f2 fix two way audio 2025-07-10 16:09:18 +02:00
seydx 4f969d750a readme 2025-07-10 16:09:18 +02:00
seydx bd2cbe20e0 add useful links 2025-07-10 16:09:18 +02:00
seydx 6d8d6a91ef format 2025-07-10 16:09:18 +02:00
seydx 05c12b34e5 refactor 2025-07-10 16:09:18 +02:00
seydx 43b7a662c1 use streamType parameter 2025-07-10 16:09:18 +02:00
seydx a7e76db464 change hls url and query and add more checks 2025-07-10 16:09:18 +02:00
seydx b797a2fcd1 add HLS support and fix skill response 2025-07-10 16:09:18 +02:00
seydx 6e35f1a389 add rtsp support 2025-07-10 16:09:18 +02:00
seydx 30d48e139c implement skill handling and media configuration 2025-07-10 16:09:18 +02:00
seydx e74fc6f198 add tuya source 2025-07-10 16:09:18 +02:00
Felipe Santos 6734492a2d Change TIPS to Tips 2025-07-07 14:31:51 -03:00
Felipe Santos 90217d61d0 Restore ToC 2025-07-07 14:25:55 -03:00
Felipe Santos ba27a7f68c Merge branch 'master' of https://github.com/AlexxIT/go2rtc into update-readme 2025-07-07 14:22:28 -03:00
Felipe Santos 6f2afdc97b Remove it from schema.json too 2025-05-22 11:16:54 -03:00
Felipe Santos 6e2e0d353a Revert Home Assistant config dir to /config in example 2025-05-22 11:14:56 -03:00
Felipe Santos 4788011249 Fix typo 2025-05-12 19:51:31 -03:00
Felipe Santos f1faa95897 Fix some links 2025-05-03 13:12:50 -03:00
Felipe Santos b84df84e53 Update README 2025-05-03 13:06:28 -03:00
240 changed files with 19962 additions and 4946 deletions
+24 -8
View File
@@ -17,21 +17,37 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
package-manager-cache: false
- name: Install dependencies
run: npm install --no-package-lock
- name: Build docs
run: npm run docs:build
- name: Copy docs into website
run: rsync -a --exclude '.vitepress/' --exclude 'README.md' website/ website/.vitepress/dist/
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: website/.vitepress/dist
# Single deploy job since we're just deploying # Single deploy job since we're just deploying
deploy: deploy:
environment: environment:
name: github-pages name: github-pages
url: ${{ steps.deployment.outputs.page_url }} url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './website'
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment
uses: actions/deploy-pages@v4 uses: actions/deploy-pages@v4
+7
View File
@@ -15,3 +15,10 @@ go2rtc_win*
0_test.go 0_test.go
.DS_Store .DS_Store
website/.vitepress/cache
website/.vitepress/dist
node_modules
package-lock.json
CLAUDE.md
+403 -1284
View File
File diff suppressed because it is too large Load Diff
-117
View File
@@ -1,117 +0,0 @@
# API
Fill free to make any API design proposals.
## HTTP API
Interactive [OpenAPI](https://alexxit.github.io/go2rtc/api/).
`www/stream.html` - universal viewer with support params in URL:
- multiple streams on page `src=camera1&src=camera2...`
- stream technology autoselection `mode=webrtc,webrtc/tcp,mse,hls,mp4,mjpeg`
- stream technology comparison `src=camera1&mode=webrtc&mode=mse&mode=mp4`
- player width setting in pixels `width=320px` or percents `width=50%`
`www/webrtc.html` - WebRTC viewer with support two way audio and params in URL:
- `media=video+audio` - simple viewer
- `media=video+audio+microphone` - two way audio from camera
- `media=camera+microphone` - stream from browser
- `media=display+speaker` - stream from desktop
## JavaScript API
- You can write your viewer from the scratch
- You can extend the built-in viewer - `www/video-rtc.js`
- Check example - `www/video-stream.js`
- Check example - https://github.com/AlexxIT/WebRTC
`video-rtc.js` features:
- support technologies:
- WebRTC over UDP or TCP
- MSE or HLS or MP4 or MJPEG over WebSocket
- automatic selection best technology according on:
- codecs inside your stream
- current browser capabilities
- current network configuration
- automatic stop stream while browser or page not active
- automatic stop stream while player not inside page viewport
- automatic reconnection
Technology selection based on priorities:
1. Video and Audio better than just Video
2. H265 better than H264
3. WebRTC better than MSE, than HLS, than MJPEG
## WebSocket API
Endpoint: `/api/ws`
Query parameters:
- `src` (required) - Stream name
### WebRTC
Request SDP:
```json
{"type":"webrtc/offer","value":"v=0\r\n..."}
```
Response SDP:
```json
{"type":"webrtc/answer","value":"v=0\r\n..."}
```
Request/response candidate:
- empty value also allowed and optional
```json
{"type":"webrtc/candidate","value":"candidate:3277516026 1 udp 2130706431 192.168.1.123 54321 typ host"}
```
### MSE
Request:
- codecs list optional
```json
{"type":"mse","value":"avc1.640029,avc1.64002A,avc1.640033,hvc1.1.6.L153.B0,mp4a.40.2,mp4a.40.5,flac,opus"}
```
Response:
```json
{"type":"mse","value":"video/mp4; codecs=\"avc1.64001F,mp4a.40.2\""}
```
### HLS
Request:
```json
{"type":"hls","value":"avc1.640029,avc1.64002A,avc1.640033,hvc1.1.6.L153.B0,mp4a.40.2,mp4a.40.5,flac"}
```
Response:
- you MUST rewrite full HTTP path to `http://192.168.1.123:1984/api/hls/playlist.m3u8`
```json
{"type":"hls","value":"#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=1000000,CODECS=\"avc1.64001F,mp4a.40.2\"\nhls/playlist.m3u8?id=DvmHdd9w"}
```
### MJPEG
Request/response:
```json
{"type":"mjpeg"}
```
-585
View File
@@ -1,585 +0,0 @@
openapi: 3.1.0
info:
title: go2rtc
license: { name: MIT,url: https://opensource.org/licenses/MIT }
version: 1.0.0
contact: { url: https://github.com/AlexxIT/go2rtc }
description: |
Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
servers:
- url: http://localhost:1984
components:
parameters:
stream_src_path:
name: src
in: path
description: Source stream name
required: true
schema: { type: string }
example: camera1
stream_dst_path:
name: dst
in: path
description: Destination stream name
required: true
schema: { type: string }
example: camera1
stream_src_query:
name: src
in: query
description: Source stream name
required: true
schema: { type: string }
example: camera1
mp4_filter:
name: mp4
in: query
description: MP4 codecs filter
required: false
schema:
type: string
enum: [ "", flac, all ]
example: flac
video_filter:
name: video
in: query
description: Video codecs filter
schema:
type: string
enum: [ "", all, h264, h265, mjpeg ]
example: h264,h265
audio_filter:
name: audio
in: query
description: Audio codecs filter
schema:
type: string
enum: [ "", all, aac, opus, pcm, pcmu, pcma ]
example: aac
responses:
discovery:
description: ""
content:
application/json:
example: { streams: [ { "name": "Camera 1","url": "..." } ] }
webtorrent:
description: ""
content:
application/json:
example: { share: AKDypPy4zz, pwd: H0Km1HLTTP }
tags:
- name: Application
description: "[Module: API](https://github.com/AlexxIT/go2rtc#module-api)"
- name: Config
description: "[Configuration](https://github.com/AlexxIT/go2rtc#configuration)"
- name: Streams list
description: "[Module: Streams](https://github.com/AlexxIT/go2rtc#module-streams)"
- name: Consume stream
- name: Snapshot
- name: Produce stream
- name: Discovery
- name: ONVIF
- name: RTSPtoWebRTC
- name: WebTorrent
description: "[Module: WebTorrent](https://github.com/AlexxIT/go2rtc#module-webtorrent)"
- name: Debug
paths:
/api:
get:
summary: Get application info
tags: [ Application ]
responses:
"200":
description: ""
content:
application/json:
example: { config_path: "/config/go2rtc.yaml",host: "192.168.1.123:1984",rtsp: { listen: ":8554",default_query: "video&audio" },version: "1.5.0" }
/api/exit:
post:
summary: Close application
tags: [ Application ]
parameters:
- name: code
in: query
description: Application exit code
required: false
schema: { type: integer }
example: 100
responses:
default:
description: Default response
/api/restart:
post:
summary: Restart Daemon
description: Restarts the daemon.
tags: [ Application ]
responses:
default:
description: Default response
/api/config:
get:
summary: Get main config file content
tags: [ Config ]
responses:
"200":
description: ""
content:
application/yaml: { example: "streams:..." }
post:
summary: Rewrite main config file
tags: [ Config ]
requestBody:
content:
"*/*": { example: "streams:..." }
responses:
default:
description: Default response
patch:
summary: Merge changes to main config file
tags: [ Config ]
requestBody:
content:
"*/*": { example: "streams:..." }
responses:
default:
description: Default response
/api/streams:
get:
summary: Get all streams info
tags: [ Streams list ]
responses:
"200":
description: ""
content:
application/json: { example: { camera1: { producers: [ ],consumers: [ ] } } }
put:
summary: Create new stream
tags: [ Streams list ]
parameters:
- name: src
in: query
description: Stream source (URI)
required: true
schema: { type: string }
example: "rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0"
- name: name
in: query
description: Stream name
required: false
schema: { type: string }
example: camera1
responses:
default:
description: Default response
patch:
summary: Update stream source
tags: [ Streams list ]
parameters:
- name: src
in: query
description: Stream source (URI)
required: true
schema: { type: string }
example: "rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0"
- name: name
in: query
description: Stream name
required: true
schema: { type: string }
example: camera1
responses:
default:
description: Default response
delete:
summary: Delete stream
tags: [ Streams list ]
parameters:
- name: src
in: query
description: Stream name
required: true
schema: { type: string }
example: camera1
responses:
default:
description: Default response
post:
summary: Send stream from source to destination
description: "[Stream to camera](https://github.com/AlexxIT/go2rtc#stream-to-camera)"
tags: [ Streams list ]
parameters:
- name: src
in: query
description: Stream source (URI)
required: true
schema: { type: string }
example: "ffmpeg:http://example.com/song.mp3#audio=pcma#input=file"
- name: dst
in: query
description: Destination stream name
required: true
schema: { type: string }
example: camera1
responses:
default:
description: Default response
/api/preload:
put:
summary: Preload new stream
tags: [ Streams list ]
parameters:
- name: src
in: query
description: Stream source (name)
required: true
schema: { type: string }
example: "camera1"
- name: video
in: query
description: Video codecs filter
required: false
schema: { type: string }
example: all,h264,h265,...
- name: audio
in: query
description: Audio codecs filter
required: false
schema: { type: string }
example: all,aac,opus,...
- name: microphone
in: query
description: Microphone codecs filter
required: false
schema: { type: string }
example: all,aac,opus,...
responses:
default:
description: Default response
delete:
summary: Delete preloaded stream
tags: [ Streams list ]
parameters:
- name: src
in: query
description: Stream source (name)
required: true
schema: { type: string }
example: "camera1"
responses:
default:
description: Default response
/api/streams?src={src}:
get:
summary: Get stream info in JSON format
tags: [ Consume stream ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
"200":
description: ""
content:
application/json:
example: { producers: [ { url: "rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0" } ], consumers: [ ] }
/api/webrtc?src={src}:
post:
summary: Get stream in WebRTC format (WHEP)
description: "[Module: WebRTC](https://github.com/AlexxIT/go2rtc#module-webrtc)"
tags: [ Consume stream ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
requestBody:
description: |
Support:
- JSON format (`Content-Type: application/json`)
- WHEP standard (`Content-Type: application/sdp`)
- raw SDP (`Content-Type: anything`)
required: true
content:
application/json: { example: { type: offer, sdp: "v=0..." } }
"application/sdp": { example: "v=0..." }
"*/*": { example: "v=0..." }
responses:
"200":
description: "Response on JSON or raw SDP"
content:
application/json: { example: { type: answer, sdp: "v=0..." } }
application/sdp: { example: "v=0..." }
"201":
description: "Response on `Content-Type: application/sdp`"
content:
application/sdp: { example: "v=0..." }
/api/stream.mp4?src={src}:
get:
summary: Get stream in MP4 format (HTTP progressive)
description: "[Module: MP4](https://github.com/AlexxIT/go2rtc#module-mp4)"
tags: [ Consume stream ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
- name: duration
in: query
description: Limit the length of the stream in seconds
required: false
schema: { type: string }
example: 15
- name: filename
in: query
description: Download as a file with this name
required: false
schema: { type: string }
example: camera1.mp4
- $ref: "#/components/parameters/mp4_filter"
- $ref: "#/components/parameters/video_filter"
- $ref: "#/components/parameters/audio_filter"
responses:
200:
description: ""
content: { video/mp4: { example: "" } }
/api/stream.m3u8?src={src}:
get:
summary: Get stream in HLS format
description: "[Module: HLS](https://github.com/AlexxIT/go2rtc#module-hls)"
tags: [ Consume stream ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
- $ref: "#/components/parameters/mp4_filter"
- $ref: "#/components/parameters/video_filter"
- $ref: "#/components/parameters/audio_filter"
responses:
200:
description: ""
content: { application/vnd.apple.mpegurl: { example: "" } }
/api/stream.mjpeg?src={src}:
get:
summary: Get stream in MJPEG format
description: "[Module: MJPEG](https://github.com/AlexxIT/go2rtc#module-mjpeg)"
tags: [ Consume stream ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
200:
description: ""
content: { multipart/x-mixed-replace: { example: "" } }
/api/frame.jpeg?src={src}:
get:
summary: Get snapshot in JPEG format
description: "[Module: MJPEG](https://github.com/AlexxIT/go2rtc#module-mjpeg)"
tags: [ Snapshot ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
200:
description: ""
content: { image/jpeg: { example: "" } }
/api/frame.mp4?src={src}:
get:
summary: Get snapshot in MP4 format
description: "[Module: MP4](https://github.com/AlexxIT/go2rtc#module-mp4)"
tags: [ Snapshot ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
200:
description: ""
content: { video/mp4: { example: "" } }
/api/webrtc?dst={dst}:
post:
summary: Post stream in WebRTC format
description: "[Incoming: WebRTC/WHIP](https://github.com/AlexxIT/go2rtc#incoming-webrtcwhip)"
tags: [ Produce stream ]
parameters:
- $ref: "#/components/parameters/stream_dst_path"
responses:
default:
description: Default response
/api/stream.flv?dst={dst}:
post:
summary: Post stream in FLV format
description: "[Incoming sources](https://github.com/AlexxIT/go2rtc#incoming-sources)"
tags: [ Produce stream ]
parameters:
- $ref: "#/components/parameters/stream_dst_path"
responses:
default:
description: Default response
/api/stream.ts?dst={dst}:
post:
summary: Post stream in MPEG-TS format
description: "[Incoming sources](https://github.com/AlexxIT/go2rtc#incoming-sources)"
tags: [ Produce stream ]
parameters:
- $ref: "#/components/parameters/stream_dst_path"
responses:
default:
description: Default response
/api/stream.mjpeg?dst={dst}:
post:
summary: Post stream in MJPEG format
description: "[Incoming sources](https://github.com/AlexxIT/go2rtc#incoming-sources)"
tags: [ Produce stream ]
parameters:
- $ref: "#/components/parameters/stream_dst_path"
responses:
default:
description: Default response
/api/dvrip:
get:
summary: DVRIP cameras discovery
description: "[Source: DVRIP](https://github.com/AlexxIT/go2rtc#source-dvrip)"
tags: [ Discovery ]
responses:
default:
description: Default response
/api/ffmpeg/devices:
get:
summary: FFmpeg USB devices discovery
description: "[Source: FFmpeg Device](https://github.com/AlexxIT/go2rtc#source-ffmpeg-device)"
tags: [ Discovery ]
responses:
default:
description: Default response
/api/ffmpeg/hardware:
get:
summary: FFmpeg hardware transcoding discovery
description: "[Hardware acceleration](https://github.com/AlexxIT/go2rtc/wiki/Hardware-acceleration)"
tags: [ Discovery ]
responses:
default:
description: Default response
/api/hass:
get:
summary: Home Assistant cameras discovery
description: "[Source: Hass](https://github.com/AlexxIT/go2rtc#source-hass)"
tags: [ Discovery ]
responses:
default:
description: Default response
/api/homekit:
get:
summary: HomeKit cameras discovery
description: "[Source: HomeKit](https://github.com/AlexxIT/go2rtc#source-homekit)"
tags: [ Discovery ]
responses:
default:
description: Default response
/api/nest:
get:
summary: Nest cameras discovery
tags: [ Discovery ]
responses:
default:
description: Default response
/api/onvif:
get:
summary: ONVIF cameras discovery
description: "[Source: ONVIF](https://github.com/AlexxIT/go2rtc#source-onvif)"
tags: [ Discovery ]
responses:
default:
description: Default response
/api/roborock:
get:
summary: Roborock vacuums discovery
description: "[Source: Roborock](https://github.com/AlexxIT/go2rtc#source-roborock)"
tags: [ Discovery ]
responses:
default:
description: Default response
/onvif/:
get:
summary: ONVIF server implementation
description: Simple realisation of the ONVIF protocol. Accepts any suburl requests
tags: [ ONVIF ]
responses:
default:
description: Default response
/stream/:
get:
summary: RTSPtoWebRTC server implementation
description: Simple API for support [RTSPtoWebRTC](https://www.home-assistant.io/integrations/rtsp_to_webrtc/) integration
tags: [ RTSPtoWebRTC ]
responses:
default:
description: Default response
/api/webtorrent?src={src}:
get:
summary: Get WebTorrent share info
tags: [ WebTorrent ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
200: { $ref: "#/components/responses/webtorrent" }
post:
summary: Add WebTorrent share
tags: [ WebTorrent ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
200: { $ref: "#/components/responses/webtorrent" }
delete:
summary: Delete WebTorrent share
tags: [ WebTorrent ]
parameters:
- $ref: "#/components/parameters/stream_src_path"
responses:
default:
description: Default response
/api/webtorrent:
get:
summary: Get all WebTorrent shares info
tags: [ WebTorrent ]
responses:
200: { $ref: "#/components/responses/discovery" }
/api/stack:
get:
summary: Show list unknown goroutines
tags: [ Debug ]
responses:
200:
description: ""
content: { text/plain: { example: "" } }
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 27 KiB

+1
View File
@@ -47,6 +47,7 @@ RUN if [ "${TARGETARCH}" = "amd64" ]; then apk add --no-cache libva-intel-driver
COPY --from=build /build/go2rtc /usr/local/bin/ COPY --from=build /build/go2rtc /usr/local/bin/
EXPOSE 1984 8554 8555 8555/udp
ENTRYPOINT ["/sbin/tini", "--"] ENTRYPOINT ["/sbin/tini", "--"]
VOLUME /config VOLUME /config
WORKDIR /config WORKDIR /config
+7 -3
View File
@@ -1,8 +1,12 @@
# Docker
Images are built automatically via [GitHub actions](https://github.com/AlexxIT/go2rtc/actions) and published on [Docker Hub](https://hub.docker.com/r/alexxit/go2rtc) and [GitHub](https://github.com/AlexxIT/go2rtc/pkgs/container/go2rtc).
## Versions ## Versions
- `alexxit/go2rtc:latest` - latest release based on `alpine` (`amd64`, `386`, `arm/v6`, `arm/v7`, `arm64`) with support hardware transcoding for Intel iGPU and Raspberry - `alexxit/go2rtc:latest` - latest release based on `alpine` (`amd64`, `386`, `arm/v6`, `arm/v7`, `arm64`) with support for hardware transcoding for Intel iGPU and Raspberry
- `alexxit/go2rtc:latest-hardware` - latest release based on `debian 13` (`amd64`) with support hardware transcoding for Intel iGPU, AMD GPU and NVidia GPU - `alexxit/go2rtc:latest-hardware` - latest release based on `debian 13` (`amd64`) with support for hardware transcoding for Intel iGPU, AMD GPU and NVidia GPU
- `alexxit/go2rtc:latest-rockchip` - latest release based on `debian 12` (`arm64`) with support hardware transcoding for Rockchip RK35xx - `alexxit/go2rtc:latest-rockchip` - latest release based on `debian 12` (`arm64`) with support for hardware transcoding for Rockchip RK35xx
- `alexxit/go2rtc:master` - latest unstable version based on `alpine` - `alexxit/go2rtc:master` - latest unstable version based on `alpine`
- `alexxit/go2rtc:master-hardware` - latest unstable version based on `debian 13` (`amd64`) - `alexxit/go2rtc:master-hardware` - latest unstable version based on `debian 13` (`amd64`)
- `alexxit/go2rtc:master-rockchip` - latest unstable version based on `debian 12` (`arm64`) - `alexxit/go2rtc:master-rockchip` - latest unstable version based on `debian 12` (`arm64`)
+1
View File
@@ -49,6 +49,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,t
COPY --from=build /build/go2rtc /usr/local/bin/ COPY --from=build /build/go2rtc /usr/local/bin/
EXPOSE 1984 8554 8555 8555/udp
ENTRYPOINT ["/usr/bin/tini", "--"] ENTRYPOINT ["/usr/bin/tini", "--"]
VOLUME /config VOLUME /config
WORKDIR /config WORKDIR /config
+1
View File
@@ -43,6 +43,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,t
COPY --from=build /build/go2rtc /usr/local/bin/ COPY --from=build /build/go2rtc /usr/local/bin/
ADD --chmod=755 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-8-no_extra_dump/ffmpeg /usr/local/bin ADD --chmod=755 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-8-no_extra_dump/ffmpeg /usr/local/bin
EXPOSE 1984 8554 8555 8555/udp
ENTRYPOINT ["/usr/bin/tini", "--"] ENTRYPOINT ["/usr/bin/tini", "--"]
VOLUME /config VOLUME /config
WORKDIR /config WORKDIR /config
+9
View File
@@ -0,0 +1,9 @@
module pinggy
go 1.25
require (
github.com/Pinggy-io/pinggy-go/pinggy v0.6.9 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/sys v0.7.0 // indirect
)
+39
View File
@@ -0,0 +1,39 @@
github.com/Pinggy-io/pinggy-go/pinggy v0.6.9 h1:lzZ00JK6BUGQXnpkJZ+cVj8kIkXsmiVBUci9uEkSwEY=
github.com/Pinggy-io/pinggy-go/pinggy v0.6.9/go.mod h1:V1Sxb+4zyr36o9atZiqtT4XhsKtW1RSb2GvsbTbTJYw=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+41
View File
@@ -0,0 +1,41 @@
package main
import (
"log"
"os"
"github.com/Pinggy-io/pinggy-go/pinggy"
)
func main() {
tunType := os.Args[1]
address := os.Args[2]
log.SetFlags(log.Llongfile | log.LstdFlags)
config := pinggy.Config{
Type: pinggy.TunnelType(tunType),
TcpForwardingAddr: address,
//SshOverSsl: true,
//Stdout: os.Stderr,
//Stderr: os.Stderr,
}
if tunType == "http" {
hman := pinggy.CreateHeaderManipulationAndAuthConfig()
//hman.SetReverseProxy(address)
//hman.SetPassPreflight(true)
//hman.SetNoReverseProxy()
config.HeaderManipulationAndAuth = hman
}
pl, err := pinggy.ConnectWithConfig(config)
if err != nil {
log.Panicln(err)
}
log.Println("Addrs: ", pl.RemoteUrls())
//err = pl.InitiateWebDebug("localhost:3424")
//log.Println(err)
pl.StartForwarding()
}
+1 -1
View File
@@ -1,4 +1,4 @@
## Example ## ONVIF Client
```shell ```shell
go run examples/onvif_client/main.go http://admin:password@192.168.10.90 GetAudioEncoderConfigurations go run examples/onvif_client/main.go http://admin:password@192.168.10.90 GetAudioEncoderConfigurations
+5
View File
@@ -0,0 +1,5 @@
# tutk_decoder
1. Wireshark > Select any packet > Follow > UDP Stream
2. Wireshark > File > Export Packet Dissections > As JSON > Displayed, Values
3. `tutk_decoder wireshark.json decoded.txt`
+82
View File
@@ -0,0 +1,82 @@
package main
import (
"encoding/hex"
"encoding/json"
"fmt"
"log"
"os"
"strings"
"github.com/AlexxIT/go2rtc/pkg/tutk"
)
func main() {
if len(os.Args) != 3 {
fmt.Println("Usage: tutk_decoder wireshark.json decoded.txt")
return
}
src, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer src.Close()
dst, err := os.Create(os.Args[2])
if err != nil {
log.Fatal(err)
}
defer dst.Close()
var items []item
if err = json.NewDecoder(src).Decode(&items); err != nil {
log.Fatal(err)
}
var b []byte
for _, v := range items {
if v.Source.Layers.Data.DataData == "" {
continue
}
s := strings.ReplaceAll(v.Source.Layers.Data.DataData, ":", "")
b, err = hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}
tutk.ReverseTransCodePartial(b, b)
ts := v.Source.Layers.Frame.FrameTimeRelative
_, _ = fmt.Fprintf(dst, "%8s: %s -> %s [%4d] %x\n",
ts[:len(ts)-6],
v.Source.Layers.Ip.IpSrc, v.Source.Layers.Ip.IpDst,
len(b), b)
}
}
type item struct {
Source struct {
Layers struct {
Frame struct {
FrameTimeRelative string `json:"frame.time_relative"`
FrameNumber string `json:"frame.number"`
} `json:"frame"`
Ip struct {
IpSrc string `json:"ip.src"`
IpDst string `json:"ip.dst"`
} `json:"ip"`
Udp struct {
UdpSrcport string `json:"udp.srcport"`
UdpDstport string `json:"udp.dstport"`
} `json:"udp"`
Data struct {
DataData string `json:"data.data"`
DataLen string `json:"data.len"`
} `json:"data"`
} `json:"layers"`
} `json:"_source"`
}
+26 -23
View File
@@ -3,47 +3,50 @@ module github.com/AlexxIT/go2rtc
go 1.24.0 go 1.24.0
require ( require (
github.com/asticode/go-astits v1.13.0 github.com/asticode/go-astits v1.14.0
github.com/expr-lang/expr v1.17.6 github.com/eclipse/paho.mqtt.golang v1.5.1
github.com/expr-lang/expr v1.17.7
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3 github.com/gorilla/websocket v1.5.3
github.com/mattn/go-isatty v0.0.20 github.com/mattn/go-isatty v0.0.20
github.com/miekg/dns v1.1.68 github.com/miekg/dns v1.1.70
github.com/pion/ice/v4 v4.0.10 github.com/pion/dtls/v3 v3.0.10
github.com/pion/interceptor v0.1.41 github.com/pion/ice/v4 v4.2.0
github.com/pion/interceptor v0.1.43
github.com/pion/rtcp v1.2.16 github.com/pion/rtcp v1.2.16
github.com/pion/rtp v1.8.24 github.com/pion/rtp v1.10.0
github.com/pion/sdp/v3 v3.0.16 github.com/pion/sdp/v3 v3.0.17
github.com/pion/srtp/v3 v3.0.8 github.com/pion/srtp/v3 v3.0.10
github.com/pion/stun/v3 v3.0.0 github.com/pion/stun/v3 v3.1.1
github.com/pion/webrtc/v4 v4.1.6 github.com/pion/webrtc/v4 v4.2.3
github.com/rs/zerolog v1.34.0 github.com/rs/zerolog v1.34.0
github.com/sigurn/crc16 v0.0.0-20240131213347-83fcde1e29d1 github.com/sigurn/crc16 v0.0.0-20240131213347-83fcde1e29d1
github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f
github.com/stretchr/testify v1.11.1 github.com/stretchr/testify v1.11.1
github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9 github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9
golang.org/x/crypto v0.43.0 golang.org/x/crypto v0.47.0
golang.org/x/net v0.49.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
require ( require (
github.com/asticode/go-astikit v0.56.0 // indirect github.com/asticode/go-astikit v0.57.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-colorable v0.1.14 // indirect
github.com/pion/datachannel v1.5.10 // indirect github.com/pion/datachannel v1.6.0 // indirect
github.com/pion/dtls/v3 v3.0.7 // indirect
github.com/pion/logging v0.2.4 // indirect github.com/pion/logging v0.2.4 // indirect
github.com/pion/mdns/v2 v2.0.7 // indirect github.com/pion/mdns/v2 v2.1.0 // indirect
github.com/pion/randutil v0.1.0 // indirect github.com/pion/randutil v0.1.0 // indirect
github.com/pion/sctp v1.8.40 // indirect github.com/pion/sctp v1.9.2 // indirect
github.com/pion/transport/v3 v3.0.8 // indirect github.com/pion/transport/v3 v3.1.1 // indirect
github.com/pion/turn/v4 v4.1.1 // indirect github.com/pion/transport/v4 v4.0.1 // indirect
github.com/pion/turn/v4 v4.1.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/wlynxg/anet v0.0.5 // indirect github.com/wlynxg/anet v0.0.5 // indirect
golang.org/x/mod v0.29.0 // indirect golang.org/x/mod v0.32.0 // indirect
golang.org/x/net v0.46.0 // indirect golang.org/x/sync v0.19.0 // indirect
golang.org/x/sync v0.17.0 // indirect golang.org/x/sys v0.40.0 // indirect
golang.org/x/sys v0.37.0 // indirect golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.38.0 // indirect golang.org/x/tools v0.41.0 // indirect
) )
+88 -114
View File
@@ -1,22 +1,22 @@
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0= github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astikit v0.54.0 h1:uq9eurgisdkYwJU9vSWIQaPH4MH0cac82sQH00kmSNQ= github.com/asticode/go-astikit v0.57.1 h1:fEykwH98Nny08kcRbk4uer+S8h0rKveCIpG9F6NVLuA=
github.com/asticode/go-astikit v0.54.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE= github.com/asticode/go-astikit v0.57.1/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE=
github.com/asticode/go-astikit v0.56.0 h1:DmD2p7YnvxiPdF0h+dRmos3bsejNEXbycENsY5JfBqw= github.com/asticode/go-astits v1.14.0 h1:zkgnZzipx2XX5mWycqsSBeEyDH58+i4HtyF4j2ROb00=
github.com/asticode/go-astikit v0.56.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE= github.com/asticode/go-astits v1.14.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
github.com/asticode/go-astits v1.13.0 h1:XOgkaadfZODnyZRR5Y0/DWkA9vrkLLPLeeOvDwfKZ1c=
github.com/asticode/go-astits v1.13.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/expr-lang/expr v1.17.2 h1:o0A99O/Px+/DTjEnQiodAgOIK9PPxL8DtXhBRKC+Iso= github.com/eclipse/paho.mqtt.golang v1.5.1 h1:/VSOv3oDLlpqR2Epjn1Q7b2bSTplJIeV2ISgCl2W7nE=
github.com/expr-lang/expr v1.17.2/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/eclipse/paho.mqtt.golang v1.5.1/go.mod h1:1/yJCneuyOoCOzKSsOTUc0AJfpsItBGWvYpBLimhArU=
github.com/expr-lang/expr v1.17.5 h1:i1WrMvcdLF249nSNlpQZN1S6NXuW9WaOfF5tPi3aw3k=
github.com/expr-lang/expr v1.17.5/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/expr-lang/expr v1.17.6 h1:1h6i8ONk9cexhDmowO/A64VPxHScu7qfSl2k8OlINec= github.com/expr-lang/expr v1.17.6 h1:1h6i8ONk9cexhDmowO/A64VPxHScu7qfSl2k8OlINec=
github.com/expr-lang/expr v1.17.6/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/expr-lang/expr v1.17.6/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/expr-lang/expr v1.17.7 h1:Q0xY/e/2aCIp8g9s/LGvMDCC5PxYlvHgDZRQ4y16JX8=
github.com/expr-lang/expr v1.17.7/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
@@ -32,82 +32,66 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY= github.com/miekg/dns v1.1.69 h1:Kb7Y/1Jo+SG+a2GtfoFUfDkG//csdRPwRLkCsxDG9Sc=
github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs= github.com/miekg/dns v1.1.69/go.mod h1:7OyjD9nEba5OkqQ/hB4fy3PIoxafSZJtducccIelz3g=
github.com/miekg/dns v1.1.66 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE= github.com/miekg/dns v1.1.70 h1:DZ4u2AV35VJxdD9Fo9fIWm119BsQL5cZU1cQ9s0LkqA=
github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE= github.com/miekg/dns v1.1.70/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs=
github.com/miekg/dns v1.1.68 h1:jsSRkNozw7G/mnmXULynzMNIsgY2dHC8LO6U6Ij2JEA=
github.com/miekg/dns v1.1.68/go.mod h1:fujopn7TB3Pu3JM69XaawiU0wqjpL9/8xGop5UrTPps=
github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o= github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M= github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E= github.com/pion/datachannel v1.6.0 h1:XecBlj+cvsxhAMZWFfFcPyUaDZtd7IJvrXqlXD/53i0=
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU= github.com/pion/datachannel v1.6.0/go.mod h1:ur+wzYF8mWdC+Mkis5Thosk+u/VOL287apDNEbFpsIk=
github.com/pion/dtls/v3 v3.0.7 h1:bItXtTYYhZwkPFk4t1n3Kkf5TDrfj6+4wG+CZR8uI9Q= github.com/pion/dtls/v3 v3.0.9 h1:4AijfFRm8mAjd1gfdlB1wzJF3fjjR/VPIpJgkEtvYmM=
github.com/pion/dtls/v3 v3.0.7/go.mod h1:uDlH5VPrgOQIw59irKYkMudSFprY9IEFCqz/eTz16f8= github.com/pion/dtls/v3 v3.0.9/go.mod h1:abApPjgadS/ra1wvUzHLc3o2HvoxppAh+NZkyApL4Os=
github.com/pion/ice/v4 v4.0.9 h1:VKgU4MwA2LUDVLq+WBkpEHTcAb8c5iCvFMECeuPOZNk= github.com/pion/dtls/v3 v3.0.10 h1:k9ekkq1kaZoxnNEbyLKI8DI37j/Nbk1HWmMuywpQJgg=
github.com/pion/ice/v4 v4.0.9/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw= github.com/pion/dtls/v3 v3.0.10/go.mod h1:YEmmBYIoBsY3jmG56dsziTv/Lca9y4Om83370CXfqJ8=
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4= github.com/pion/ice/v4 v4.1.0 h1:YlxIii2bTPWyC08/4hdmtYq4srbrY0T9xcTsTjldGqU=
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw= github.com/pion/ice/v4 v4.1.0/go.mod h1:5gPbzYxqenvn05k7zKPIZFuSAufolygiy6P1U9HzvZ4=
github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI= github.com/pion/ice/v4 v4.2.0 h1:jJC8S+CvXCCvIQUgx+oNZnoUpt6zwc34FhjWwCU4nlw=
github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y= github.com/pion/ice/v4 v4.2.0/go.mod h1:EgjBGxDgmd8xB0OkYEVFlzQuEI7kWSCFu+mULqaisy4=
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4= github.com/pion/interceptor v0.1.42 h1:0/4tvNtruXflBxLfApMVoMubUMik57VZ+94U0J7cmkQ=
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic= github.com/pion/interceptor v0.1.42/go.mod h1:g6XYTChs9XyolIQFhRHOOUS+bGVGLRfgTCUzH29EfVU=
github.com/pion/interceptor v0.1.41 h1:NpvX3HgWIukTf2yTBVjVGFXtpSpWgXjqz7IIpu7NsOw= github.com/pion/interceptor v0.1.43 h1:6hmRfnmjogSs300xfkR0JxYFZ9k5blTEvCD7wxEDuNQ=
github.com/pion/interceptor v0.1.41/go.mod h1:nEt4187unvRXJFyjiw00GKo+kIuXMWQI9K89fsosDLY= github.com/pion/interceptor v0.1.43/go.mod h1:BSiC1qKIJt1XVr3l3xQ2GEmCFStk9tx8fwtCZxxgR7M=
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8= github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so= github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM= github.com/pion/mdns/v2 v2.1.0 h1:3IJ9+Xio6tWYjhN6WwuY142P/1jA0D5ERaIqawg/fOY=
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA= github.com/pion/mdns/v2 v2.1.0/go.mod h1:pcez23GdynwcfRU1977qKU0mDxSeucttSHbCSfFOd9A=
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo=
github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0=
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo= github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo= github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
github.com/pion/rtp v1.8.13 h1:8uSUPpjSL4OlwZI8Ygqu7+h2p9NPFB+yAZ461Xn5sNg= github.com/pion/rtp v1.8.26 h1:VB+ESQFQhBXFytD+Gk8cxB6dXeVf2WQzg4aORvAvAAc=
github.com/pion/rtp v1.8.13/go.mod h1:8uMBJj32Pa1wwx8Fuv/AsFhn8jsgw+3rUC2PfoBZ8p4= github.com/pion/rtp v1.8.26/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
github.com/pion/rtp v1.8.20 h1:8zcyqohadZE8FCBeGdyEvHiclPIezcwRQH9zfapFyYI= github.com/pion/rtp v1.10.0 h1:XN/xca4ho6ZEcijpdF2VGFbwuHUfiIMf3ew8eAAE43w=
github.com/pion/rtp v1.8.20/go.mod h1:bAu2UFKScgzyFqvUKmbvzSdPr+NGbZtv6UB2hesqXBk= github.com/pion/rtp v1.10.0/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
github.com/pion/rtp v1.8.24 h1:+ICyZXUQDv95EsHN70RrA4XKJf5MGWyC6QQc1u6/ynI= github.com/pion/sctp v1.8.41 h1:20R4OHAno4Vky3/iE4xccInAScAa83X6nWUfyc65MIs=
github.com/pion/rtp v1.8.24/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM= github.com/pion/sctp v1.8.41/go.mod h1:2wO6HBycUH7iCssuGyc2e9+0giXVW0pyCv3ZuL8LiyY=
github.com/pion/sctp v1.8.37 h1:ZDmGPtRPX9mKCiVXtMbTWybFw3z/hVKAZgU81wcOrqs= github.com/pion/sctp v1.9.2 h1:HxsOzEV9pWoeggv7T5kewVkstFNcGvhMPx0GvUOUQXo=
github.com/pion/sctp v1.8.37/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE= github.com/pion/sctp v1.9.2/go.mod h1:OTOlsQ5EDQ6mQ0z4MUGXt2CgQmKyafBEXhUVqLRB6G8=
github.com/pion/sctp v1.8.39 h1:PJma40vRHa3UTO3C4MyeJDQ+KIobVYRZQZ0Nt7SjQnE=
github.com/pion/sctp v1.8.39/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE=
github.com/pion/sctp v1.8.40 h1:bqbgWYOrUhsYItEnRObUYZuzvOMsVplS3oNgzedBlG8=
github.com/pion/sctp v1.8.40/go.mod h1:SPBBUENXE6ThkEksN5ZavfAhFYll+h+66ZiG6IZQuzo=
github.com/pion/sdp/v3 v3.0.11 h1:VhgVSopdsBKwhCFoyyPmT1fKMeV9nLMrEKxNOdy3IVI=
github.com/pion/sdp/v3 v3.0.11/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E=
github.com/pion/sdp/v3 v3.0.14 h1:1h7gBr9FhOWH5GjWWY5lcw/U85MtdcibTyt/o6RxRUI=
github.com/pion/sdp/v3 v3.0.14/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E=
github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo= github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo=
github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo= github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo=
github.com/pion/srtp/v3 v3.0.4 h1:2Z6vDVxzrX3UHEgrUyIGM4rRouoC7v+NiF1IHtp9B5M= github.com/pion/sdp/v3 v3.0.17 h1:9SfLAW/fF1XC8yRqQ3iWGzxkySxup4k4V7yN8Fs8nuo=
github.com/pion/srtp/v3 v3.0.4/go.mod h1:1Jx3FwDoxpRaTh1oRV8A/6G1BnFL+QI82eK4ms8EEJQ= github.com/pion/sdp/v3 v3.0.17/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo=
github.com/pion/srtp/v3 v3.0.6 h1:E2gyj1f5X10sB/qILUGIkL4C2CqK269Xq167PbGCc/4= github.com/pion/srtp/v3 v3.0.9 h1:lRGF4G61xxj+m/YluB3ZnBpiALSri2lTzba0kGZMrQY=
github.com/pion/srtp/v3 v3.0.6/go.mod h1:BxvziG3v/armJHAaJ87euvkhHqWe9I7iiOy50K2QkhY= github.com/pion/srtp/v3 v3.0.9/go.mod h1:E+AuWd7Ug2Fp5u38MKnhduvpVkveXJX6J4Lq4rxUYt8=
github.com/pion/srtp/v3 v3.0.8 h1:RjRrjcIeQsilPzxvdaElN0CpuQZdMvcl9VZ5UY9suUM= github.com/pion/srtp/v3 v3.0.10 h1:tFirkpBb3XccP5VEXLi50GqXhv5SKPxqrdlhDCJlZrQ=
github.com/pion/srtp/v3 v3.0.8/go.mod h1:2Sq6YnDH7/UDCvkSoHSDNDeyBcFgWL0sAVycVbAsXFg= github.com/pion/srtp/v3 v3.0.10/go.mod h1:3mOTIB0cq9qlbn59V4ozvv9ClW/BSEbRp4cY0VtaR7M=
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw= github.com/pion/stun/v3 v3.0.2 h1:BJuGEN2oLrJisiNEJtUTJC4BGbzbfp37LizfqswblFU=
github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU= github.com/pion/stun/v3 v3.0.2/go.mod h1:JFJKfIWvt178MCF5H/YIgZ4VX3LYE77vca4b9HP60SA=
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0= github.com/pion/stun/v3 v3.1.1 h1:CkQxveJ4xGQjulGSROXbXq94TAWu8gIX2dT+ePhUkqw=
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo= github.com/pion/stun/v3 v3.1.1/go.mod h1:qC1DfmcCTQjl9PBaMa5wSn3x9IPmKxSdcCsxBcDBndM=
github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc= github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=
github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ= github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM= github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA= github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
github.com/pion/turn/v4 v4.0.2 h1:ZqgQ3+MjP32ug30xAbD6Mn+/K4Sxi3SdNOTFf+7mpps= github.com/pion/turn/v4 v4.1.3 h1:jVNW0iR05AS94ysEtvzsrk3gKs9Zqxf6HmnsLfRvlzA=
github.com/pion/turn/v4 v4.0.2/go.mod h1:pMMKP/ieNAG/fN5cZiN4SDuyKsXtNTr0ccN7IToA1zs= github.com/pion/turn/v4 v4.1.3/go.mod h1:TD/eiBUf5f5LwXbCJa35T7dPtTpCHRJ9oJWmyPLVT3A=
github.com/pion/turn/v4 v4.1.1 h1:9UnY2HB99tpDyz3cVVZguSxcqkJ1DsTSZ+8TGruh4fc= github.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=
github.com/pion/turn/v4 v4.1.1/go.mod h1:2123tHk1O++vmjI5VSD0awT50NywDAq5A2NNNU4Jjs8= github.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=
github.com/pion/webrtc/v4 v4.0.14 h1:nyds/sFRR+HvmWoBa6wrL46sSfpArE0qR883MBW96lg= github.com/pion/webrtc/v4 v4.1.8 h1:ynkjfiURDQ1+8EcJsoa60yumHAmyeYjz08AaOuor+sk=
github.com/pion/webrtc/v4 v4.0.14/go.mod h1:R3+qTnQTS03UzwDarYecgioNf7DYgTsldxnCXB821Kk= github.com/pion/webrtc/v4 v4.1.8/go.mod h1:KVaARG2RN0lZx0jc7AWTe38JpPv+1/KicOZ9jN52J/s=
github.com/pion/webrtc/v4 v4.1.3 h1:YZ67Boj9X/hk190jJZ8+HFGQ6DqSZ/fYP3sLAZv7c3c= github.com/pion/webrtc/v4 v4.2.3 h1:RtdWDnkenNQGxUrZqWa5gSkTm5ncsLg5d+zu0M4cXt4=
github.com/pion/webrtc/v4 v4.1.3/go.mod h1:rsq+zQ82ryfR9vbb0L1umPJ6Ogq7zm8mcn9fcGnxomM= github.com/pion/webrtc/v4 v4.2.3/go.mod h1:7vsyFzRzaKP5IELUnj8zLcglPyIT6wWwqTppBZ1k6Kc=
github.com/pion/webrtc/v4 v4.1.6 h1:srHH2HwvCGwPba25EYJgUzgLqCQoXl1VCUnrGQMSzUw=
github.com/pion/webrtc/v4 v4.1.6/go.mod h1:wKecGRlkl3ox/As/MYghJL+b/cVXMEhoPMJWPuGQFhU=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE= github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
@@ -124,55 +108,45 @@ github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f h1:1R9KdKjCNSd7F8iGTxI
github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f/go.mod h1:vQhwQ4meQEDfahT5kd61wLAF5AAeh5ZPLVI4JJ/tYo8= github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f/go.mod h1:vQhwQ4meQEDfahT5kd61wLAF5AAeh5ZPLVI4JJ/tYo8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9 h1:aeN+ghOV0b2VCmKKO3gqnDQ8mLbpABZgRR2FVYx4ouI= github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9 h1:aeN+ghOV0b2VCmKKO3gqnDQ8mLbpABZgRR2FVYx4ouI=
github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9/go.mod h1:roo6cZ/uqpwKMuvPG0YmzI5+AmUiMWfjCBZpGXqbTxE= github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9/go.mod h1:roo6cZ/uqpwKMuvPG0YmzI5+AmUiMWfjCBZpGXqbTxE=
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU= github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+113
View File
@@ -0,0 +1,113 @@
# Modules
go2rtc tries to name formats, protocols and codecs the same way they are named in FFmpeg.
Some formats and protocols go2rtc supports exclusively. They have no equivalent in FFmpeg.
- The [`echo`], [`expr`], [`hass`] and [`onvif`] modules receive a link to a stream. They don't know the protocol in advance.
- The [`exec`] and [`ffmpeg`] modules support many formats. They are identical to the [`http`] module.
- The [`api`], [`app`], [`debug`], [`ngrok`], [`pinggy`], [`srtp`], [`streams`] are supporting modules.
**Modules** implement communication APIs: authorization, encryption, command set, structure of media packets.
**Formats** describe the structure of the data being transmitted.
**Protocols** implement transport for data transmission.
| module | formats | protocols | input | output | ingest | two-way |
|----------------|-----------------|------------------|-------|--------|--------|---------|
| [`alsa`] | `pcm` | `ioctl` | yes | | | |
| [`bubble`] | - | `http` | yes | | | |
| [`doorbird`] | `mulaw` | `http` | yes | | | yes |
| [`dvrip`] | - | `tcp` | yes | | | yes |
| [`echo`] | * | * | yes | | | |
| [`eseecloud`] | `rtp` | `http` | yes | | | |
| [`exec`] | * | `pipe`, `rtsp` | yes | | | yes |
| [`expr`] | * | * | yes | | | |
| [`ffmpeg`] | * | `pipe`, `rtsp` | yes | | | |
| [`flussonic`] | `mp4` | `ws` | yes | | | |
| [`gopro`] | `mpegts` | `udp` | yes | | | |
| [`hass`] | * | * | yes | | | |
| [`hls`] | `mpegts`, `mp4` | `http` | | yes | | |
| [`homekit`] | `srtp` | `hap` | yes | yes | | no |
| [`http`] | `adts` | `http`, `tcp` | yes | | | |
| [`http`] | `flv` | `http`, `tcp` | yes | | | |
| [`http`] | `h264` | `http`, `tcp` | yes | | | |
| [`http`] | `hevc` | `http`, `tcp` | yes | | | |
| [`http`] | `hls` | `http`, `tcp` | yes | | | |
| [`http`] | `mjpeg` | `http`, `tcp` | yes | | | |
| [`http`] | `mpjpeg` | `http` | yes | | | |
| [`http`] | `mpegts` | `http`, `tcp` | yes | | | |
| [`http`] | `wav` | `http`, `tcp` | yes | | | |
| [`http`] | `yuv4mpegpipe` | `http`, `tcp` | yes | | | |
| [`isapi`] | `alaw`, `mulaw` | `http` | | | | yes |
| [`ivideon`] | `mp4` | `ws` | yes | | | |
| [`kasa`] | `h264`, `mulaw` | `http` | yes | | | |
| [`mjpeg`] | `ascii` | `http` | | yes | | |
| [`mjpeg`] | `jpeg` | `http` | | yes | | |
| [`mjpeg`] | `mpjpeg` | `http` | | yes | yes | |
| [`mjpeg`] | `yuv4mpegpipe` | `http` | | yes | | |
| [`mp4`] | `mp4` | `http`, `ws` | | yes | | |
| [`mpeg`] | `adts` | `http` | | yes | | |
| [`mpeg`] | `mpegts` | `http` | | yes | yes | |
| [`multitrans`] | `rtp` | `tcp` | | | | yes |
| [`nest`] | `srtp` | `rtsp`, `webrtc` | yes | | | no |
| [`onvif`] | `rtp` | * | yes | yes | | |
| [`ring`] | `srtp` | `webrtc` | yes | | | yes |
| [`roborock`] | `srtp` | `webrtc` | yes | | | yes |
| [`rtmp`] | `flv` | `rtmp` | yes | yes | yes | |
| [`rtmp`] | `flv` | `http` | | yes | yes | |
| [`rtsp`] | `rtsp` | `rtsp` | yes | yes | yes | yes |
| [`tapo`] | `mpegts` | `http` | yes | | | yes |
| [`tuya`] | `srtp` | `webrtc` | yes | | | yes |
| [`v4l2`] | `rawvideo` | `ioctl` | yes | | | |
| [`webrtc`] | `srtp` | `webrtc` | yes | yes | yes | yes |
| [`webtorrent`] | `srtp` | `webrtc` | yes | yes | | |
| [`wyoming`] | `pcm` | `tcp` | | yes | | |
| [`wyze`] | - | `tutk` | yes | | | yes |
| [`xiaomi`] | - | `cs2`, `tutk` | yes | | | yes |
| [`yandex`] | `srtp` | `webrtc` | yes | | | |
[`alsa`]: alsa/README.md
[`api`]: api/README.md
[`app`]: app/README.md
[`bubble`]: bubble/README.md
[`debug`]: debug/README.md
[`doorbird`]: doorbird/README.md
[`dvrip`]: dvrip/README.md
[`echo`]: echo/README.md
[`eseecloud`]: eseecloud/README.md
[`exec`]: exec/README.md
[`expr`]: expr/README.md
[`ffmpeg`]: ffmpeg/README.md
[`flussonic`]: flussonic/README.md
[`gopro`]: gopro/README.md
[`hass`]: hass/README.md
[`hls`]: hls/README.md
[`homekit`]: homekit/README.md
[`http`]: http/README.md
[`isapi`]: isapi/README.md
[`ivideon`]: ivideon/README.md
[`kasa`]: kasa/README.md
[`mjpeg`]: mjpeg/README.md
[`mp4`]: mp4/README.md
[`mpeg`]: mpeg/README.md
[`multitrans`]: multitrans/README.md
[`nest`]: nest/README.md
[`ngrok`]: ngrok/README.md
[`onvif`]: onvif/README.md
[`pinggy`]: pinggy/README.md
[`ring`]: ring/README.md
[`roborock`]: roborock/README.md
[`rtmp`]: rtmp/README.md
[`rtsp`]: rtsp/README.md
[`srtp`]: srtp/README.md
[`streams`]: streams/README.md
[`tapo`]: tapo/README.md
[`tuya`]: tuya/README.md
[`v4l2`]: v4l2/README.md
[`webrtc`]: webrtc/README.md
[`webtorrent`]: webtorrent/README.md
[`wyoming`]: wyze/README.md
[`wyze`]: wyze/README.md
[`xiaomi`]: xiaomi/README.md
[`yandex`]: yandex/README.md
+12
View File
@@ -0,0 +1,12 @@
# ALSA
[`new in v1.9.10`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.10)
> [!WARNING]
> This source is under development and does not always work well.
[Advanced Linux Sound Architecture](https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture) - a framework for receiving audio from devices on Linux OS.
Easy to add via **WebUI > add > ALSA**.
Alternatively, you can use FFmpeg source.
+44 -3
View File
@@ -1,4 +1,45 @@
## Exit codes # HTTP API
- https://tldp.org/LDP/abs/html/exitcodes.html The HTTP API is the main part for interacting with the application. Default address: `http://localhost:1984/`.
- https://komodor.com/learn/exit-codes-in-containers-and-kubernetes-the-complete-guide/
The HTTP API is described in [OpenAPI](../../website/api/openapi.yaml) format. It can be explored in [interactive viewer](https://go2rtc.org/api/). WebSocket API described [here](ws/README.md).
The project's static HTML and JS files are located in the [www](../../www/README.md) folder. An external developer can use them as a basis for integrating go2rtc into their project or for developing a custom web interface for go2rtc.
The contents of `www` folder are built into go2rtc when building, but you can use configuration to specify an external folder as the source of static files.
## Configuration
**Important!** go2rtc passes requests from localhost and Unix sockets without HTTP authorization, even if you have it configured. It is your responsibility to set up secure external access to the API. If not properly configured, an attacker can gain access to your cameras and even your server.
- you can disable HTTP API with `listen: ""` and use, for example, only RTSP client/server protocol
- you can enable HTTP API only on localhost with `listen: "127.0.0.1:1984"` setting
- you can change the API `base_path` and host go2rtc on your main app webserver suburl
- all files from `static_dir` hosted on root path: `/`
- you can use raw TLS cert/key content or path to files
```yaml
api:
listen: ":1984" # default ":1984", HTTP API port ("" - disabled)
username: "admin" # default "", Basic auth for WebUI
password: "pass" # default "", Basic auth for WebUI
local_auth: true # default false, Enable auth check for localhost requests
base_path: "/rtc" # default "", API prefix for serving on suburl (/api => /rtc/api)
static_dir: "www" # default "", folder for static files (custom web interface)
origin: "*" # default "", allow CORS requests (only * supported)
tls_listen: ":443" # default "", enable HTTPS server
tls_cert: | # default "", PEM-encoded fullchain certificate for HTTPS
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
tls_key: | # default "", PEM-encoded private key for HTTPS
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
unix_listen: "/tmp/go2rtc.sock" # default "", unix socket listener for API
```
**PS:**
- MJPEG over WebSocket plays better than native MJPEG because Chrome [bug](https://bugs.chromium.org/p/chromium/issues/detail?id=527446)
- MP4 over WebSocket was created only for Apple iOS because it doesn't support file streaming
+17 -3
View File
@@ -7,6 +7,7 @@ import (
"net" "net"
"net/http" "net/http"
"os" "os"
"slices"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@@ -23,6 +24,7 @@ func Init() {
Listen string `yaml:"listen"` Listen string `yaml:"listen"`
Username string `yaml:"username"` Username string `yaml:"username"`
Password string `yaml:"password"` Password string `yaml:"password"`
LocalAuth bool `yaml:"local_auth"`
BasePath string `yaml:"base_path"` BasePath string `yaml:"base_path"`
StaticDir string `yaml:"static_dir"` StaticDir string `yaml:"static_dir"`
Origin string `yaml:"origin"` Origin string `yaml:"origin"`
@@ -30,6 +32,8 @@ func Init() {
TLSCert string `yaml:"tls_cert"` TLSCert string `yaml:"tls_cert"`
TLSKey string `yaml:"tls_key"` TLSKey string `yaml:"tls_key"`
UnixListen string `yaml:"unix_listen"` UnixListen string `yaml:"unix_listen"`
AllowPaths []string `yaml:"allow_paths"`
} `yaml:"api"` } `yaml:"api"`
} }
@@ -43,6 +47,7 @@ func Init() {
return return
} }
allowPaths = cfg.Mod.AllowPaths
basePath = cfg.Mod.BasePath basePath = cfg.Mod.BasePath
log = app.GetLogger("api") log = app.GetLogger("api")
@@ -61,7 +66,7 @@ func Init() {
} }
if cfg.Mod.Username != "" { if cfg.Mod.Username != "" {
Handler = middlewareAuth(cfg.Mod.Username, cfg.Mod.Password, Handler) // 2nd Handler = middlewareAuth(cfg.Mod.Username, cfg.Mod.Password, cfg.Mod.LocalAuth, Handler) // 2nd
} }
if log.Trace().Enabled() { if log.Trace().Enabled() {
@@ -152,6 +157,10 @@ func HandleFunc(pattern string, handler http.HandlerFunc) {
if len(pattern) == 0 || pattern[0] != '/' { if len(pattern) == 0 || pattern[0] != '/' {
pattern = basePath + "/" + pattern pattern = basePath + "/" + pattern
} }
if allowPaths != nil && !slices.Contains(allowPaths, pattern) {
log.Trace().Str("path", pattern).Msg("[api] ignore path not in allow_paths")
return
}
log.Trace().Str("path", pattern).Msg("[api] register path") log.Trace().Str("path", pattern).Msg("[api] register path")
http.HandleFunc(pattern, handler) http.HandleFunc(pattern, handler)
} }
@@ -185,6 +194,7 @@ func Response(w http.ResponseWriter, body any, contentType string) {
const StreamNotFound = "stream not found" const StreamNotFound = "stream not found"
var allowPaths []string
var basePath string var basePath string
var log zerolog.Logger var log zerolog.Logger
@@ -195,9 +205,13 @@ func middlewareLog(next http.Handler) http.Handler {
}) })
} }
func middlewareAuth(username, password string, next http.Handler) http.Handler { func isLoopback(remoteAddr string) bool {
return strings.HasPrefix(remoteAddr, "127.") || strings.HasPrefix(remoteAddr, "[::1]") || remoteAddr == "@"
}
func middlewareAuth(username, password string, localAuth bool, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.RemoteAddr, "127.") && !strings.HasPrefix(r.RemoteAddr, "[::1]") && r.RemoteAddr != "@" { if localAuth || !isLoopback(r.RemoteAddr) {
user, pass, ok := r.BasicAuth() user, pass, ok := r.BasicAuth()
if !ok || user != username || pass != password { if !ok || user != username || pass != password {
w.Header().Set("Www-Authenticate", `Basic realm="go2rtc"`) w.Header().Set("Www-Authenticate", `Basic realm="go2rtc"`)
+69
View File
@@ -0,0 +1,69 @@
# WebSocket
Endpoint: `/api/ws`
Query parameters:
- `src` (required) - Stream name
### WebRTC
Request SDP:
```json
{"type":"webrtc/offer","value":"v=0\r\n..."}
```
Response SDP:
```json
{"type":"webrtc/answer","value":"v=0\r\n..."}
```
Request/response candidate:
- empty value also allowed and optional
```json
{"type":"webrtc/candidate","value":"candidate:3277516026 1 udp 2130706431 192.168.1.123 54321 typ host"}
```
### MSE
Request:
- codecs list optional
```json
{"type":"mse","value":"avc1.640029,avc1.64002A,avc1.640033,hvc1.1.6.L153.B0,mp4a.40.2,mp4a.40.5,flac,opus"}
```
Response:
```json
{"type":"mse","value":"video/mp4; codecs=\"avc1.64001F,mp4a.40.2\""}
```
### HLS
Request:
```json
{"type":"hls","value":"avc1.640029,avc1.64002A,avc1.640033,hvc1.1.6.L153.B0,mp4a.40.2,mp4a.40.5,flac"}
```
Response:
- you MUST rewrite full HTTP path to `http://192.168.1.123:1984/api/hls/playlist.m3u8`
```json
{"type":"hls","value":"#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=1000000,CODECS=\"avc1.64001F,mp4a.40.2\"\nhls/playlist.m3u8?id=DvmHdd9w"}
```
### MJPEG
Request/response:
```json
{"type":"mjpeg"}
```
+2 -2
View File
@@ -11,7 +11,7 @@ import (
"github.com/AlexxIT/go2rtc/internal/api" "github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/app" "github.com/AlexxIT/go2rtc/internal/app"
"github.com/AlexxIT/go2rtc/pkg/core" "github.com/AlexxIT/go2rtc/pkg/creds"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/rs/zerolog" "github.com/rs/zerolog"
) )
@@ -133,7 +133,7 @@ func apiWS(w http.ResponseWriter, r *http.Request) {
if handler := wsHandlers[msg.Type]; handler != nil { if handler := wsHandlers[msg.Type]; handler != nil {
go func() { go func() {
if err = handler(tr, msg); err != nil { if err = handler(tr, msg); err != nil {
errMsg := core.StripUserinfo(err.Error()) errMsg := creds.SecretString(err.Error())
tr.Write(&Message{Type: "error", Value: msg.Type + ": " + errMsg}) tr.Write(&Message{Type: "error", Value: msg.Type + ": " + errMsg})
} }
}() }()
+44 -17
View File
@@ -1,17 +1,23 @@
- By default go2rtc will search config file `go2rtc.yaml` in current work directory # App
- go2rtc support multiple config files:
- `go2rtc -c config1.yaml -c config2.yaml -c config3.yaml` The application module is responsible for reading configuration files, running other modules and setting up [logs](#log).
- go2rtc support inline config as multiple formats from command line:
The configuration can be edited through the application's WebUI with code highlighting, syntax and specification checking.
- By default, go2rtc will search for the `go2rtc.yaml` config file in the current working directory
- go2rtc supports multiple config files:
- `go2rtc -c config1.yaml -c config2.yaml -c config3.yaml`
- go2rtc supports inline config in multiple formats from the command line:
- **YAML**: `go2rtc -c '{log: {format: text}}'` - **YAML**: `go2rtc -c '{log: {format: text}}'`
- **JSON**: `go2rtc -c '{"log":{"format":"text"}}'` - **JSON**: `go2rtc -c '{"log":{"format":"text"}}'`
- **key=value**: `go2rtc -c log.format=text` - **key=value**: `go2rtc -c log.format=text`
- Every next config will overwrite previous (but only defined params) - Each subsequent config will overwrite the previous one (but only for defined params)
``` ```
go2rtc -config "{log: {format: text}}" -config /config/go2rtc.yaml -config "{rtsp: {listen: ''}}" -config /usr/local/go2rtc/go2rtc.yaml go2rtc -config "{log: {format: text}}" -config /config/go2rtc.yaml -config "{rtsp: {listen: ''}}" -config /usr/local/go2rtc/go2rtc.yaml
``` ```
or simple version or a simpler version
``` ```
go2rtc -c log.format=text -c /config/go2rtc.yaml -c rtsp.listen='' -c /usr/local/go2rtc/go2rtc.yaml go2rtc -c log.format=text -c /config/go2rtc.yaml -c rtsp.listen='' -c /usr/local/go2rtc/go2rtc.yaml
@@ -19,7 +25,7 @@ go2rtc -c log.format=text -c /config/go2rtc.yaml -c rtsp.listen='' -c /usr/local
## Environment variables ## Environment variables
There is support for loading external variables into the config. First, they will be attempted to be loaded from [credential files](https://systemd.io/CREDENTIALS). If `CREDENTIALS_DIRECTORY` is not set, then the key will be loaded from an environment variable. If no environment variable is set, then the string will be left as-is. There is support for loading external variables into the config. First, they will be loaded from [credential files](https://systemd.io/CREDENTIALS). If `CREDENTIALS_DIRECTORY` is not set, then the key will be loaded from an environment variable. If no environment variable is set, then the string will be left as-is.
```yaml ```yaml
streams: streams:
@@ -32,10 +38,16 @@ rtsp:
## JSON Schema ## JSON Schema
Editors like [GoLand](https://www.jetbrains.com/go/) and [VS Code](https://code.visualstudio.com/) supports autocomplete and syntax validation. Editors like [GoLand](https://www.jetbrains.com/go/) and [VS Code](https://code.visualstudio.com/) support autocomplete and syntax validation.
```yaml ```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/AlexxIT/go2rtc/master/website/schema.json # yaml-language-server: $schema=https://raw.githubusercontent.com/AlexxIT/go2rtc/master/www/schema.json
```
or from a running go2rtc:
```yaml
# yaml-language-server: $schema=http://localhost:1984/schema.json
``` ```
## Defaults ## Defaults
@@ -45,26 +57,41 @@ Editors like [GoLand](https://www.jetbrains.com/go/) and [VS Code](https://code.
```yaml ```yaml
api: api:
listen: ":1984" listen: ":1984" # default public port for WebUI and HTTP API
ffmpeg: ffmpeg:
bin: "ffmpeg" bin: "ffmpeg" # default binary path for FFmpeg
log: log:
format: "color" level: "info" # default log level
level: "info"
output: "stdout" output: "stdout"
time: "UNIXMS" time: "UNIXMS"
rtsp: rtsp:
listen: ":8554" listen: ":8554" # default public port for RTSP server
default_query: "video&audio" default_query: "video&audio"
srtp: srtp:
listen: ":8443" listen: ":8443" # default public port for SRTP server (used for HomeKit)
webrtc: webrtc:
listen: ":8555/tcp" listen: ":8555" # default public port for WebRTC server (TCP and UDP)
ice_servers: ice_servers:
- urls: [ "stun:stun.l.google.com:19302" ] - urls: [ "stun:stun.cloudflare.com:3478", "stun:stun.l.google.com:19302" ]
``` ```
## Log
You can set different log levels for different 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
```
Modules: `api`, `streams`, `rtsp`, `webrtc`, `mp4`, `hls`, `mjpeg`, `hass`, `homekit`, `onvif`, `rtmp`, `webtorrent`, `wyoming`, `echo`, `exec`, `expr`, `ffmpeg`, `wyze`, `xiaomi`.
+22 -1
View File
@@ -11,6 +11,7 @@ import (
var ( var (
Version string Version string
Modules []string
UserAgent string UserAgent string
ConfigPath string ConfigPath string
Info = make(map[string]any) Info = make(map[string]any)
@@ -76,6 +77,16 @@ func Init() {
if ConfigPath != "" { if ConfigPath != "" {
Logger.Info().Str("path", ConfigPath).Msg("config") Logger.Info().Str("path", ConfigPath).Msg("config")
} }
var cfg struct {
Mod struct {
Modules []string `yaml:"modules"`
} `yaml:"app"`
}
LoadConfig(&cfg)
Modules = cfg.Mod.Modules
} }
func readRevisionTime() (revision, vcsTime string) { func readRevisionTime() (revision, vcsTime string) {
@@ -92,10 +103,20 @@ func readRevisionTime() (revision, vcsTime string) {
vcsTime = setting.Value vcsTime = setting.Value
case "vcs.modified": case "vcs.modified":
if setting.Value == "true" { if setting.Value == "true" {
revision = "mod." + revision revision += ".dirty"
} }
} }
} }
// Check version from -buildvcs info
// Format for tagged version : v1.9.13
// Format for modified code: v1.9.14-0.20251215184105-753d6617ab58+dirty
if info.Main.Version != "v"+Version {
// Format: 1.9.13+dev.753d661[.dirty]
// Compatible with "awesomeversion" and "packaging.version" from python.
// Version will be larger than the previous release, but smaller than the next release.
Version += "+dev." + revision
}
} }
return return
} }
+2
View File
@@ -14,6 +14,8 @@ import (
var MemoryLog = newBuffer() var MemoryLog = newBuffer()
func GetLogger(module string) zerolog.Logger { func GetLogger(module string) zerolog.Logger {
Logger.Trace().Str("module", module).Msgf("[log] init")
if s, ok := modules[module]; ok { if s, ok := modules[module]; ok {
lvl, err := zerolog.ParseLevel(s) lvl, err := zerolog.ParseLevel(s)
if err == nil { if err == nil {
+15
View File
@@ -0,0 +1,15 @@
# Bubble
[`new in v1.6.1`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.6.1)
Private format in some cameras from [dvr163.com](http://help.dvr163.com/) and [eseecloud.com](http://www.eseecloud.com/).
## Configuration
- you can skip `username`, `password`, `port`, `ch` and `stream` if they are default
- set up separate streams for different channels and streams
```yaml
streams:
camera1: bubble://username:password@192.168.1.123:34567/bubble/live?ch=0&stream=0
```
+3
View File
@@ -0,0 +1,3 @@
# Debug
This module provides `GET /api/stack`, with which you can find hanging goroutines
+21
View File
@@ -0,0 +1,21 @@
# Doorbird
[`new in v1.9.8`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.8)
This source type supports [Doorbird](https://www.doorbird.com/) devices including MJPEG stream, audio stream as well as two-way audio.
It is recommended to create a separate user within your doorbird setup for go2rtc. Minimum permissions for the user are:
- Watch always
- API operator
## Configuration
```yaml
streams:
doorbird1:
- rtsp://admin:password@192.168.1.123:8557/mpeg/720p/media.amp # RTSP stream
- doorbird://admin:password@192.168.1.123?media=video # MJPEG stream
- doorbird://admin:password@192.168.1.123?media=audio # audio stream
- doorbird://admin:password@192.168.1.123 # two-way audio
```
+21
View File
@@ -0,0 +1,21 @@
# DVR-IP
[`new in v1.2.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.2.0)
Private format from DVR-IP NVR, NetSurveillance, Sofia protocol (NETsurveillance ActiveX plugin XMeye SDK).
## Configuration
- you can skip `username`, `password`, `port`, `channel` and `subtype` if they are default
- set up separate streams for different channels
- use `subtype=0` for Main stream, and `subtype=1` for Extra1 stream
- only the TCP protocol is supported
```yaml
streams:
only_stream: dvrip://username:password@192.168.1.123:34567?channel=0&subtype=0
only_tts: dvrip://username:password@192.168.1.123:34567?backchannel=1
two_way_audio:
- dvrip://username:password@192.168.1.123:34567?channel=0&subtype=0
- dvrip://username:password@192.168.1.123:34567?backchannel=1
```
+48
View File
@@ -0,0 +1,48 @@
# Echo
Some sources may have a dynamic link. And you will need to get it using a Bash or Python script. Your script should echo a link to the source. RTSP, FFmpeg or any of the supported sources.
**Docker** and **Home Assistant add-on** users have preinstalled `python3`, `curl`, `jq`.
## Configuration
```yaml
streams:
apple_hls: echo:python3 hls.py https://developer.apple.com/streaming/examples/basic-stream-osx-ios5.html
```
## Install python libraries
**Docker** and **Hass Add-on** users have preinstalled `python3` without any additional libraries, like [requests](https://requests.readthedocs.io/) or others. If you need some additional libraries - you need to install them to folder with your script:
1. Install [SSH & Web Terminal](https://github.com/hassio-addons/addon-ssh)
2. Goto Add-on Web UI
3. Install library: `pip install requests -t /config/echo`
4. Add your script to `/config/echo/myscript.py`
5. Use your script as source `echo:python3 /config/echo/myscript.py`
## Example: Apple HLS
```yaml
streams:
apple_hls: echo:python3 hls.py https://developer.apple.com/streaming/examples/basic-stream-osx-ios5.html
```
**hls.py**
```python
import re
import sys
from urllib.parse import urljoin
from urllib.request import urlopen
html = urlopen(sys.argv[1]).read().decode("utf-8")
url = re.search(r"https.+?m3u8", html)[0]
html = urlopen(url).read().decode("utf-8")
m = re.search(r"^[a-z0-1/_]+\.m3u8$", html, flags=re.MULTILINE)
url = urljoin(url, m[0])
# ffmpeg:https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8#video=copy
print("ffmpeg:" + url + "#video=copy")
```
+17
View File
@@ -2,7 +2,9 @@ package echo
import ( import (
"bytes" "bytes"
"errors"
"os/exec" "os/exec"
"slices"
"github.com/AlexxIT/go2rtc/internal/app" "github.com/AlexxIT/go2rtc/internal/app"
"github.com/AlexxIT/go2rtc/internal/streams" "github.com/AlexxIT/go2rtc/internal/streams"
@@ -10,11 +12,25 @@ import (
) )
func Init() { func Init() {
var cfg struct {
Mod struct {
AllowPaths []string `yaml:"allow_paths"`
} `yaml:"echo"`
}
app.LoadConfig(&cfg)
allowPaths := cfg.Mod.AllowPaths
log := app.GetLogger("echo") log := app.GetLogger("echo")
streams.RedirectFunc("echo", func(url string) (string, error) { streams.RedirectFunc("echo", func(url string) (string, error) {
args := shell.QuoteSplit(url[5:]) args := shell.QuoteSplit(url[5:])
if allowPaths != nil && !slices.Contains(allowPaths, args[0]) {
return "", errors.New("echo: bin not in allow_paths: " + args[0])
}
b, err := exec.Command(args[0], args[1:]...).Output() b, err := exec.Command(args[0], args[1:]...).Output()
if err != nil { if err != nil {
return "", err return "", err
@@ -26,4 +42,5 @@ func Init() {
return string(b), nil return string(b), nil
}) })
streams.MarkInsecure("echo")
} }
+12
View File
@@ -0,0 +1,12 @@
# EseeCloud
[`new in v1.9.10`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.10)
This source is for cameras with a link like this `http://admin:@192.168.1.123:80/livestream/12`. Related [issue](https://github.com/AlexxIT/go2rtc/issues/1690).
## Configuration
```yaml
streams:
camera1: eseecloud://user:pass@192.168.1.123:80/livestream/12
```
+36
View File
@@ -1,3 +1,39 @@
# Exec
Exec source can run any external application and expect data from it. Two transports are supported - **pipe** ([`new in v1.5.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.5.0)) and **RTSP**.
If you want to use **RTSP** transport, the command must contain the `{output}` argument in any place. On launch, it will be replaced by the local address of the RTSP server.
**pipe** reads data from app stdout in different formats: **MJPEG**, **H.264/H.265 bitstream**, **MPEG-TS**. Also pipe can write data to app stdin in two formats: **PCMA** and **PCM/48000**.
The source can be used with:
- [FFmpeg](https://ffmpeg.org/) - go2rtc ffmpeg source is just a shortcut to exec source
- [FFplay](https://ffmpeg.org/ffplay.html) - play audio on your server
- [GStreamer](https://gstreamer.freedesktop.org/)
- [Raspberry Pi Cameras](https://www.raspberrypi.com/documentation/computers/camera_software.html)
- any of your own software
## Configuration
Pipe commands support parameters (format: `exec:{command}#{param1}#{param2}`):
- `killsignal` - signal which will be sent to stop the process (numeric form)
- `killtimeout` - time in seconds for forced termination with sigkill
- `backchannel` - enable backchannel for two-way audio
- `starttimeout` - time in seconds for waiting first byte from RTSP
```yaml
streams:
stream: exec:ffmpeg -re -i /media/BigBuckBunny.mp4 -c copy -rtsp_transport tcp -f rtsp {output}
picam_h264: exec:libcamera-vid -t 0 --inline -o -
picam_mjpeg: exec:libcamera-vid -t 0 --codec mjpeg -o -
pi5cam_h264: exec:libcamera-vid -t 0 --libav-format h264 -o -
canon: exec:gphoto2 --capture-movie --stdout#killsignal=2#killtimeout=5
play_pcma: exec:ffplay -fflags nobuffer -f alaw -ar 8000 -i -#backchannel=1
play_pcm48k: exec:ffplay -fflags nobuffer -f s16be -ar 48000 -i -#backchannel=1
```
## Backchannel ## Backchannel
- You can check audio card names in the **Go2rtc > WebUI > Add** - You can check audio card names in the **Go2rtc > WebUI > Add**
+31 -5
View File
@@ -9,6 +9,7 @@ import (
"io" "io"
"net/url" "net/url"
"os" "os"
"slices"
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
@@ -26,6 +27,16 @@ import (
) )
func Init() { func Init() {
var cfg struct {
Mod struct {
AllowPaths []string `yaml:"allow_paths"`
} `yaml:"exec"`
}
app.LoadConfig(&cfg)
allowPaths = cfg.Mod.AllowPaths
rtsp.HandleFunc(func(conn *pkg.Conn) bool { rtsp.HandleFunc(func(conn *pkg.Conn) bool {
waitersMu.Lock() waitersMu.Lock()
waiter := waiters[conn.URL.Path] waiter := waiters[conn.URL.Path]
@@ -45,10 +56,13 @@ func Init() {
}) })
streams.HandleFunc("exec", execHandle) streams.HandleFunc("exec", execHandle)
streams.MarkInsecure("exec")
log = app.GetLogger("exec") log = app.GetLogger("exec")
} }
var allowPaths []string
func execHandle(rawURL string) (prod core.Producer, err error) { func execHandle(rawURL string) (prod core.Producer, err error) {
rawURL, rawQuery, _ := strings.Cut(rawURL, "#") rawURL, rawQuery, _ := strings.Cut(rawURL, "#")
query := streams.ParseQuery(rawQuery) query := streams.ParseQuery(rawQuery)
@@ -73,6 +87,11 @@ func execHandle(rawURL string) (prod core.Producer, err error) {
debug: log.Debug().Enabled(), debug: log.Debug().Enabled(),
} }
if allowPaths != nil && !slices.Contains(allowPaths, cmd.Args[0]) {
_ = cmd.Close()
return nil, errors.New("exec: bin not in allow_paths: " + cmd.Args[0])
}
if s := query.Get("killsignal"); s != "" { if s := query.Get("killsignal"); s != "" {
sig := syscall.Signal(core.Atoi(s)) sig := syscall.Signal(core.Atoi(s))
cmd.Cancel = func() error { cmd.Cancel = func() error {
@@ -89,10 +108,17 @@ func execHandle(rawURL string) (prod core.Producer, err error) {
return pcm.NewBackchannel(cmd, query.Get("audio")) return pcm.NewBackchannel(cmd, query.Get("audio"))
} }
var timeout time.Duration
if s := query.Get("starttimeout"); s != "" {
timeout = time.Duration(core.Atoi(s)) * time.Second
} else {
timeout = 30 * time.Second
}
if path == "" { if path == "" {
prod, err = handlePipe(rawURL, cmd) prod, err = handlePipe(rawURL, cmd)
} else { } else {
prod, err = handleRTSP(rawURL, cmd, path) prod, err = handleRTSP(rawURL, cmd, path, timeout)
} }
if err != nil { if err != nil {
@@ -141,7 +167,7 @@ func handlePipe(source string, cmd *shell.Command) (core.Producer, error) {
return prod, nil return prod, nil
} }
func handleRTSP(source string, cmd *shell.Command, path string) (core.Producer, error) { func handleRTSP(source string, cmd *shell.Command, path string, timeout time.Duration) (core.Producer, error) {
if log.Trace().Enabled() { if log.Trace().Enabled() {
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
} }
@@ -167,11 +193,11 @@ func handleRTSP(source string, cmd *shell.Command, path string) (core.Producer,
return nil, err return nil, err
} }
timeout := time.NewTimer(30 * time.Second) timer := time.NewTimer(timeout)
defer timeout.Stop() defer timer.Stop()
select { select {
case <-timeout.C: case <-timer.C:
// haven't received data from app in timeout // haven't received data from app in timeout
log.Error().Str("source", source).Msg("[exec] timeout") log.Error().Str("source", source).Msg("[exec] timeout")
return nil, errors.New("exec: timeout") return nil, errors.New("exec: timeout")
+74 -12
View File
@@ -1,5 +1,7 @@
# Expr # Expr
[`new in v1.8.2`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.8.2)
[Expr](https://github.com/antonmedv/expr) - expression language and expression evaluation for Go. [Expr](https://github.com/antonmedv/expr) - expression language and expression evaluation for Go.
- [language definition](https://expr.medv.io/docs/Language-Definition) - takes best from JS, Python, Jinja2 syntax - [language definition](https://expr.medv.io/docs/Language-Definition) - takes best from JS, Python, Jinja2 syntax
@@ -12,34 +14,94 @@
- `fetch` - JS-like HTTP requests - `fetch` - JS-like HTTP requests
- `match` - JS-like RegExp queries - `match` - JS-like RegExp queries
## Examples ## Fetch examples
Multiple fetch requests are executed within a single session. They share the same cookie.
**HTTP GET**
```js
var r = fetch('https://example.org/products.json');
```
**HTTP POST JSON**
```js
var r = fetch('https://example.org/post', {
method: 'POST',
// Content-Type: application/json will be set automatically
json: {username: 'example'}
});
```
**HTTP POST Form**
```js
var r = fetch('https://example.org/post', {
method: 'POST',
// Content-Type: application/x-www-form-urlencoded will be set automatically
data: {username: 'example', password: 'password'}
});
```
## Script examples
**Two way audio for Dahua VTO** **Two way audio for Dahua VTO**
```yaml ```yaml
streams: streams:
dahua_vto: | dahua_vto: |
expr: let host = "admin:password@192.168.1.123"; expr:
fetch("http://"+host+"/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Audio.Compression=G.711A&Encode[0].MainFormat[0].Audio.Frequency=8000").ok let host = 'admin:password@192.168.1.123';
? "rtsp://"+host+"/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif" : ""
var r = fetch('http://' + host + '/cgi-bin/configManager.cgi?action=setConfig&Encode[0].MainFormat[0].Audio.Compression=G.711A&Encode[0].MainFormat[0].Audio.Frequency=8000');
'rtsp://' + host + '/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif'
``` ```
**dom.ru** **dom.ru**
You can get credentials via: You can get credentials from https://github.com/ad/domru
- https://github.com/alexmorbo/domru (file `/share/domru/accounts`)
- https://github.com/ad/domru
```yaml ```yaml
streams: streams:
dom_ru: | dom_ru: |
expr: let camera = "99999999"; let token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; let operator = 99; expr:
fetch("https://myhome.novotelecom.ru/rest/v1/forpost/cameras/"+camera+"/video", { let camera = '***';
headers: {Authorization: "Bearer "+token, Operator: operator} let token = '***';
let operator = '***';
fetch('https://myhome.proptech.ru/rest/v1/forpost/cameras/' + camera + '/video', {
headers: {
'Authorization': 'Bearer ' + token,
'User-Agent': 'Google sdkgphone64x8664 | Android 14 | erth | 8.26.0 (82600010) | 0 | 0 | 0',
'Operator': operator
}
}).json().data.URL }).json().data.URL
``` ```
**dom.ufanet.ru**
```yaml
streams:
ufanet_ru: |
expr:
let username = '***';
let password = '***';
let cameraid = '***';
let r1 = fetch('https://ucams.ufanet.ru/api/internal/login/', {
method: 'POST',
data: {username: username, password: password}
});
let r2 = fetch('https://ucams.ufanet.ru/api/v0/cameras/this/?lang=ru', {
method: 'POST',
json: {'fields': ['token_l', 'server'], 'token_l_ttl': 3600, 'numbers': [cameraid]},
}).json().results[0];
'rtsp://' + r2.server.domain + '/' + r2.number + '?token=' + r2.token_l
```
**Parse HLS files from Apple** **Parse HLS files from Apple**
Same example in two languages - python and expr. Same example in two languages - python and expr.
@@ -76,7 +138,7 @@ streams:
"ffmpeg:" + url3 + "#video=copy" "ffmpeg:" + url3 + "#video=copy"
``` ```
## Comparsion ## Comparison
| expr | python | js | | expr | python | js |
|------------------------------|----------------------------|--------------------------------| |------------------------------|----------------------------|--------------------------------|
+1
View File
@@ -25,4 +25,5 @@ func Init() {
return url, nil return url, nil
}) })
streams.MarkInsecure("expr")
} }
+52 -58
View File
@@ -1,68 +1,62 @@
## FFplay output # FFmpeg
[FFplay](https://stackoverflow.com/questions/27778678/what-are-mv-fd-aq-vq-sq-and-f-in-a-video-stream) `7.11 A-V: 0.003 fd= 1 aq= 21KB vq= 321KB sq= 0B f=0/0`: You can get any stream, file or device via FFmpeg and push it to go2rtc. The app will automatically start FFmpeg with the proper arguments when someone starts watching the stream.
- `7.11` - master clock, is the time from start of the stream/video - FFmpeg preinstalled for **Docker** and **Home Assistant add-on** users
- `A-V` - av_diff, difference between audio and video timestamps - **Home Assistant add-on** users can target files from [/media](https://www.home-assistant.io/more-info/local-media/setup-media/) folder
- `fd` - frames dropped
- `aq` - audio queue (0 - no delay)
- `vq` - video queue (0 - no delay)
- `sq` - subtitle queue
- `f` - timestamp error correction rate (Not 100% sure)
`M-V`, `M-A` means video stream only, audio stream only respectively. ## Configuration
## Devices Windows Format: `ffmpeg:{input}#{param1}#{param2}#{param3}`. Examples:
```
>ffmpeg -hide_banner -f dshow -list_options true -i video="VMware Virtual USB Video Device"
[dshow @ 0000025695e52900] DirectShow video device options (from video devices)
[dshow @ 0000025695e52900] Pin "Record" (alternative pin name "0")
[dshow @ 0000025695e52900] pixel_format=yuyv422 min s=1280x720 fps=1 max s=1280x720 fps=10
[dshow @ 0000025695e52900] pixel_format=yuyv422 min s=1280x720 fps=1 max s=1280x720 fps=10 (tv, bt470bg/bt709/unknown, topleft)
[dshow @ 0000025695e52900] pixel_format=nv12 min s=1280x720 fps=1 max s=1280x720 fps=23
[dshow @ 0000025695e52900] pixel_format=nv12 min s=1280x720 fps=1 max s=1280x720 fps=23 (tv, bt470bg/bt709/unknown, topleft)
```
## Devices Mac
```
% ./ffmpeg -hide_banner -f avfoundation -list_devices true -i ""
[AVFoundation indev @ 0x7f8b1f504d80] AVFoundation video devices:
[AVFoundation indev @ 0x7f8b1f504d80] [0] FaceTime HD Camera
[AVFoundation indev @ 0x7f8b1f504d80] [1] Capture screen 0
[AVFoundation indev @ 0x7f8b1f504d80] AVFoundation audio devices:
[AVFoundation indev @ 0x7f8b1f504d80] [0] Soundflower (2ch)
[AVFoundation indev @ 0x7f8b1f504d80] [1] Built-in Microphone
[AVFoundation indev @ 0x7f8b1f504d80] [2] Soundflower (64ch)
```
## Devices Linux
```
# ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0
[video4linux2,v4l2 @ 0x7f7de7c58bc0] Raw : yuyv422 : YUYV 4:2:2 : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360 752x416 800x448 800x600 864x480 960x544 960x720 1024x576 1184x656 1280x720 1280x960
[video4linux2,v4l2 @ 0x7f7de7c58bc0] Compressed: mjpeg : Motion-JPEG : 640x480 160x120 176x144 320x176 320x240 352x288 432x240 544x288 640x360 752x416 800x448 800x600 864x480 960x544 960x720 1024x576 1184x656 1280x720 1280x960
```
## TTS
```yaml ```yaml
streams: streams:
tts: ffmpeg:#input=-readrate 1 -readrate_initial_burst 0.001 -f lavfi -i "flite=text='1 2 3 4 5 6 7 8 9 0'"#audio=pcma # [FILE] all tracks will be copied without transcoding codecs
file1: ffmpeg:/media/BigBuckBunny.mp4
# [FILE] video will be transcoded to H264, audio will be skipped
file2: ffmpeg:/media/BigBuckBunny.mp4#video=h264
# [FILE] video will be copied, audio will be transcoded to PCMU
file3: ffmpeg:/media/BigBuckBunny.mp4#video=copy#audio=pcmu
# [HLS] video will be copied, audio will be skipped
hls: ffmpeg:https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8#video=copy
# [MJPEG] video will be transcoded to H264
mjpeg: ffmpeg:http://185.97.122.128/cgi-bin/faststream.jpg#video=h264
# [RTSP] video with rotation, should be transcoded, so select H264
rotate: ffmpeg:rtsp://12345678@192.168.1.123/av_stream/ch0#video=h264#rotate=90
``` ```
## Useful links All transcoding formats have [built-in templates](ffmpeg.go): `h264`, `h265`, `opus`, `pcmu`, `pcmu/16000`, `pcmu/48000`, `pcma`, `pcma/16000`, `pcma/48000`, `aac`, `aac/16000`.
- https://superuser.com/questions/564402/explanation-of-x264-tune But you can override them via YAML config. You can also add your own formats to the config and use them with source params.
- https://stackoverflow.com/questions/33624016/why-sliced-thread-affect-so-much-on-realtime-encoding-using-ffmpeg-x264
- https://codec.fandom.com/ru/wiki/X264_-_описание_ключей_кодирования ```yaml
- https://html5test.com/ ffmpeg:
- https://trac.ffmpeg.org/wiki/Capture/Webcam bin: ffmpeg # path to ffmpeg binary
- https://trac.ffmpeg.org/wiki/DirectShow global: "-hide_banner"
- https://stackoverflow.com/questions/53207692/libav-mjpeg-encoding-and-huffman-table timeout: 5 # default timeout in seconds for rtsp inputs
- https://github.com/tuupola/esp_video/blob/master/README.md h264: "-codec:v libx264 -g:v 30 -preset:v superfast -tune:v zerolatency -profile:v main -level:v 4.1"
- https://github.com/leandromoreira/ffmpeg-libav-tutorial mycodec: "-any args that supported by ffmpeg..."
- https://www.reddit.com/user/VeritablePornocopium/comments/okw130/ffmpeg_with_libfdk_aac_for_windows_x64/ myinput: "-fflags nobuffer -flags low_delay -timeout {timeout} -i {input}"
- https://slhck.info/video/2017/02/24/vbr-settings.html myraw: "-ss 00:00:20"
- [HomeKit audio samples problem](https://superuser.com/questions/1290996/non-monotonous-dts-with-igndts-flag) ```
- You can use go2rtc stream name as ffmpeg input (ex. `ffmpeg:camera1#video=h264`)
- You can use `video` and `audio` params multiple times (ex. `#video=copy#audio=copy#audio=pcmu`)
- You can use `rotate` param with `90`, `180`, `270` or `-90` values, important with transcoding (ex. `#video=h264#rotate=90`)
- You can use `width` and/or `height` params, important with transcoding (ex. `#video=h264#width=1280`)
- You can use `drawtext` to add a timestamp (ex. `drawtext=x=2:y=2:fontsize=12:fontcolor=white:box=1:boxcolor=black`)
- This will greatly increase the CPU of the server, even with hardware acceleration
- You can use `timeout` param to set RTSP input timeout in seconds (ex. `#timeout=10`)
- You can use `raw` param for any additional FFmpeg arguments (ex. `#raw=-vf transpose=1`)
- You can use `input` param to override default input template (ex. `#input=rtsp/udp` will change RTSP transport from TCP to UDP+TCP)
- You can use raw input value (ex. `#input=-timeout {timeout} -i {input}`)
- You can add your own input templates
Read more about [hardware acceleration](hardware/README.md).
**PS.** It is recommended to check the available hardware in the WebUI add page.
+22
View File
@@ -0,0 +1,22 @@
# FFmpeg Device
You can get video from any USB camera or Webcam as RTSP or WebRTC stream. This is part of FFmpeg integration.
- check available devices in web interface
- `video_size` and `framerate` must be supported by your camera!
- for Linux supported only video for now
- for macOS you can stream FaceTime camera or whole desktop!
- for macOS important to set right framerate
## Configuration
Format: `ffmpeg:device?{input-params}#{param1}#{param2}#{param3}`
```yaml
streams:
linux_usbcam: ffmpeg:device?video=0&video_size=1280x720#video=h264
windows_webcam: ffmpeg:device?video=0#video=h264
macos_facetime: ffmpeg:device?video=0&audio=1&video_size=1280x720&framerate=30#video=h264#audio=pcma
```
**PS.** It is recommended to check the available devices in the WebUI add page.
+14 -7
View File
@@ -58,15 +58,15 @@ func Init() {
} }
var defaults = map[string]string{ var defaults = map[string]string{
"bin": "ffmpeg", "bin": "ffmpeg",
"global": "-hide_banner", "global": "-hide_banner",
"timeout": "5",
// inputs // inputs
"file": "-re -i {input}", "file": "-re -i {input}",
"http": "-fflags nobuffer -flags low_delay -i {input}", "http": "-fflags nobuffer -flags low_delay -i {input}",
"rtsp": "-fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i {input}", "rtsp": "-fflags nobuffer -flags low_delay -timeout {timeout} -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i {input}",
"rtsp/udp": "-fflags nobuffer -flags low_delay -timeout {timeout} -user_agent go2rtc/ffmpeg -i {input}",
"rtsp/udp": "-fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -i {input}",
// output // output
"output": "-user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}", "output": "-user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}",
@@ -169,6 +169,13 @@ func inputTemplate(name, s string, query url.Values) string {
} else { } else {
template = defaults[name] template = defaults[name]
} }
if strings.Contains(template, "{timeout}") {
timeout := query.Get("timeout")
if timeout == "" {
timeout = defaults["timeout"]
}
template = strings.Replace(template, "{timeout}", timeout+"000000", 1)
}
return strings.Replace(template, "{input}", s, 1) return strings.Replace(template, "{input}", s, 1)
} }
+5
View File
@@ -123,6 +123,11 @@ func TestParseArgsIpCam(t *testing.T) {
source: "rtmp://example.com#input=rtsp/udp", source: "rtmp://example.com#input=rtsp/udp",
expect: `ffmpeg -hide_banner -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -i rtmp://example.com -c copy -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`, expect: `ffmpeg -hide_banner -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -i rtmp://example.com -c copy -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`,
}, },
{
name: "[RTSP] custom timeout",
source: "rtsp://example.com#timeout=10",
expect: `ffmpeg -hide_banner -allowed_media_types video+audio -fflags nobuffer -flags low_delay -timeout 10000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://example.com -c copy -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`,
},
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
+26 -26
View File
@@ -2,27 +2,27 @@
You **DON'T** need hardware acceleration if: You **DON'T** need hardware acceleration if:
- you not using [FFmpeg source](https://github.com/AlexxIT/go2rtc#source-ffmpeg) - you're not using the [FFmpeg source](../README.md)
- you using only `#video=copy` for FFmpeg source - you're using only `#video=copy` for the FFmpeg source
- you using only `#audio=...` (any audio) transcoding for FFmpeg source - you're using only `#audio=...` (any audio) transcoding for the FFmpeg source
You **NEED** hardware acceleration if you using `#video=h264`, `#video=h265`, `#video=mjpeg` (video) transcoding. You **NEED** hardware acceleration if you're using `#video=h264`, `#video=h265`, `#video=mjpeg` (video) transcoding.
## Important ## Important
- Acceleration is disabled by default because it can be unstable (it can be changed in future) - Acceleration is disabled by default because it can be unstable (this may change in the future)
- go2rtc can automatically detect supported hardware acceleration if enabled - go2rtc can automatically detect supported hardware acceleration if enabled
- go2rtc will enable hardware decoding only if hardware encoding supported - go2rtc will enable hardware decoding only if hardware encoding is supported
- go2rtc will use the same GPU for decoder and encoder - go2rtc will use the same GPU for decoder and encoder
- Intel and AMD will switch to software decoder if input codec is not supported with hardware decoder - Intel and AMD will switch to a software decoder if the input codec isn't supported by the hardware decoder
- NVidia will fail if input codec is not supported with hardware decoder - NVIDIA will fail if the input codec isn't supported by the hardware decoder
- Raspberry always uses software decoder - Raspberry Pi always uses a software decoder
```yaml ```yaml
streams: streams:
# auto select hardware encoder # auto select hardware encoder
camera1_hw: ffmpeg:rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0#video=h264#hardware camera1_hw: ffmpeg:rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0#video=h264#hardware
# manual select hardware encoder (vaapi, cuda, v4l2m2m, dxva2, videotoolbox) # manual select hardware encoder (vaapi, cuda, v4l2m2m, dxva2, videotoolbox)
camera1_vaapi: ffmpeg:rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0#video=h264#hardware=vaapi camera1_vaapi: ffmpeg:rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0#video=h264#hardware=vaapi
``` ```
@@ -31,41 +31,41 @@ streams:
There are two versions of the Docker container and Hass Add-on: There are two versions of the Docker container and Hass Add-on:
- Latest (alpine) support hardware acceleration for Intel iGPU (CPU with Graphics) and Raspberry. - Latest (Alpine) supports hardware acceleration for Intel iGPU (CPU with graphics) and Raspberry Pi.
- Hardware (debian 12) support Intel iGPU, AMD GPU, NVidia GPU. - Hardware (Debian 12) supports Intel iGPU, AMD GPU, NVIDIA GPU.
## Intel iGPU ## Intel iGPU
**Supported on:** Windows binary, Linux binary, Docker, Hass Addon. **Supported on:** Windows binary, Linux binary, Docker, Hass Addon.
If you have Intel CPU Sandy Bridge (2011) with Graphics, you already have support hardware decoding/encoding for `AVC/H.264`. If you have an Intel Sandy Bridge (2011) CPU with graphics, you already have hardware decoding/encoding support for `AVC/H.264`.
If you have Intel CPU Skylake (2015) with Graphics, you already have support hardware decoding/encoding for `AVC/H.264`, `HEVC/H.265` and `MJPEG`. If you have an Intel Skylake (2015) CPU with graphics, you already have hardware decoding/encoding support for `AVC/H.264`, `HEVC/H.265` and `MJPEG`.
Read more [here](https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video#Hardware_decoding_and_encoding) and [here](https://en.wikipedia.org/wiki/Intel_Graphics_Technology#Capabilities_(GPU_video_acceleration)). Read more [here](https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video#Hardware_decoding_and_encoding) and [here](https://en.wikipedia.org/wiki/Intel_Graphics_Technology#Capabilities_(GPU_video_acceleration)).
Linux and Docker: Linux and Docker:
- It may be important to have the latest version of the OS with the latest version of the Linux kernel. For example, on my **Debian 10 (kernel 4.19)** it did not work, but after update to **Debian 11 (kernel 5.10)** all was fine. - It may be important to have a recent OS and Linux kernel. For example, on my **Debian 10 (kernel 4.19)** it did not work, but after updating to **Debian 11 (kernel 5.10)** everything was fine.
- In case of troube check you have `/dev/dri/` folder on your host. - If you run into trouble, check that you have the `/dev/dri/` folder on your host.
Docker users should add `--privileged` option to container for access to Hardware. Docker users should add the `--privileged` option to the container for access to the hardware.
**PS.** Supported via [VAAPI](https://trac.ffmpeg.org/wiki/Hardware/VAAPI) engine on Linux and [DXVA2+QSV](https://trac.ffmpeg.org/wiki/Hardware/QuickSync) engine on Windows. **PS.** Supported via [VAAPI](https://trac.ffmpeg.org/wiki/Hardware/VAAPI) engine on Linux and [DXVA2+QSV](https://trac.ffmpeg.org/wiki/Hardware/QuickSync) engine on Windows.
## AMD GPU ## AMD GPU
*I don't have the hardware for test support!!!* *I don't have the hardware to test this!!!*
**Supported on:** Linux binary, Docker, Hass Addon. **Supported on:** Linux binary, Docker, Hass Addon.
Docker users should install: `alexxit/go2rtc:master-hardware`. Docker users should add `--privileged` option to container for access to Hardware. Docker users should install: `alexxit/go2rtc:master-hardware`. Docker users should add the `--privileged` option to the container for access to the hardware.
Hass Addon users should install **go2rtc master hardware** version. Hass Addon users should install **go2rtc master hardware** version.
**PS.** Supported via [VAAPI](https://trac.ffmpeg.org/wiki/Hardware/VAAPI) engine. **PS.** Supported via [VAAPI](https://trac.ffmpeg.org/wiki/Hardware/VAAPI) engine.
## NVidia GPU ## NVIDIA GPU
**Supported on:** Windows binary, Linux binary, Docker. **Supported on:** Windows binary, Linux binary, Docker.
@@ -79,11 +79,11 @@ Read more [here](https://docs.frigate.video/configuration/hardware_acceleration)
**Supported on:** Linux binary, Docker, Hass Addon. **Supported on:** Linux binary, Docker, Hass Addon.
I don't recommend using transcoding on the Raspberry Pi 3. It's extreamly slow, even with hardware acceleration. Also it may fail when transcoding 2K+ stream. I don't recommend using transcoding on the Raspberry Pi 3. It's extremely slow, even with hardware acceleration. Also, it may fail when transcoding a 2K+ stream.
## Raspberry Pi 4 ## Raspberry Pi 4
*I don't have the hardware for test support!!!* *I don't have the hardware to test this!!!*
**Supported on:** Linux binary, Docker, Hass Addon. **Supported on:** Linux binary, Docker, Hass Addon.
@@ -91,16 +91,16 @@ I don't recommend using transcoding on the Raspberry Pi 3. It's extreamly slow,
## macOS ## macOS
In my tests, transcoding is faster on the M1 CPU than on the M1 GPU. Transcoding time on M1 CPU better than any Intel iGPU and comparable to NVidia RTX 2070. In my tests, transcoding is faster on the M1 CPU than on the M1 GPU. Transcoding time on the M1 CPU is better than any Intel iGPU and comparable to an NVIDIA RTX 2070.
**PS.** Supported via [videotoolbox](https://trac.ffmpeg.org/wiki/HWAccelIntro#VideoToolbox) engine. **PS.** Supported via [videotoolbox](https://trac.ffmpeg.org/wiki/HWAccelIntro#VideoToolbox) engine.
## Rockchip ## Rockchip
- Important to use custom FFmpeg with Rockchip support from [@nyanmisaka](https://github.com/nyanmisaka/ffmpeg-rockchip) - It's important to use a custom FFmpeg build with Rockchip support from [@nyanmisaka](https://github.com/nyanmisaka/ffmpeg-rockchip)
- Static binaries from [@MarcA711](https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/) - Static binaries from [@MarcA711](https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/)
- Important to have Linux kernel 5.10 or 6.1 - It's important to have Linux kernel 5.10 or 6.1
**Tested** **Tested**
- [Orange Pi 3B](https://www.armbian.com/orangepi3b/) with Armbian 6.1, support transcoding H264, H265, MJPEG - [Orange Pi 3B](https://www.armbian.com/orangepi3b/) with Armbian 6.1, supports transcoding H.264, H.265, MJPEG
+3 -2
View File
@@ -46,6 +46,7 @@ func NewProducer(url string) (core.Producer, error) {
{Name: core.CodecPCM, ClockRate: 16000}, {Name: core.CodecPCM, ClockRate: 16000},
{Name: core.CodecPCMA, ClockRate: 16000}, {Name: core.CodecPCMA, ClockRate: 16000},
{Name: core.CodecPCMU, ClockRate: 16000}, {Name: core.CodecPCMU, ClockRate: 16000},
{Name: core.CodecPCML, ClockRate: 8000},
{Name: core.CodecPCM, ClockRate: 8000}, {Name: core.CodecPCM, ClockRate: 8000},
{Name: core.CodecPCMA, ClockRate: 8000}, {Name: core.CodecPCMA, ClockRate: 8000},
{Name: core.CodecPCMU, ClockRate: 8000}, {Name: core.CodecPCMU, ClockRate: 8000},
@@ -95,11 +96,11 @@ func (p *Producer) newURL() string {
codec := receiver.Codec codec := receiver.Codec
switch codec.Name { switch codec.Name {
case core.CodecOpus: case core.CodecOpus:
s += "#audio=opus" s += "#audio=opus/16000"
case core.CodecAAC: case core.CodecAAC:
s += "#audio=aac/16000" s += "#audio=aac/16000"
case core.CodecPCML: case core.CodecPCML:
s += "#audio=pcml/16000" s += "#audio=pcml/" + strconv.Itoa(int(codec.ClockRate))
case core.CodecPCM: case core.CodecPCM:
s += "#audio=pcm/" + strconv.Itoa(int(codec.ClockRate)) s += "#audio=pcm/" + strconv.Itoa(int(codec.ClockRate))
case core.CodecPCMA: case core.CodecPCMA:
+5
View File
@@ -0,0 +1,5 @@
# Flussonic
[`new in v1.9.10`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.10)
Support streams from [Flussonic](https://flussonic.com/) server. Related [issue](https://github.com/AlexxIT/go2rtc/issues/1678).
+7 -3
View File
@@ -1,16 +1,20 @@
# GoPro # GoPro
[`new in v1.8.3`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.8.3)
Support streaming from [GoPro](https://gopro.com/) cameras, connected via USB or Wi-Fi to Linux, Mac, Windows.
Supported models: HERO9, HERO10, HERO11, HERO12. Supported models: HERO9, HERO10, HERO11, HERO12.
Supported OS: Linux, Mac, Windows, [HassOS](https://www.home-assistant.io/installation/) Supported OS: Linux, Mac, Windows, [HassOS](https://www.home-assistant.io/installation/)
The other camera models have different APIs. I will try to add them in the next versions. Other camera models have different APIs. I will try to add them in future versions.
## Config ## Configuration
- USB-connected cameras create a new network interface in the system - USB-connected cameras create a new network interface in the system
- Linux users do not need to install anything - Linux users do not need to install anything
- Windows users should install the [network driver](https://community.gopro.com/s/article/GoPro-Webcam) - Windows users should install the [network driver](https://community.gopro.com/s/article/GoPro-Webcam)
- if the camera is detected but the stream does not start - you need to disable firewall - if the camera is detected but the stream does not start, you need to disable the firewall
1. Discover camera address: WebUI > Add > GoPro 1. Discover camera address: WebUI > Add > GoPro
2. Add camera to config 2. Add camera to config
+41
View File
@@ -0,0 +1,41 @@
# Hass
Support import camera links from [Home Assistant](https://www.home-assistant.io/) config files:
- [Generic Camera](https://www.home-assistant.io/integrations/generic/), setup via GUI
- [HomeKit Camera](https://www.home-assistant.io/integrations/homekit_controller/)
- [ONVIF](https://www.home-assistant.io/integrations/onvif/)
- [Roborock](https://github.com/humbertogontijo/homeassistant-roborock) vacuums with camera
## Configuration
```yaml
hass:
config: "/config" # skip this setting if you are a Home Assistant add-on user
streams:
generic_camera: hass:Camera1 # Settings > Integrations > Integration Name
aqara_g3: hass:Camera-Hub-G3-AB12
```
### WebRTC Cameras
[`new in v1.6.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.6.0)
Any cameras in WebRTC format are supported. But at the moment Home Assistant only supports some [Nest](https://www.home-assistant.io/integrations/nest/) cameras in this format.
**Important.** The Nest API only allows you to get a link to a stream for 5 minutes.
Do not use this with Frigate! If the stream expires, Frigate will consume all available RAM on your machine within seconds.
It's recommended to use [Nest source](../nest/README.md) - it supports extending the stream.
```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...
```
### RTSP Cameras
By default, the Home Assistant API does not allow you to get a dynamic RTSP link to a camera stream. [This method](https://github.com/felipecrs/hass-expose-camera-stream-source#importing-cameras-from-home-assistant-to-go2rtc-or-frigate) can work around it.
+2 -2
View File
@@ -30,10 +30,10 @@ func apiStream(w http.ResponseWriter, r *http.Request) {
// 1. link to go2rtc stream: rtsp://...:8554/{stream_name} // 1. link to go2rtc stream: rtsp://...:8554/{stream_name}
// 2. static link to Hass camera // 2. static link to Hass camera
// 3. dynamic link to Hass camera // 3. dynamic link to Hass camera
if streams.Patch(v.Name, v.Channels.First.Url) != nil { if _, err := streams.Patch(v.Name, v.Channels.First.Url); err == nil {
apiOK(w, r) apiOK(w, r)
} else { } else {
http.Error(w, "", http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
} }
// /stream/{id}/channel/0/webrtc // /stream/{id}/channel/0/webrtc
+8 -2
View File
@@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"os" "os"
"path" "path"
"strings"
"sync" "sync"
"github.com/AlexxIT/go2rtc/internal/api" "github.com/AlexxIT/go2rtc/internal/api"
@@ -37,8 +38,13 @@ func Init() {
api.HandleFunc("/streams", apiOK) api.HandleFunc("/streams", apiOK)
api.HandleFunc("/stream/", apiStream) api.HandleFunc("/stream/", apiStream)
streams.RedirectFunc("hass", func(url string) (string, error) { streams.RedirectFunc("hass", func(rawURL string) (string, error) {
if location := entities[url[5:]]; location != "" { rawURL, rawQuery, _ := strings.Cut(rawURL, "#")
if location := entities[rawURL[5:]]; location != "" {
if rawQuery != "" {
return location + "#" + rawQuery, nil
}
return location, nil return location, nil
} }
+16
View File
@@ -1,3 +1,19 @@
# HLS
[`new in v1.1.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.1.0)
[HLS](https://en.wikipedia.org/wiki/HTTP_Live_Streaming) is the worst technology for real-time streaming.
It can only be useful on devices that do not support more modern technology, like [WebRTC](../webrtc/README.md), [MP4](../mp4/README.md).
The go2rtc implementation differs from the standards and may not work with all players.
API examples:
- HLS/TS stream: `http://192.168.1.123:1984/api/stream.m3u8?src=camera1` (H264)
- HLS/fMP4 stream: `http://192.168.1.123:1984/api/stream.m3u8?src=camera1&mp4` (H264, H265, AAC)
Read more about [codecs filters](../../README.md#codecs-filters).
## Useful links ## Useful links
- https://walterebert.com/playground/video/hls/ - https://walterebert.com/playground/video/hls/
+1 -1
View File
@@ -11,7 +11,7 @@ import (
) )
func handlerWSHLS(tr *ws.Transport, msg *ws.Message) error { func handlerWSHLS(tr *ws.Transport, msg *ws.Message) error {
stream := streams.GetOrPatch(tr.Request.URL.Query()) stream, _ := streams.GetOrPatch(tr.Request.URL.Query())
if stream == nil { if stream == nil {
return errors.New(api.StreamNotFound) return errors.New(api.StreamNotFound)
} }
+97
View File
@@ -0,0 +1,97 @@
# Apple HomeKit
This module supports both client and server for the [Apple HomeKit](https://www.apple.com/home-app/accessories/) protocol.
## HomeKit Client
**Important:**
- You can use HomeKit Cameras **without Apple devices** (iPhone, iPad, etc.), it's just a yet another protocol
- HomeKit device can be paired with only one ecosystem. So, if you have paired it to an iPhone (Apple Home), you can't pair it with Home Assistant or go2rtc. Or if you have paired it to go2rtc, you can't pair it with an iPhone
- HomeKit device should be on the same network with working [mDNS](https://en.wikipedia.org/wiki/Multicast_DNS) between the device and go2rtc
go2rtc supports importing paired HomeKit devices from [Home Assistant](../hass/README.md).
So you can use HomeKit camera with Home Assistant and go2rtc simultaneously.
If you are using Home Assistant, I recommend pairing devices with it; it will give you more options.
You can pair device with go2rtc on the HomeKit page. If you can't see your devices, reload the page.
Also, try rebooting your HomeKit device (power off). If you still can't see it, you have a problem with mDNS.
If you see a device but it does not have a pairing button, it is paired to some ecosystem (Apple Home, Home Assistant, HomeBridge, etc.). You need to delete the device from that ecosystem, and it will be available for pairing. If you cannot unpair the device, you will have to reset it.
**Important:**
- HomeKit audio uses very non-standard **AAC-ELD** codec with very non-standard params and specification violations
- Audio can't be played in `VLC` and probably any other player
- Audio should be transcoded for use with MSE, WebRTC, etc.
### Client Configuration
Recommended settings for using HomeKit Camera with WebRTC, MSE, MP4, RTSP:
```yaml
streams:
aqara_g3:
- hass:Camera-Hub-G3-AB12
- ffmpeg:aqara_g3#audio=aac#audio=opus
```
RTSP link with "normal" audio for any player: `rtsp://192.168.1.123:8554/aqara_g3?video&audio=aac`
**This source is in active development!** Tested only with [Aqara Camera Hub G3](https://www.aqara.com/eu/product/camera-hub-g3) (both EU and CN versions).
## HomeKit Server
[`new in v1.7.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.7.0)
HomeKit module can work in two modes:
- export any H264 camera to Apple HomeKit
- transparent proxy any Apple HomeKit camera (Aqara, Eve, Eufy, etc.) back to Apple HomeKit, so you will have all camera features in Apple Home and also will have RTSP/WebRTC/MP4/etc. from your HomeKit camera
**Important**
- HomeKit cameras support only H264 video and OPUS audio
### Server Configuration
**Minimal config**
```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
```
**Full config**
```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
```
**Proxy HomeKit camera**
- Video stream from HomeKit camera to Apple device (iPhone, Apple TV) will be transmitted directly
- Video stream from HomeKit camera to RTSP/WebRTC/MP4/etc. will be transmitted via go2rtc
```yaml
streams:
aqara1:
- homekit://...
- ffmpeg:aqara1#audio=aac#audio=opus # optional audio transcoding
homekit:
aqara1: # same stream ID from streams list
```
+79 -37
View File
@@ -3,6 +3,7 @@ package homekit
import ( import (
"errors" "errors"
"fmt" "fmt"
"io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@@ -14,56 +15,97 @@ import (
"github.com/AlexxIT/go2rtc/pkg/mdns" "github.com/AlexxIT/go2rtc/pkg/mdns"
) )
func apiHandler(w http.ResponseWriter, r *http.Request) { func apiDiscovery(w http.ResponseWriter, r *http.Request) {
sources, err := discovery()
if err != nil {
api.Error(w, err)
return
}
urls := findHomeKitURLs()
for id, u := range urls {
deviceID := u.Query().Get("device_id")
for _, source := range sources {
if strings.Contains(source.URL, deviceID) {
source.Location = id
break
}
}
}
for _, source := range sources {
if source.Location == "" {
source.Location = " "
}
}
api.ResponseSources(w, sources)
}
func apiHomekit(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
switch r.Method { switch r.Method {
case "GET": case "GET":
sources, err := discovery() if id := r.Form.Get("id"); id != "" {
if err != nil { if srv := servers[id]; srv != nil {
api.Error(w, err) api.ResponsePrettyJSON(w, srv)
return } else {
} http.Error(w, "server not found", http.StatusNotFound)
urls := findHomeKitURLs()
for id, u := range urls {
deviceID := u.Query().Get("device_id")
for _, source := range sources {
if strings.Contains(source.URL, deviceID) {
source.Location = id
break
}
} }
} else {
api.ResponsePrettyJSON(w, servers)
} }
for _, source := range sources {
if source.Location == "" {
source.Location = " "
}
}
api.ResponseSources(w, sources)
case "POST": case "POST":
if err := r.ParseMultipartForm(1024); err != nil { id := r.Form.Get("id")
api.Error(w, err) rawURL := r.Form.Get("src") + "&pin=" + r.Form.Get("pin")
return if err := apiPair(id, rawURL); err != nil {
} http.Error(w, err.Error(), http.StatusInternalServerError)
if err := apiPair(r.Form.Get("id"), r.Form.Get("url")); err != nil {
api.Error(w, err)
} }
case "DELETE": case "DELETE":
if err := r.ParseMultipartForm(1024); err != nil { id := r.Form.Get("id")
api.Error(w, err) if err := apiUnpair(id); err != nil {
return http.Error(w, err.Error(), http.StatusInternalServerError)
}
if err := apiUnpair(r.Form.Get("id")); err != nil {
api.Error(w, err)
} }
} }
} }
func apiHomekitAccessories(w http.ResponseWriter, r *http.Request) {
id := r.URL.Query().Get("id")
stream := streams.Get(id)
if stream == nil {
http.Error(w, "", http.StatusNotFound)
return
}
rawURL := findHomeKitURL(stream.Sources())
if rawURL == "" {
http.Error(w, "", http.StatusBadRequest)
return
}
client, err := hap.Dial(rawURL)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer client.Close()
res, err := client.Get(hap.PathAccessories)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", api.MimeJSON)
_, _ = io.Copy(w, res.Body)
}
func discovery() ([]*api.Source, error) { func discovery() ([]*api.Source, error) {
var sources []*api.Source var sources []*api.Source
+33 -54
View File
@@ -2,8 +2,6 @@ package homekit
import ( import (
"errors" "errors"
"io"
"net"
"net/http" "net/http"
"strings" "strings"
@@ -26,6 +24,7 @@ func Init() {
Name string `yaml:"name"` Name string `yaml:"name"`
DeviceID string `yaml:"device_id"` DeviceID string `yaml:"device_id"`
DevicePrivate string `yaml:"device_private"` DevicePrivate string `yaml:"device_private"`
CategoryID string `yaml:"category_id"`
Pairings []string `yaml:"pairings"` Pairings []string `yaml:"pairings"`
} `yaml:"homekit"` } `yaml:"homekit"`
} }
@@ -35,12 +34,15 @@ func Init() {
streams.HandleFunc("homekit", streamHandler) streams.HandleFunc("homekit", streamHandler)
api.HandleFunc("api/homekit", apiHandler) api.HandleFunc("api/homekit", apiHomekit)
api.HandleFunc("api/homekit/accessories", apiHomekitAccessories)
api.HandleFunc("api/discovery/homekit", apiDiscovery)
if cfg.Mod == nil { if cfg.Mod == nil {
return return
} }
hosts = map[string]*server{}
servers = map[string]*server{} servers = map[string]*server{}
var entries []*mdns.ServiceEntry var entries []*mdns.ServiceEntry
@@ -63,36 +65,19 @@ func Init() {
deviceID := calcDeviceID(conf.DeviceID, id) // random MAC-address deviceID := calcDeviceID(conf.DeviceID, id) // random MAC-address
name := calcName(conf.Name, deviceID) name := calcName(conf.Name, deviceID)
setupID := calcSetupID(id)
srv := &server{ srv := &server{
stream: id, stream: id,
srtp: srtp.Server,
pairings: conf.Pairings, pairings: conf.Pairings,
setupID: setupID,
} }
srv.hap = &hap.Server{ srv.hap = &hap.Server{
Pin: pin, Pin: pin,
DeviceID: deviceID, DeviceID: deviceID,
DevicePrivate: calcDevicePrivate(conf.DevicePrivate, id), DevicePrivate: calcDevicePrivate(conf.DevicePrivate, id),
GetPair: srv.GetPair, GetClientPublic: srv.GetPair,
AddPair: srv.AddPair,
Handler: homekit.ServerHandler(srv),
}
if url := findHomeKitURL(stream.Sources()); url != "" {
// 1. Act as transparent proxy for HomeKit camera
dial := func() (net.Conn, error) {
client, err := homekit.Dial(url, srtp.Server)
if err != nil {
return nil, err
}
return client.Conn(), nil
}
srv.hap.Handler = homekit.ProxyHandler(srv, dial)
} else {
// 2. Act as basic HomeKit camera
srv.accessory = camera.NewAccessory("AlexxIT", "go2rtc", name, "-", app.Version)
srv.hap.Handler = homekit.ServerHandler(srv)
} }
srv.mdns = &mdns.ServiceEntry{ srv.mdns = &mdns.ServiceEntry{
@@ -106,23 +91,32 @@ func Init() {
hap.TXTProtoVersion: "1.1", hap.TXTProtoVersion: "1.1",
hap.TXTStateNumber: "1", hap.TXTStateNumber: "1",
hap.TXTStatusFlags: hap.StatusNotPaired, hap.TXTStatusFlags: hap.StatusNotPaired,
hap.TXTCategory: hap.CategoryCamera, hap.TXTCategory: calcCategoryID(conf.CategoryID),
hap.TXTSetupHash: srv.hap.SetupHash(), hap.TXTSetupHash: hap.SetupHash(setupID, deviceID),
}, },
} }
entries = append(entries, srv.mdns) entries = append(entries, srv.mdns)
srv.UpdateStatus() srv.UpdateStatus()
if url := findHomeKitURL(stream.Sources()); url != "" {
// 1. Act as transparent proxy for HomeKit camera
srv.proxyURL = url
} else {
// 2. Act as basic HomeKit camera
srv.accessory = camera.NewAccessory("AlexxIT", "go2rtc", name, "-", app.Version)
}
host := srv.mdns.Host(mdns.ServiceHAP) host := srv.mdns.Host(mdns.ServiceHAP)
servers[host] = srv hosts[host] = srv
servers[id] = srv
log.Trace().Msgf("[homekit] new server: %s", srv.mdns)
} }
api.HandleFunc(hap.PathPairSetup, hapHandler) api.HandleFunc(hap.PathPairSetup, hapHandler)
api.HandleFunc(hap.PathPairVerify, hapHandler) api.HandleFunc(hap.PathPairVerify, hapHandler)
log.Trace().Msgf("[homekit] mdns: %s", entries)
go func() { go func() {
if err := mdns.Serve(mdns.ServiceHAP, entries); err != nil { if err := mdns.Serve(mdns.ServiceHAP, entries); err != nil {
log.Error().Err(err).Caller().Send() log.Error().Err(err).Caller().Send()
@@ -131,6 +125,7 @@ func Init() {
} }
var log zerolog.Logger var log zerolog.Logger
var hosts map[string]*server
var servers map[string]*server var servers map[string]*server
func streamHandler(rawURL string) (core.Producer, error) { func streamHandler(rawURL string) (core.Producer, error) {
@@ -142,6 +137,8 @@ func streamHandler(rawURL string) (core.Producer, error) {
client, err := homekit.Dial(rawURL, srtp.Server) client, err := homekit.Dial(rawURL, srtp.Server)
if client != nil && rawQuery != "" { if client != nil && rawQuery != "" {
query := streams.ParseQuery(rawQuery) query := streams.ParseQuery(rawQuery)
client.MaxWidth = core.Atoi(query.Get("maxwidth"))
client.MaxHeight = core.Atoi(query.Get("maxheight"))
client.Bitrate = parseBitrate(query.Get("bitrate")) client.Bitrate = parseBitrate(query.Get("bitrate"))
} }
@@ -149,45 +146,27 @@ func streamHandler(rawURL string) (core.Producer, error) {
} }
func resolve(host string) *server { func resolve(host string) *server {
if len(servers) == 1 { if len(hosts) == 1 {
for _, srv := range servers { for _, srv := range hosts {
return srv return srv
} }
} }
if srv, ok := servers[host]; ok { if srv, ok := hosts[host]; ok {
return srv return srv
} }
return nil return nil
} }
func hapHandler(w http.ResponseWriter, r *http.Request) { func hapHandler(w http.ResponseWriter, r *http.Request) {
conn, rw, err := w.(http.Hijacker).Hijack()
if err != nil {
return
}
defer conn.Close()
// Can support multiple HomeKit cameras on single port ONLY for Apple devices. // Can support multiple HomeKit cameras on single port ONLY for Apple devices.
// Doesn't support Home Assistant and any other open source projects // Doesn't support Home Assistant and any other open source projects
// because they don't send the host header in requests. // because they don't send the host header in requests.
srv := resolve(r.Host) srv := resolve(r.Host)
if srv == nil { if srv == nil {
log.Error().Msg("[homekit] unknown host: " + r.Host) log.Error().Msg("[homekit] unknown host: " + r.Host)
_ = hap.WriteBackoff(rw)
return return
} }
srv.Handle(w, r)
switch r.RequestURI {
case hap.PathPairSetup:
err = srv.hap.PairSetup(r, rw, conn)
case hap.PathPairVerify:
err = srv.hap.PairVerify(r, rw, conn)
}
if err != nil && err != io.EOF {
log.Error().Err(err).Caller().Send()
}
} }
func findHomeKitURL(sources []string) string { func findHomeKitURL(sources []string) string {
@@ -203,7 +182,7 @@ func findHomeKitURL(sources []string) string {
if strings.HasPrefix(url, "hass") { if strings.HasPrefix(url, "hass") {
location, _ := streams.Location(url) location, _ := streams.Location(url)
if strings.HasPrefix(location, "homekit") { if strings.HasPrefix(location, "homekit") {
return url return location
} }
} }
+235 -95
View File
@@ -4,10 +4,16 @@ import (
"crypto/ed25519" "crypto/ed25519"
"crypto/sha512" "crypto/sha512"
"encoding/hex" "encoding/hex"
"encoding/json"
"errors"
"fmt" "fmt"
"io"
"net" "net"
"net/http"
"net/url" "net/url"
"slices"
"strings" "strings"
"sync"
"github.com/AlexxIT/go2rtc/internal/app" "github.com/AlexxIT/go2rtc/internal/app"
"github.com/AlexxIT/go2rtc/internal/ffmpeg" "github.com/AlexxIT/go2rtc/internal/ffmpeg"
@@ -16,23 +22,142 @@ import (
"github.com/AlexxIT/go2rtc/pkg/core" "github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/hap" "github.com/AlexxIT/go2rtc/pkg/hap"
"github.com/AlexxIT/go2rtc/pkg/hap/camera" "github.com/AlexxIT/go2rtc/pkg/hap/camera"
"github.com/AlexxIT/go2rtc/pkg/hap/hds"
"github.com/AlexxIT/go2rtc/pkg/hap/tlv8" "github.com/AlexxIT/go2rtc/pkg/hap/tlv8"
"github.com/AlexxIT/go2rtc/pkg/homekit" "github.com/AlexxIT/go2rtc/pkg/homekit"
"github.com/AlexxIT/go2rtc/pkg/magic" "github.com/AlexxIT/go2rtc/pkg/magic"
"github.com/AlexxIT/go2rtc/pkg/mdns" "github.com/AlexxIT/go2rtc/pkg/mdns"
"github.com/AlexxIT/go2rtc/pkg/srtp"
) )
type server struct { type server struct {
stream string // stream name from YAML hap *hap.Server // server for HAP connection and encryption
hap *hap.Server // server for HAP connection and encryption mdns *mdns.ServiceEntry
mdns *mdns.ServiceEntry
srtp *srtp.Server
accessory *hap.Accessory // HAP accessory
pairings []string // pairings list
streams map[string]*homekit.Consumer pairings []string // pairings list
consumer *homekit.Consumer conns []any
mu sync.Mutex
accessory *hap.Accessory // HAP accessory
consumer *homekit.Consumer
proxyURL string
setupID string
stream string // stream name from YAML
}
func (s *server) MarshalJSON() ([]byte, error) {
v := struct {
Name string `json:"name"`
DeviceID string `json:"device_id"`
Paired int `json:"paired,omitempty"`
CategoryID string `json:"category_id,omitempty"`
SetupCode string `json:"setup_code,omitempty"`
SetupID string `json:"setup_id,omitempty"`
Conns []any `json:"connections,omitempty"`
}{
Name: s.mdns.Name,
DeviceID: s.mdns.Info[hap.TXTDeviceID],
CategoryID: s.mdns.Info[hap.TXTCategory],
Paired: len(s.pairings),
Conns: s.conns,
}
if v.Paired == 0 {
v.SetupCode = s.hap.Pin
v.SetupID = s.setupID
}
return json.Marshal(v)
}
func (s *server) Handle(w http.ResponseWriter, r *http.Request) {
conn, rw, err := w.(http.Hijacker).Hijack()
if err != nil {
return
}
defer conn.Close()
// Fix reading from Body after Hijack.
r.Body = io.NopCloser(rw)
switch r.RequestURI {
case hap.PathPairSetup:
id, key, err := s.hap.PairSetup(r, rw)
if err != nil {
log.Error().Err(err).Caller().Send()
return
}
s.AddPair(id, key, hap.PermissionAdmin)
case hap.PathPairVerify:
id, key, err := s.hap.PairVerify(r, rw)
if err != nil {
log.Debug().Err(err).Caller().Send()
return
}
log.Debug().Str("stream", s.stream).Str("client_id", id).Msgf("[homekit] %s: new conn", conn.RemoteAddr())
controller, err := hap.NewConn(conn, rw, key, false)
if err != nil {
log.Error().Err(err).Caller().Send()
return
}
s.AddConn(controller)
defer s.DelConn(controller)
var handler homekit.HandlerFunc
switch {
case s.accessory != nil:
handler = homekit.ServerHandler(s)
case s.proxyURL != "":
client, err := hap.Dial(s.proxyURL)
if err != nil {
log.Error().Err(err).Caller().Send()
return
}
handler = homekit.ProxyHandler(s, client.Conn)
}
// If your iPhone goes to sleep, it will be an EOF error.
if err = handler(controller); err != nil && !errors.Is(err, io.EOF) {
log.Error().Err(err).Caller().Send()
return
}
}
}
type logger struct {
v any
}
func (l logger) String() string {
switch v := l.v.(type) {
case *hap.Conn:
return "hap " + v.RemoteAddr().String()
case *hds.Conn:
return "hds " + v.RemoteAddr().String()
case *homekit.Consumer:
return "rtp " + v.RemoteAddr
}
return "unknown"
}
func (s *server) AddConn(v any) {
log.Trace().Str("stream", s.stream).Msgf("[homekit] add conn %s", logger{v})
s.mu.Lock()
s.conns = append(s.conns, v)
s.mu.Unlock()
}
func (s *server) DelConn(v any) {
log.Trace().Str("stream", s.stream).Msgf("[homekit] del conn %s", logger{v})
s.mu.Lock()
if i := slices.Index(s.conns, v); i >= 0 {
s.conns = slices.Delete(s.conns, i, i+1)
}
s.mu.Unlock()
} }
func (s *server) UpdateStatus() { func (s *server) UpdateStatus() {
@@ -44,12 +169,68 @@ func (s *server) UpdateStatus() {
} }
} }
func (s *server) pairIndex(id string) int {
id = "client_id=" + id
for i, pairing := range s.pairings {
if strings.HasPrefix(pairing, id) {
return i
}
}
return -1
}
func (s *server) GetPair(id string) []byte {
s.mu.Lock()
defer s.mu.Unlock()
if i := s.pairIndex(id); i >= 0 {
query, _ := url.ParseQuery(s.pairings[i])
b, _ := hex.DecodeString(query.Get("client_public"))
return b
}
return nil
}
func (s *server) AddPair(id string, public []byte, permissions byte) {
log.Debug().Str("stream", s.stream).Msgf("[homekit] add pair id=%s public=%x perm=%d", id, public, permissions)
s.mu.Lock()
if s.pairIndex(id) < 0 {
s.pairings = append(s.pairings, fmt.Sprintf(
"client_id=%s&client_public=%x&permissions=%d", id, public, permissions,
))
s.UpdateStatus()
s.PatchConfig()
}
s.mu.Unlock()
}
func (s *server) DelPair(id string) {
log.Debug().Str("stream", s.stream).Msgf("[homekit] del pair id=%s", id)
s.mu.Lock()
if i := s.pairIndex(id); i >= 0 {
s.pairings = append(s.pairings[:i], s.pairings[i+1:]...)
s.UpdateStatus()
s.PatchConfig()
}
s.mu.Unlock()
}
func (s *server) PatchConfig() {
if err := app.PatchConfig([]string{"homekit", s.stream, "pairings"}, s.pairings); err != nil {
log.Error().Err(err).Msgf(
"[homekit] can't save %s pairings=%v", s.stream, s.pairings,
)
}
}
func (s *server) GetAccessories(_ net.Conn) []*hap.Accessory { func (s *server) GetAccessories(_ net.Conn) []*hap.Accessory {
return []*hap.Accessory{s.accessory} return []*hap.Accessory{s.accessory}
} }
func (s *server) GetCharacteristic(conn net.Conn, aid uint8, iid uint64) any { func (s *server) GetCharacteristic(conn net.Conn, aid uint8, iid uint64) any {
log.Trace().Msgf("[homekit] %s: get char aid=%d iid=0x%x", conn.RemoteAddr(), aid, iid) log.Trace().Str("stream", s.stream).Msgf("[homekit] get char aid=%d iid=0x%x", aid, iid)
char := s.accessory.GetCharacterByID(iid) char := s.accessory.GetCharacterByID(iid)
if char == nil { if char == nil {
@@ -59,11 +240,12 @@ func (s *server) GetCharacteristic(conn net.Conn, aid uint8, iid uint64) any {
switch char.Type { switch char.Type {
case camera.TypeSetupEndpoints: case camera.TypeSetupEndpoints:
if s.consumer == nil { consumer := s.consumer
if consumer == nil {
return nil return nil
} }
answer := s.consumer.GetAnswer() answer := consumer.GetAnswer()
v, err := tlv8.MarshalBase64(answer) v, err := tlv8.MarshalBase64(answer)
if err != nil { if err != nil {
return nil return nil
@@ -76,7 +258,7 @@ func (s *server) GetCharacteristic(conn net.Conn, aid uint8, iid uint64) any {
} }
func (s *server) SetCharacteristic(conn net.Conn, aid uint8, iid uint64, value any) { func (s *server) SetCharacteristic(conn net.Conn, aid uint8, iid uint64, value any) {
log.Trace().Msgf("[homekit] %s: set char aid=%d iid=0x%x value=%v", conn.RemoteAddr(), aid, iid, value) log.Trace().Str("stream", s.stream).Msgf("[homekit] set char aid=%d iid=0x%x value=%v", aid, iid, value)
char := s.accessory.GetCharacterByID(iid) char := s.accessory.GetCharacterByID(iid)
if char == nil { if char == nil {
@@ -86,61 +268,64 @@ func (s *server) SetCharacteristic(conn net.Conn, aid uint8, iid uint64, value a
switch char.Type { switch char.Type {
case camera.TypeSetupEndpoints: case camera.TypeSetupEndpoints:
var offer camera.SetupEndpoints var offer camera.SetupEndpointsRequest
if err := tlv8.UnmarshalBase64(value, &offer); err != nil { if err := tlv8.UnmarshalBase64(value, &offer); err != nil {
return return
} }
s.consumer = homekit.NewConsumer(conn, srtp2.Server) consumer := homekit.NewConsumer(conn, srtp2.Server)
s.consumer.SetOffer(&offer) consumer.SetOffer(&offer)
s.consumer = consumer
case camera.TypeSelectedStreamConfiguration: case camera.TypeSelectedStreamConfiguration:
var conf camera.SelectedStreamConfig var conf camera.SelectedStreamConfiguration
if err := tlv8.UnmarshalBase64(value, &conf); err != nil { if err := tlv8.UnmarshalBase64(value, &conf); err != nil {
return return
} }
log.Trace().Msgf("[homekit] %s stream id=%x cmd=%d", conn.RemoteAddr(), conf.Control.SessionID, conf.Control.Command) log.Trace().Str("stream", s.stream).Msgf("[homekit] stream id=%x cmd=%d", conf.Control.SessionID, conf.Control.Command)
switch conf.Control.Command { switch conf.Control.Command {
case camera.SessionCommandEnd: case camera.SessionCommandEnd:
if consumer := s.streams[conf.Control.SessionID]; consumer != nil { for _, consumer := range s.conns {
_ = consumer.Stop() if consumer, ok := consumer.(*homekit.Consumer); ok {
if consumer.SessionID() == conf.Control.SessionID {
_ = consumer.Stop()
return
}
}
} }
case camera.SessionCommandStart: case camera.SessionCommandStart:
if s.consumer == nil { consumer := s.consumer
if consumer == nil {
return return
} }
if !s.consumer.SetConfig(&conf) { if !consumer.SetConfig(&conf) {
log.Warn().Msgf("[homekit] wrong config") log.Warn().Msgf("[homekit] wrong config")
return return
} }
if s.streams == nil { s.AddConn(consumer)
s.streams = map[string]*homekit.Consumer{}
}
s.streams[conf.Control.SessionID] = s.consumer
stream := streams.Get(s.stream) stream := streams.Get(s.stream)
if err := stream.AddConsumer(s.consumer); err != nil { if err := stream.AddConsumer(consumer); err != nil {
return return
} }
go func() { go func() {
_, _ = s.consumer.WriteTo(nil) _, _ = consumer.WriteTo(nil)
stream.RemoveConsumer(s.consumer) stream.RemoveConsumer(consumer)
delete(s.streams, conf.Control.SessionID) s.DelConn(consumer)
}() }()
} }
} }
} }
func (s *server) GetImage(conn net.Conn, width, height int) []byte { func (s *server) GetImage(conn net.Conn, width, height int) []byte {
log.Trace().Msgf("[homekit] %s: get image width=%d height=%d", conn.RemoteAddr(), width, height) log.Trace().Str("stream", s.stream).Msgf("[homekit] get image width=%d height=%d", width, height)
stream := streams.Get(s.stream) stream := streams.Get(s.stream)
cons := magic.NewKeyframe() cons := magic.NewKeyframe()
@@ -166,69 +351,6 @@ func (s *server) GetImage(conn net.Conn, width, height int) []byte {
return b return b
} }
func (s *server) GetPair(conn net.Conn, id string) []byte {
log.Trace().Msgf("[homekit] %s: get pair id=%s", conn.RemoteAddr(), id)
for _, pairing := range s.pairings {
if !strings.Contains(pairing, id) {
continue
}
query, err := url.ParseQuery(pairing)
if err != nil {
continue
}
if query.Get("client_id") != id {
continue
}
s := query.Get("client_public")
b, _ := hex.DecodeString(s)
return b
}
return nil
}
func (s *server) AddPair(conn net.Conn, id string, public []byte, permissions byte) {
log.Trace().Msgf("[homekit] %s: add pair id=%s public=%x perm=%d", conn.RemoteAddr(), id, public, permissions)
query := url.Values{
"client_id": []string{id},
"client_public": []string{hex.EncodeToString(public)},
"permissions": []string{string('0' + permissions)},
}
if s.GetPair(conn, id) == nil {
s.pairings = append(s.pairings, query.Encode())
s.UpdateStatus()
s.PatchConfig()
}
}
func (s *server) DelPair(conn net.Conn, id string) {
log.Trace().Msgf("[homekit] %s: del pair id=%s", conn.RemoteAddr(), id)
id = "client_id=" + id
for i, pairing := range s.pairings {
if !strings.Contains(pairing, id) {
continue
}
s.pairings = append(s.pairings[:i], s.pairings[i+1:]...)
s.UpdateStatus()
s.PatchConfig()
break
}
}
func (s *server) PatchConfig() {
if err := app.PatchConfig([]string{"homekit", s.stream, "pairings"}, s.pairings); err != nil {
log.Error().Err(err).Msgf(
"[homekit] can't save %s pairings=%v", s.stream, s.pairings,
)
}
}
func calcName(name, seed string) string { func calcName(name, seed string) string {
if name != "" { if name != "" {
return name return name
@@ -263,3 +385,21 @@ func calcDevicePrivate(private, seed string) []byte {
b := sha512.Sum512([]byte(seed)) b := sha512.Sum512([]byte(seed))
return ed25519.NewKeyFromSeed(b[:ed25519.SeedSize]) return ed25519.NewKeyFromSeed(b[:ed25519.SeedSize])
} }
func calcSetupID(seed string) string {
b := sha512.Sum512([]byte(seed))
return fmt.Sprintf("%02X%02X", b[44], b[46])
}
func calcCategoryID(categoryID string) string {
switch categoryID {
case "bridge":
return hap.CategoryBridge
case "doorbell":
return hap.CategoryDoorbell
}
if core.Atoi(categoryID) > 0 {
return categoryID
}
return hap.CategoryCamera
}
+47
View File
@@ -0,0 +1,47 @@
# HTTP
This source supports receiving a stream via an HTTP link.
It can determine the source format from the`Content-Type` HTTP header:
- **HTTP-JPEG** (`image/jpeg`) - camera snapshot link, can be converted by go2rtc to MJPEG stream
- **HTTP-MJPEG** (`multipart/x-mixed-replace`) - A continuous sequence of JPEG frames (with HTTP headers).
- **HLS** (`application/vnd.apple.mpegurl`) - A popular [HTTP Live Streaming](https://en.wikipedia.org/wiki/HTTP_Live_Streaming) (HLS) format, which is not designed for real-time media transmission.
> [!WARNING]
> The HLS format is not designed for real time and is supported quite poorly. It is recommended to use it via ffmpeg source with buffering enabled (disabled by default).
## TCP
Source also supports HTTP and TCP streams with autodetection for different formats:
- `adts` - Audio stream in [AAC](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) codec with Audio Data Transport Stream (ADTS) headers.
- `flv` - The legacy but still used [Flash Video](https://en.wikipedia.org/wiki/Flash_Video) format.
- `h264` - AVC/H.264 bitstream.
- `hevc` - HEVC/H.265 bitstream.
- `mjpeg` - A continuous sequence of JPEG frames (without HTTP headers).
- `mpegts` - The legacy [MPEG transport stream](https://en.wikipedia.org/wiki/MPEG_transport_stream) format.
- `wav` - Audio stream in [WAV](https://en.wikipedia.org/wiki/WAV) format.
- `yuv4mpegpipe` - Raw YUV frame stream with YUV4MPEG header.
## Configuration
```yaml
streams:
# [HTTP-FLV] stream in video/x-flv format
http_flv: http://192.168.1.123:20880/api/camera/stream/780900131155/657617
# [JPEG] snapshots from Dahua camera, will be converted to MJPEG stream
dahua_snap: http://admin:password@192.168.1.123/cgi-bin/snapshot.cgi?channel=1
# [MJPEG] stream will be proxied without modification
http_mjpeg: https://mjpeg.sanford.io/count.mjpeg
# [MJPEG or H.264/H.265 bitstream or MPEG-TS]
tcp_magic: tcp://192.168.1.123:12345
# Add custom header
custom_header: "https://mjpeg.sanford.io/count.mjpeg#header=Authorization: Bearer XXX"
```
**PS.** Dahua camera has a bug: if you select MJPEG codec for RTSP second stream, snapshot won't work.
+14
View File
@@ -0,0 +1,14 @@
# Hikvision ISAPI
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
This source type supports only backchannel audio for the [Hikvision ISAPI](https://tpp.hikvision.com/download/ISAPI_OTAP) protocol. So it should be used as a second source in addition to the RTSP protocol.
## Configuration
```yaml
streams:
hikvision1:
- rtsp://admin:password@192.168.1.123:554/Streaming/Channels/101
- isapi://admin:password@192.168.1.123:80/
```
+10
View File
@@ -0,0 +1,10 @@
# Ivideon
Support public cameras from the service [Ivideon](https://tv.ivideon.com/).
## Configuration
```yaml
streams:
quailcam: ivideon:100-tu5dkUPct39cTp9oNEN2B6/0
```
+15
View File
@@ -0,0 +1,15 @@
# TP-Link Kasa
[`new in v1.7.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.7.0)
[TP-Link Kasa](https://www.kasasmart.com/) non-standard protocol [more info](https://medium.com/@hu3vjeen/reverse-engineering-tp-link-kc100-bac4641bf1cd).
- `username` - urlsafe email, `alex@gmail.com` -> `alex%40gmail.com`
- `password` - base64password, `secret1` -> `c2VjcmV0MQ==`
```yaml
streams:
kc401: kasa://username:password@192.168.1.123:19443/https/stream/mixed
```
Tested: KD110, KC200, KC401, KC420WS, EC71.
+13
View File
@@ -0,0 +1,13 @@
package kasa
import (
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/kasa"
)
func Init() {
streams.HandleFunc("kasa", func(source string) (core.Producer, error) {
return kasa.Dial(source)
})
}
+75 -5
View File
@@ -1,15 +1,71 @@
## Stream as ASCII to Terminal # Motion JPEG
- This module can provide and receive streams in MJPEG format.
- This module is also responsible for receiving snapshots in JPEG format.
- This module also supports streaming to the server console (terminal) in the **animated ASCII art** format.
## MJPEG Client
**Important.** For a stream in MJPEG format, your source MUST contain the MJPEG codec. If your stream has the MJPEG codec, you can receive an **MJPEG stream** or **JPEG snapshots** via the API.
You can receive an MJPEG stream in several ways:
- some cameras support MJPEG codec inside [RTSP stream](../rtsp/README.md) (ex. second stream for Dahua cameras)
- some cameras have an HTTP link with [MJPEG stream](../http/README.md)
- some cameras have an HTTP link with snapshots - go2rtc can convert them to [MJPEG stream](../http/README.md)
- you can convert an H264/H265 stream from your camera via [FFmpeg integration](../ffmpeg/README.md)
With this example, your stream will have both H264 and MJPEG codecs:
```yaml
streams:
camera1:
- rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0
- ffmpeg:camera1#video=mjpeg
```
## MJPEG Server
### mpjpeg
Output a stream in [MJPEG](https://en.wikipedia.org/wiki/Motion_JPEG) format. In [FFmpeg](https://ffmpeg.org/), this format is called `mpjpeg` because it contains HTTP headers.
```
ffplay http://192.168.1.123:1984/api/stream.mjpeg?src=camera1
```
### jpeg
Receiving a JPEG snapshot.
```
curl http://192.168.1.123:1984/api/frame.jpeg?src=camera1
```
- You can use `width`/`w` and/or `height`/`h` parameters.
- You can use `rotate` param with `90`, `180`, `270` or `-90` values.
- You can use `hardware`/`hw` param [read more](https://github.com/AlexxIT/go2rtc/wiki/Hardware-acceleration).
- You can use `cache` param (`1m`, `10s`, etc.) to get a cached snapshot.
- The snapshot is cached only when requested with the `cache` parameter.
- A cached snapshot will be used if its time is not older than the time specified in the `cache` parameter.
- The `cache` parameter does not check the image dimensions from the cache and those specified in the query.
### ascii
Stream as ASCII to Terminal. This format is just for fun. You can boast to your friends that you can stream cameras even to the server console without a GUI.
[![](https://img.youtube.com/vi/sHj_3h_sX7M/mqdefault.jpg)](https://www.youtube.com/watch?v=sHj_3h_sX7M) [![](https://img.youtube.com/vi/sHj_3h_sX7M/mqdefault.jpg)](https://www.youtube.com/watch?v=sHj_3h_sX7M)
> The demo video features a combination of several settings for this format with added audio. Of course, the format doesn't support audio out of the box.
**Tips** **Tips**
- this feature works only with MJPEG codec (use transcoding) - this feature works only with MJPEG codec (use transcoding)
- choose a low frame rate (FPS) - choose a low frame rate (FPS)
- choose the width and height to fit in your terminal - choose the width and height to fit in your terminal
- different terminals support different numbers of colours (8, 256, rgb) - different terminals support different numbers of colors (8, 256, rgb)
- escape text param with urlencode - URL-encode the `text` parameter
- you can stream any camera or file from a disc - you can stream any camera or file from disk
**go2rtc.yaml** - transcoding to MJPEG, terminal size - 210x59 (16/9), fps - 10 **go2rtc.yaml** - transcoding to MJPEG, terminal size - 210x59 (16/9), fps - 10
@@ -24,7 +80,7 @@ streams:
- example: `30` (black), `37` (white), `38;5;226` (yellow) - example: `30` (black), `37` (white), `38;5;226` (yellow)
- `back` - background color, values: empty, `8`, `256`, `rgb`, [SGR](https://en.wikipedia.org/wiki/ANSI_escape_code) - `back` - background color, values: empty, `8`, `256`, `rgb`, [SGR](https://en.wikipedia.org/wiki/ANSI_escape_code)
- example: `40` (black), `47` (white), `48;5;226` (yellow) - example: `40` (black), `47` (white), `48;5;226` (yellow)
- `text` - character set, values: empty, one char, `block`, list of chars (in order of brightness) - `text` - character set, values: empty, one character, `block`, list of chars (in order of brightness)
- example: `%20` (space), `block` (keyword for block elements), `ox` (two chars) - example: `%20` (space), `block` (keyword for block elements), `ox` (two chars)
**Examples** **Examples**
@@ -36,3 +92,17 @@ streams:
% 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&back=8&text=%20%20"
% curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&text=helloworld" % curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&text=helloworld"
``` ```
### yuv4mpegpipe
Raw [YUV](https://en.wikipedia.org/wiki/Y%E2%80%B2UV) frame stream with [YUV4MPEG](https://manned.org/yuv4mpeg) header.
```
ffplay http://192.168.1.123:1984/api/stream.y4m?src=camera1
```
## Streaming ingest
```shell
ffmpeg -re -i BigBuckBunny.mp4 -c mjpeg -f mpjpeg http://localhost:1984/api/stream.mjpeg?dst=camera1
```
@@ -6,6 +6,7 @@ import (
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
"sync"
"time" "time"
"github.com/AlexxIT/go2rtc/internal/api" "github.com/AlexxIT/go2rtc/internal/api"
@@ -36,12 +37,44 @@ func Init() {
var log zerolog.Logger var log zerolog.Logger
func handlerKeyframe(w http.ResponseWriter, r *http.Request) { func handlerKeyframe(w http.ResponseWriter, r *http.Request) {
stream := streams.GetOrPatch(r.URL.Query()) query := r.URL.Query()
stream, _ := streams.GetOrPatch(query)
if stream == nil { if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound) http.Error(w, api.StreamNotFound, http.StatusNotFound)
return return
} }
var b []byte
if s := query.Get("cache"); s != "" {
if timeout, err := time.ParseDuration(s); err == nil {
src := query.Get("src")
cacheMu.Lock()
entry, found := cache[src]
cacheMu.Unlock()
if found && time.Since(entry.timestamp) < timeout {
writeJPEGResponse(w, entry.payload)
return
}
defer func() {
if b == nil {
return
}
entry = cacheEntry{payload: b, timestamp: time.Now()}
cacheMu.Lock()
if cache == nil {
cache = map[string]cacheEntry{src: entry}
} else {
cache[src] = entry
}
cacheMu.Unlock()
}()
}
}
cons := magic.NewKeyframe() cons := magic.NewKeyframe()
cons.WithRequest(r) cons.WithRequest(r)
@@ -52,7 +85,7 @@ func handlerKeyframe(w http.ResponseWriter, r *http.Request) {
once := &core.OnceBuffer{} // init and first frame once := &core.OnceBuffer{} // init and first frame
_, _ = cons.WriteTo(once) _, _ = cons.WriteTo(once)
b := once.Buffer() b = once.Buffer()
stream.RemoveConsumer(cons) stream.RemoveConsumer(cons)
@@ -60,7 +93,7 @@ func handlerKeyframe(w http.ResponseWriter, r *http.Request) {
case core.CodecH264, core.CodecH265: case core.CodecH264, core.CodecH265:
ts := time.Now() ts := time.Now()
var err error var err error
if b, err = ffmpeg.JPEGWithQuery(b, r.URL.Query()); err != nil { if b, err = ffmpeg.JPEGWithQuery(b, query); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -69,6 +102,19 @@ func handlerKeyframe(w http.ResponseWriter, r *http.Request) {
b = mjpeg.FixJPEG(b) b = mjpeg.FixJPEG(b)
} }
writeJPEGResponse(w, b)
}
var cache map[string]cacheEntry
var cacheMu sync.Mutex
// cacheEntry represents a cached keyframe with its timestamp
type cacheEntry struct {
payload []byte
timestamp time.Time
}
func writeJPEGResponse(w http.ResponseWriter, b []byte) {
h := w.Header() h := w.Header()
h.Set("Content-Type", "image/jpeg") h.Set("Content-Type", "image/jpeg")
h.Set("Content-Length", strconv.Itoa(len(b))) h.Set("Content-Length", strconv.Itoa(len(b)))
@@ -145,7 +191,7 @@ func inputMjpeg(w http.ResponseWriter, r *http.Request) {
} }
func handlerWS(tr *ws.Transport, _ *ws.Message) error { func handlerWS(tr *ws.Transport, _ *ws.Message) error {
stream := streams.GetOrPatch(tr.Request.URL.Query()) stream, _ := streams.GetOrPatch(tr.Request.URL.Query())
if stream == nil { if stream == nil {
return errors.New(api.StreamNotFound) return errors.New(api.StreamNotFound)
} }
+66
View File
@@ -0,0 +1,66 @@
# MP4
This module provides several features:
1. MSE stream (fMP4 over WebSocket)
2. Camera snapshots in MP4 format (single frame), can be sent to [Telegram](#snapshot-to-telegram)
3. HTTP progressive streaming (MP4 file stream) - bad format for streaming because of high start delay. This format doesn't work in all Safari browsers, but go2rtc will automatically redirect it to HLS/fMP4 in this case.
## API examples
- MP4 snapshot: `http://192.168.1.123:1984/api/frame.mp4?src=camera1` (H264, H265)
- MP4 stream: `http://192.168.1.123:1984/api/stream.mp4?src=camera1` (H264, H265, AAC)
- MP4 file: `http://192.168.1.123:1984/api/stream.mp4?src=camera1` (H264, H265*, AAC, OPUS, MP3, PCMA, PCMU, PCM)
- You can use `mp4`, `mp4=flac` and `mp4=all` param for codec filters
- You can use `duration` param in seconds (ex. `duration=15`)
- You can use `filename` param (ex. `filename=record.mp4`)
- You can use `rotate` param with `90`, `180` or `270` values
- You can use `scale` param with positive integer values (ex. `scale=4:3`)
Read more about [codecs filters](../../README.md#codecs-filters).
**PS.** Rotate and scale params don't use transcoding and change video using metadata.
## Snapshot to Telegram
This examples for Home Assistant [Telegram Bot](https://www.home-assistant.io/integrations/telegram_bot/) integration.
- change `url` to your go2rtc web API (`http://localhost:1984/` for most users)
- change `target` to your Telegram chat ID (support list)
- change `src=camera1` to your stream name from go2rtc config
**Important.** Snapshot will be near instant for most cameras and many sources, except `ffmpeg` source. Because it takes a long time for ffmpeg to start streaming with video, even when you use `#video=copy`. Also the delay can be with cameras that do not start the stream with a keyframe.
### Snapshot from H264 or H265 camera
```yaml
service: telegram_bot.send_video
data:
url: http://localhost:1984/api/frame.mp4?src=camera1
target: 123456789
```
### Record from H264 or H265 camera
Record from service call to the future. Doesn't support loopback.
- `mp4=flac` - adds support PCM audio family
- `filename=record.mp4` - set name for downloaded file
```yaml
service: telegram_bot.send_video
data:
url: http://localhost:1984/api/stream.mp4?src=camera1&mp4=flac&duration=5&filename=record.mp4 # duration in seconds
target: 123456789
```
### Snapshot from JPEG or MJPEG camera
This example works via the [mjpeg](../mjpeg/README.md) module.
```yaml
service: telegram_bot.send_photo
data:
url: http://localhost:1984/api/frame.jpeg?src=camera1
target: 123456789
```
+1 -1
View File
@@ -91,7 +91,7 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
return return
} }
stream := streams.GetOrPatch(query) stream, _ := streams.GetOrPatch(query)
if stream == nil { if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound) http.Error(w, api.StreamNotFound, http.StatusNotFound)
return return
+2 -2
View File
@@ -11,7 +11,7 @@ import (
) )
func handlerWSMSE(tr *ws.Transport, msg *ws.Message) error { func handlerWSMSE(tr *ws.Transport, msg *ws.Message) error {
stream := streams.GetOrPatch(tr.Request.URL.Query()) stream, _ := streams.GetOrPatch(tr.Request.URL.Query())
if stream == nil { if stream == nil {
return errors.New(api.StreamNotFound) return errors.New(api.StreamNotFound)
} }
@@ -43,7 +43,7 @@ func handlerWSMSE(tr *ws.Transport, msg *ws.Message) error {
} }
func handlerWSMP4(tr *ws.Transport, msg *ws.Message) error { func handlerWSMP4(tr *ws.Transport, msg *ws.Message) error {
stream := streams.GetOrPatch(tr.Request.URL.Query()) stream, _ := streams.GetOrPatch(tr.Request.URL.Query())
if stream == nil { if stream == nil {
return errors.New(api.StreamNotFound) return errors.New(api.StreamNotFound)
} }
+25
View File
@@ -0,0 +1,25 @@
# MPEG
This module provides an [HTTP API](../api/README.md) for:
- Streaming output in `mpegts` format.
- Streaming output in `adts` format.
- Streaming ingest in `mpegts` format.
## MPEG-TS Server
```shell
ffplay http://localhost:1984/api/stream.ts?src=camera1
```
## ADTS Server
```shell
ffplay http://localhost:1984/api/stream.aac?src=camera1
```
## Streaming ingest
```shell
ffmpeg -re -i BigBuckBunny.mp4 -c copy -f mpegts http://localhost:1984/api/stream.ts?dst=camera1
```
@@ -1,10 +1,11 @@
package mpegts package mpeg
import ( import (
"net/http" "net/http"
"github.com/AlexxIT/go2rtc/internal/api" "github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/streams" "github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/aac"
"github.com/AlexxIT/go2rtc/pkg/mpegts" "github.com/AlexxIT/go2rtc/pkg/mpegts"
) )
@@ -66,3 +67,26 @@ func inputMpegTS(w http.ResponseWriter, r *http.Request) {
return return
} }
} }
func apiStreamAAC(w http.ResponseWriter, r *http.Request) {
src := r.URL.Query().Get("src")
stream := streams.Get(src)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}
cons := aac.NewConsumer()
cons.WithRequest(r)
if err := stream.AddConsumer(cons); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "audio/aac")
_, _ = cons.WriteTo(w)
stream.RemoveConsumer(cons)
}
-32
View File
@@ -1,32 +0,0 @@
package mpegts
import (
"net/http"
"github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/aac"
)
func apiStreamAAC(w http.ResponseWriter, r *http.Request) {
src := r.URL.Query().Get("src")
stream := streams.Get(src)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}
cons := aac.NewConsumer()
cons.WithRequest(r)
if err := stream.AddConsumer(cons); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "audio/aac")
_, _ = cons.WriteTo(w)
stream.RemoveConsumer(cons)
}
+22
View File
@@ -0,0 +1,22 @@
# TP-Link MULTITRANS
[`new in v1.9.14`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.14) by [@forrestsocool](https://github.com/forrestsocool)
Two-way audio support for Chinese version of [TP-Link](https://www.tp-link.com.cn/) cameras.
## Configuration
```yaml
streams:
tplink_cam:
# video uses standard RTSP
- rtsp://admin:admin@192.168.1.202:554/stream1
# two-way audio uses MULTITRANS schema
- multitrans://admin:admin@192.168.1.202:554
```
## Useful links
- https://www.tp-link.com.cn/list_2549.html
- https://github.com/AlexxIT/go2rtc/issues/1724
- https://github.com/bingooo/hass-tplink-ipc/
+10
View File
@@ -0,0 +1,10 @@
package multitrans
import (
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/multitrans"
)
func Init() {
streams.HandleFunc("multitrans", multitrans.Dial)
}
+11
View File
@@ -0,0 +1,11 @@
# Google Nest
[`new in v1.6.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.6.0)
For simplicity, it is recommended to connect the Nest/WebRTC camera to the [Home Assistant](../hass/README.md).
But if you can somehow get the below parameters, Nest/WebRTC source will work without Home Assistant.
```yaml
streams:
nest-doorbell: nest:?client_id=***&client_secret=***&refresh_token=***&project_id=***&device_id=***
```
+8 -6
View File
@@ -1,19 +1,21 @@
With ngrok integration, you can get external access to your streams in situations when you have Internet with a private IP address. # ngrok
With the ngrok integration, you can get external access to your streams when your Internet connection is behind a private IP address.
- you may need external access for two different things: - you may need external access for two different things:
- WebRTC stream, so you need a tunnel WebRTC TCP port (ex. 8555) - WebRTC streams (tunnel the WebRTC TCP port, e.g. 8555)
- go2rtc web interface, so you need a tunnel API HTTP port (ex. 1984) - go2rtc web interface (tunnel the API HTTP port, e.g. 1984)
- ngrok supports authorization for your web interface - ngrok supports authorization for your web interface
- ngrok automatically adds HTTPS to your web interface - ngrok automatically adds HTTPS to your web interface
The ngrok free subscription has the following limitations: The ngrok free subscription has the following limitations:
- You can reserve a free domain for serving the web interface, but the TCP address you get will always be random and change with each restart of the ngrok agent (not a problem for WebRTC stream) - You can reserve a free domain for serving the web interface, but the TCP address you get will always be random and will change with each restart of the ngrok agent (not a problem for WebRTC streams)
- You can forward multiple ports from a single agent, but you can only run one ngrok agent on the free plan - You can forward multiple ports from a single agent, but you can only run one ngrok agent on the free plan
go2rtc will automatically get your external TCP address (if you enable it in ngrok config) and use it with WebRTC connection (if you enable it in webrtc config). go2rtc will automatically get your external TCP address (if you enable it in the ngrok config) and use it for WebRTC connections (if you enable it in the WebRTC config).
You need to manually download the [ngrok agent app](https://ngrok.com/download) for your OS and register with the [ngrok service](https://ngrok.com/signup). You need to manually download the [ngrok agent](https://ngrok.com/download) for your OS and register with the [ngrok service](https://ngrok.com/signup).
**Tunnel for only WebRTC Stream** **Tunnel for only WebRTC Stream**
+18 -1
View File
@@ -1,5 +1,22 @@
# ONVIF # ONVIF
## ONVIF Client
[`new in v1.5.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.5.0)
The source is not very useful if you already know RTSP and snapshot links for your camera. But it can be useful if you don't.
**WebUI > Add** webpage supports ONVIF autodiscovery. Your server must be on the same subnet as the camera. If you use Docker, you must use "network host".
```yaml
streams:
dahua1: onvif://admin:password@192.168.1.123
reolink1: onvif://admin:password@192.168.1.123:8000
tapo1: onvif://admin:password@192.168.1.123:2020
```
## ONVIF Server
A regular camera has a single video source (`GetVideoSources`) and two profiles (`GetProfiles`). A regular camera has a single video source (`GetVideoSources`) and two profiles (`GetProfiles`).
Go2rtc has one video source and one profile per stream. Go2rtc has one video source and one profile per stream.
@@ -13,7 +30,7 @@ Go2rtc works as ONVIF server:
- Onvier (android) - Onvier (android)
- ONVIF Device Manager (windows) - ONVIF Device Manager (windows)
PS. Support only TCP transport for RTSP protocol. UDP and HTTP transports - unsupported yet. PS. Supports only TCP transport for RTSP protocol. UDP and HTTP transports - unsupported yet.
## Tested cameras ## Tested cameras
+26 -14
View File
@@ -7,6 +7,7 @@ import (
"net/url" "net/url"
"os" "os"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/AlexxIT/go2rtc/internal/api" "github.com/AlexxIT/go2rtc/internal/api"
@@ -43,8 +44,17 @@ func streamOnvif(rawURL string) (core.Producer, error) {
return nil, err return nil, err
} }
// Append hash-based arguments to the retrieved URI
if i := strings.IndexByte(rawURL, '#'); i > 0 {
uri += rawURL[i:]
}
log.Debug().Msgf("[onvif] new uri=%s", uri) log.Debug().Msgf("[onvif] new uri=%s", uri)
if err = streams.Validate(uri); err != nil {
return nil, err
}
return streams.GetProducer(uri) return streams.GetProducer(uri)
} }
@@ -64,8 +74,10 @@ func onvifDeviceService(w http.ResponseWriter, r *http.Request) {
log.Trace().Msgf("[onvif] server request %s %s:\n%s", r.Method, r.RequestURI, b) log.Trace().Msgf("[onvif] server request %s %s:\n%s", r.Method, r.RequestURI, b)
switch operation { switch operation {
case onvif.DeviceGetNetworkInterfaces, // important for Hass case onvif.ServiceGetServiceCapabilities, // important for Hass
onvif.DeviceGetNetworkInterfaces, // important for Hass
onvif.DeviceGetSystemDateAndTime, // important for Hass onvif.DeviceGetSystemDateAndTime, // important for Hass
onvif.DeviceSetSystemDateAndTime, // return just OK
onvif.DeviceGetDiscoveryMode, onvif.DeviceGetDiscoveryMode,
onvif.DeviceGetDNS, onvif.DeviceGetDNS,
onvif.DeviceGetHostname, onvif.DeviceGetHostname,
@@ -73,8 +85,10 @@ func onvifDeviceService(w http.ResponseWriter, r *http.Request) {
onvif.DeviceGetNetworkProtocols, onvif.DeviceGetNetworkProtocols,
onvif.DeviceGetNTP, onvif.DeviceGetNTP,
onvif.DeviceGetScopes, onvif.DeviceGetScopes,
onvif.MediaGetVideoEncoderConfiguration,
onvif.MediaGetVideoEncoderConfigurations, onvif.MediaGetVideoEncoderConfigurations,
onvif.MediaGetAudioEncoderConfigurations, onvif.MediaGetAudioEncoderConfigurations,
onvif.MediaGetVideoEncoderConfigurationOptions,
onvif.MediaGetAudioSources, onvif.MediaGetAudioSources,
onvif.MediaGetAudioSourceConfigurations: onvif.MediaGetAudioSourceConfigurations:
b = onvif.StaticResponse(operation) b = onvif.StaticResponse(operation)
@@ -90,11 +104,6 @@ func onvifDeviceService(w http.ResponseWriter, r *http.Request) {
// important for Hass: SerialNumber (unique server ID) // important for Hass: SerialNumber (unique server ID)
b = onvif.GetDeviceInformationResponse("", "go2rtc", app.Version, r.Host) b = onvif.GetDeviceInformationResponse("", "go2rtc", app.Version, r.Host)
case onvif.ServiceGetServiceCapabilities:
// important for Hass
// TODO: check path links to media
b = onvif.GetMediaServiceCapabilitiesResponse()
case onvif.DeviceSystemReboot: case onvif.DeviceSystemReboot:
b = onvif.StaticResponse(operation) b = onvif.StaticResponse(operation)
@@ -124,8 +133,7 @@ func onvifDeviceService(w http.ResponseWriter, r *http.Request) {
case onvif.MediaGetStreamUri: case onvif.MediaGetStreamUri:
host, _, err := net.SplitHostPort(r.Host) host, _, err := net.SplitHostPort(r.Host)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) host = r.Host // in case of Host without port
return
} }
uri := "rtsp://" + host + ":" + rtsp.Port + "/" + onvif.FindTagValue(b, "ProfileToken") uri := "rtsp://" + host + ":" + rtsp.Port + "/" + onvif.FindTagValue(b, "ProfileToken")
@@ -156,21 +164,21 @@ func apiOnvif(w http.ResponseWriter, r *http.Request) {
var items []*api.Source var items []*api.Source
if src == "" { if src == "" {
urls, err := onvif.DiscoveryStreamingURLs() devices, err := onvif.DiscoveryStreamingDevices()
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
for _, rawURL := range urls { for _, device := range devices {
u, err := url.Parse(rawURL) u, err := url.Parse(device.URL)
if err != nil { if err != nil {
log.Warn().Str("url", rawURL).Msg("[onvif] broken") log.Warn().Str("url", device.URL).Msg("[onvif] broken")
continue continue
} }
if u.Scheme != "http" { if u.Scheme != "http" {
log.Warn().Str("url", rawURL).Msg("[onvif] unsupported") log.Warn().Str("url", device.URL).Msg("[onvif] unsupported")
continue continue
} }
@@ -181,7 +189,11 @@ func apiOnvif(w http.ResponseWriter, r *http.Request) {
u.Path = "" u.Path = ""
} }
items = append(items, &api.Source{Name: u.Host, URL: u.String()}) items = append(items, &api.Source{
Name: u.Host,
URL: u.String(),
Info: device.Name + " " + device.Hardware,
})
} }
} else { } else {
client, err := onvif.NewClient(src) client, err := onvif.NewClient(src)
+54
View File
@@ -0,0 +1,54 @@
# Pinggy
[Pinggy](https://pinggy.io/) - nice service for public tunnels to your local services.
**Features:**
- A free account does not require registration.
- It does not require downloading third-party binaries and works over the SSH protocol.
- Works with HTTP, TCP and UDP protocols.
- Creates HTTPS for your HTTP services.
> [!IMPORTANT]
> A free account creates a tunnel with a random address that only works for an hour. It is suitable for testing purposes ONLY.
> [!CAUTION]
> Public access to go2rtc without authorization puts your entire home network at risk. Use with caution.
**Why:**
- It's easy to set up HTTPS for testing two-way audio.
- It's easy to check whether external access via WebRTC technology will work.
- It's easy to share direct access to your RTSP or HTTP camera with the go2rtc developer. If such access is necessary to debug your problem.
## Configuration
You will find public links in the go2rtc log after startup.
**Tunnel to go2rtc WebUI.**
```yaml
pinggy:
tunnel: http://localhost:1984
```
**Tunnel to RTSP camera.**
For example, you have camera: `rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0`
```yaml
pinggy:
tunnel: tcp://192.168.10.91:554
```
In go2rtc logs you will get similar output:
```
16:17:43.167 INF [pinggy] proxy url=tcp://abcde-123-123-123-123.a.free.pinggy.link:12345
```
Now you have a working stream:
```
rtsp://admin:password@abcde-123-123-123-123.a.free.pinggy.link:12345/cam/realmonitor?channel=1&subtype=0
```
+60
View File
@@ -0,0 +1,60 @@
package pinggy
import (
"net/url"
"github.com/AlexxIT/go2rtc/internal/app"
"github.com/AlexxIT/go2rtc/pkg/pinggy"
"github.com/rs/zerolog"
)
func Init() {
var cfg struct {
Mod struct {
Tunnel string `yaml:"tunnel"`
} `yaml:"pinggy"`
}
app.LoadConfig(&cfg)
if cfg.Mod.Tunnel == "" {
return
}
log = app.GetLogger("pinggy")
u, err := url.Parse(cfg.Mod.Tunnel)
if err != nil {
log.Error().Err(err).Send()
return
}
go proxy(u.Scheme, u.Host)
}
var log zerolog.Logger
func proxy(proto, address string) {
client, err := pinggy.NewClient(proto)
if err != nil {
log.Error().Err(err).Send()
return
}
defer client.Close()
urls, err := client.GetURLs()
if err != nil {
log.Error().Err(err).Send()
return
}
for _, s := range urls {
log.Info().Str("url", s).Msgf("[pinggy] proxy")
}
err = client.Proxy(address)
if err != nil {
log.Error().Err(err).Send()
return
}
}
+17
View File
@@ -0,0 +1,17 @@
# Ring
[`new in v1.9.13`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.13) by [@seydx](https://github.com/seydx)
This source type supports Ring cameras with [two-way audio](../../README.md#two-way-audio) support.
## Configuration
If you have a `refresh_token` and `device_id`, you can use them in the `go2rtc.yaml` config file.
Otherwise, you can use the go2rtc web interface and add your Ring account (WebUI > Add > Ring). Once added, it will list all your Ring cameras.
```yaml
streams:
ring: ring:?device_id=XXX&refresh_token=XXX
ring_snapshot: ring:?device_id=XXX&refresh_token=XXX&snapshot
```
+15
View File
@@ -0,0 +1,15 @@
# Roborock
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
This source type supports Roborock vacuums with cameras. Known working models:
- **Roborock S6 MaxV** - only video (the vacuum has no microphone)
- **Roborock S7 MaxV** - video and two-way audio
- **Roborock Qrevo MaxV** - video and two-way audio
## Configuration
This source supports loading Roborock credentials from the Home Assistant [custom integration](https://github.com/humbertogontijo/homeassistant-roborock) or the [core integration](https://www.home-assistant.io/integrations/roborock). Otherwise, you need to log in to your Roborock account (MiHome account is not supported). Go to go2rtc WebUI > Add webpage. Copy the `roborock://...` source for your vacuum and paste it into your `go2rtc.yaml` config.
If you have a pattern PIN for your vacuum, add it as a numeric PIN (lines: 123, 456, 789) to the end of the `roborock` link.
+61 -3
View File
@@ -1,4 +1,62 @@
## Tested client # Real-Time Messaging Protocol
This module provides the following features for the RTMP protocol:
- Streaming input - [RTMP client](#rtmp-client)
- Streaming output and ingest in `rtmp` format - [RTMP server](#rtmp-server)
- Streaming output and ingest in `flv` format - [FLV server](#flv-server)
## RTMP Client
You can get a stream from an RTMP server, for example [Nginx with nginx-rtmp-module](https://github.com/arut/nginx-rtmp-module).
### Client Configuration
```yaml
streams:
rtmp_stream: rtmp://192.168.1.123/live/camera1
```
## RTMP Server
[`new in v1.8.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.8.0)
Streaming output stream in `rtmp` format:
```shell
ffplay rtmp://localhost:1935/camera1
```
Streaming ingest stream in `rtmp` format:
```shell
ffmpeg -re -i BigBuckBunny.mp4 -c copy -f flv rtmp://localhost:1935/camera1
```
### Server Configuration
By default, the RTMP server is disabled.
```yaml
rtmp:
listen: ":1935" # by default - disabled!
```
## FLV Server
Streaming output in `flv` format.
```shell
ffplay http://localhost:1984/stream.flv?src=camera1
```
Streaming ingest in `flv` format.
```shell
ffmpeg -re -i BigBuckBunny.mp4 -c copy -f flv http://localhost:1984/api/stream.flv?dst=camera1
```
## Tested clients
| From | To | Comment | | From | To | Comment |
|--------|---------------------------------|---------| |--------|---------------------------------|---------|
@@ -37,8 +95,8 @@ Settings > Stream:
- Service: Custom - Service: Custom
- Server: rtmp://192.168.10.101/tmp - Server: rtmp://192.168.10.101/tmp
- Stream Key: <empty> - Stream Key: `<empty>`
- Use auth: <disabled> - Use auth: `<disabled>`
**OpenIPC** **OpenIPC**
+93
View File
@@ -0,0 +1,93 @@
# Real Time Streaming Protocol
This module provides the following features for the RTSP protocol:
- Streaming input - [RTSP client](#rtsp-client)
- Streaming output - [RTSP server](#rtsp-server)
- [Streaming ingest](#streaming-ingest)
- [Two-way audio](#two-way-audio)
## RTSP Client
### Configuration
```yaml
streams:
sonoff_camera: rtsp://rtsp:12345678@192.168.1.123/av_stream/ch0
dahua_camera:
- rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
- rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=1#backchannel=0
amcrest_doorbell:
- rtsp://username:password@192.168.1.123:554/cam/realmonitor?channel=1&subtype=0#backchannel=0
unifi_camera: rtspx://192.168.1.123:7441/fD6ouM72bWoFijxK
glichy_camera: ffmpeg:rtsp://username:password@192.168.1.123/live/ch00_1
```
### Recommendations
- **Amcrest Doorbell** users may want to disable two-way audio, because with an active stream, you won't have a working call button. You need to add `#backchannel=0` to the end of your RTSP link in YAML config file
- **Dahua Doorbell** users may want to change [audio codec](https://github.com/AlexxIT/go2rtc/issues/49#issuecomment-2127107379) for proper two-way audio. Make sure not to request backchannel multiple times by adding `#backchannel=0` to other stream sources of the same doorbell. The `unicast=true&proto=Onvif` is preferred for two-way audio as this makes the doorbell accept multiple codecs for the incoming audio
- **Reolink** users may want NOT to use RTSP protocol at all, some camera models have a very awful, unusable stream implementation
- **Ubiquiti UniFi** users may want to disable HTTPS verification. Use `rtspx://` prefix instead of `rtsps://`. And don't use `?enableSrtp` [suffix](https://github.com/AlexxIT/go2rtc/issues/81)
- **TP-Link Tapo** users may skip login and password, because go2rtc supports login [without them](https://drmnsamoliu.github.io/video.html)
- If your camera has two RTSP links, you can add both as sources. This is useful when streams have different codecs, for example AAC audio with main stream and PCMU/PCMA audio with second stream
- If the stream from your camera is glitchy, try using [ffmpeg source](../ffmpeg/README.md). It will not add CPU load if you don't use transcoding
- If the stream from your camera is very glitchy, try to use transcoding with [ffmpeg source](../ffmpeg/README.md)
### Other options
Format: `rtsp...#{param1}#{param2}#{param3}`
- Add custom timeout `#timeout=30` (in seconds)
- Ignore audio - `#media=video` or ignore video - `#media=audio`
- Ignore two-way audio API `#backchannel=0` - important for some glitchy cameras
- Use WebSocket transport `#transport=ws...`
### RTSP over WebSocket
```yaml
streams:
# WebSocket with authorization, RTSP - without
axis-rtsp-ws: rtsp://192.168.1.123:4567/axis-media/media.amp?overview=0&camera=1&resolution=1280x720&videoframeskipmode=empty&Axis-Orig-Sw=true#transport=ws://user:pass@192.168.1.123:4567/rtsp-over-websocket
# WebSocket without authorization, RTSP - with
dahua-rtsp-ws: rtsp://user:pass@192.168.1.123/cam/realmonitor?channel=1&subtype=1&proto=Private3#transport=ws://192.168.1.123/rtspoverwebsocket
```
## RTSP Server
You can get any stream as RTSP-stream: `rtsp://192.168.1.123:8554/{stream_name}`
You can enable external password protection for your RTSP streams. Password protection is always disabled for localhost calls (ex. FFmpeg or Home Assistant on the same server).
### Configuration
```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
```
By default go2rtc provide RTSP-stream with only one first video and only one first audio. You can change it with the `default_query` setting:
- `default_query: "mp4"` - MP4 compatible codecs (H264, H265, AAC)
- `default_query: "video=all&audio=all"` - all tracks from all source (not all players can handle this)
- `default_query: "video=h264,h265"` - only one video track (H264 or H265)
- `default_query: "video&audio=all"` - only one first any video and all audio as separate tracks
Read more about [codecs filters](../../README.md#codecs-filters).
## Streaming ingest
```shell
ffmpeg -re -i BigBuckBunny.mp4 -c copy -rtsp_transport tcp -f rtsp rtsp://localhost:8554/camera1
```
## Two-way audio
Before purchasing, it is difficult to understand whether the camera supports two-way audio via the RTSP protocol or not. This isn't usually mentioned in a camera's description. You can only find out by reading reviews from real buyers.
A camera is considered to support two-way audio if it supports the ONVIF Profile T protocol. But in reality, this isn't always the case. And the ONVIF protocol has no connection with the camera's RTSP implementation.
In go2rtc you can find out if the camera supports two-way audio via WebUI > stream probe.
+2
View File
@@ -198,6 +198,8 @@ func tcpHandler(conn *rtsp.Conn) {
{Name: core.CodecPCM, ClockRate: 8000}, {Name: core.CodecPCM, ClockRate: 8000},
{Name: core.CodecPCMA, ClockRate: 8000}, {Name: core.CodecPCMA, ClockRate: 8000},
{Name: core.CodecPCMU, ClockRate: 8000}, {Name: core.CodecPCMU, ClockRate: 8000},
{Name: core.CodecAAC, ClockRate: 8000},
{Name: core.CodecAAC, ClockRate: 16000},
}, },
}) })
} }
+13
View File
@@ -0,0 +1,13 @@
# SRTP
This is a support module for the [HomeKit](../homekit/README.md) module.
> [!NOTE]
> This module can be removed and its functionality transferred to the homekit module.
## Configuration
```yaml
srtp:
listen: :8443 # enabled by default
```
+86
View File
@@ -1,3 +1,89 @@
# Streams
This core module is responsible for managing the stream list.
## Stream to camera
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
go2rtc supports playing audio files (ex. music or [TTS](https://www.home-assistant.io/integrations/#text-to-speech)) and live streams (ex. radio) on cameras with [two-way audio](../../README.md#two-way-audio) support.
API example:
```text
POST http://localhost:1984/api/streams?dst=camera1&src=ffmpeg:http://example.com/song.mp3#audio=pcma#input=file
```
- you can stream: local files, web files, live streams or any format, supported by FFmpeg
- you should use [ffmpeg source](../ffmpeg/README.md) for transcoding audio to codec, that your camera supports
- you can check camera codecs on the go2rtc WebUI info page when the stream is active
- some cameras support only low quality `PCMA/8000` codec (ex. [Tapo](../tapo/README.md))
- it is recommended to choose higher quality formats if your camera supports them (ex. `PCMA/48000` for some Dahua cameras)
- if you play files over `http` link, you need to add `#input=file` params for transcoding, so the file will be transcoded and played in real time
- if you play live streams, you should skip `#input` param, because it is already in real time
- you can stop active playback by calling the API with the empty `src` parameter
- you will see one active producer and one active consumer in go2rtc WebUI info page during streaming
## Publish stream
[`new in v1.8.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.8.0)
You can publish any stream to streaming services (YouTube, Telegram, etc.) via RTMP/RTMPS. Important:
- Supported codecs: H264 for video and AAC for audio
- AAC audio is required for YouTube; videos without audio will not work
- You don't need to enable [RTMP module](../rtmp/README.md) listening for this task
You can use the API:
```text
POST http://localhost:1984/api/streams?src=camera1&dst=rtmps://...
```
Or config file:
```yaml
publish:
# publish stream "video_audio_transcode" to Telegram
video_audio_transcode:
- rtmps://xxx-x.rtmp.t.me/s/xxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxx
# publish stream "audio_transcode" to Telegram and YouTube
audio_transcode:
- rtmps://xxx-x.rtmp.t.me/s/xxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxx
- rtmp://xxx.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx-xxxx
streams:
video_audio_transcode:
- ffmpeg:rtsp://user:pass@192.168.1.123/stream1#video=h264#hardware#audio=aac
audio_transcode:
- ffmpeg:rtsp://user:pass@192.168.1.123/stream1#video=copy#audio=aac
```
- **Telegram Desktop App** > Any public or private channel or group (where you admin) > Live stream > Start with... > Start streaming.
- **YouTube** > Create > Go live > Stream latency: Ultra low-latency > Copy: Stream URL + Stream key.
## Preload stream
[`new in v1.9.11`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.11)
You can preload any stream on go2rtc start. This is useful for cameras that take a long time to start up.
```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
```
## Examples ## Examples
```yaml ```yaml
+16 -13
View File
@@ -52,8 +52,8 @@ func apiStreams(w http.ResponseWriter, r *http.Request) {
name = src name = src
} }
if New(name, query["src"]...) == nil { if _, err := New(name, query["src"]...); err != nil {
http.Error(w, "", http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }
@@ -69,8 +69,8 @@ func apiStreams(w http.ResponseWriter, r *http.Request) {
} }
// support {input} templates: https://github.com/AlexxIT/go2rtc#module-hass // support {input} templates: https://github.com/AlexxIT/go2rtc#module-hass
if Patch(name, src) == nil { if _, err := Patch(name, src); err != nil {
http.Error(w, "", http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
} }
case "POST": case "POST":
@@ -130,16 +130,15 @@ func apiStreamsDOT(w http.ResponseWriter, r *http.Request) {
} }
func apiPreload(w http.ResponseWriter, r *http.Request) { func apiPreload(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query() // GET - return all preloads
src := query.Get("src") if r.Method == "GET" {
api.ResponseJSON(w, GetPreloads())
// check if stream exists
stream := Get(src)
if stream == nil {
http.Error(w, "", http.StatusNotFound)
return return
} }
query := r.URL.Query()
src := query.Get("src")
switch r.Method { switch r.Method {
case "PUT": case "PUT":
// it's safe to delete from map while iterating // it's safe to delete from map while iterating
@@ -153,7 +152,7 @@ func apiPreload(w http.ResponseWriter, r *http.Request) {
rawQuery := query.Encode() rawQuery := query.Encode()
if err := AddPreload(stream, rawQuery); err != nil { if err := AddPreload(src, rawQuery); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -163,7 +162,7 @@ func apiPreload(w http.ResponseWriter, r *http.Request) {
} }
case "DELETE": case "DELETE":
if err := DelPreload(stream); err != nil { if err := DelPreload(src); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -176,3 +175,7 @@ func apiPreload(w http.ResponseWriter, r *http.Request) {
http.Error(w, "", http.StatusMethodNotAllowed) http.Error(w, "", http.StatusMethodNotAllowed)
} }
} }
func apiSchemes(w http.ResponseWriter, r *http.Request) {
api.ResponseJSON(w, SupportedSchemes())
}
+66
View File
@@ -0,0 +1,66 @@
package streams
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/stretchr/testify/require"
)
func TestApiSchemes(t *testing.T) {
// Setup: Register some test handlers and redirects
HandleFunc("rtsp", func(url string) (core.Producer, error) { return nil, nil })
HandleFunc("rtmp", func(url string) (core.Producer, error) { return nil, nil })
RedirectFunc("http", func(url string) (string, error) { return "", nil })
t.Run("GET request returns schemes", func(t *testing.T) {
req := httptest.NewRequest("GET", "/api/schemes", nil)
w := httptest.NewRecorder()
apiSchemes(w, req)
require.Equal(t, http.StatusOK, w.Code)
require.Equal(t, "application/json", w.Header().Get("Content-Type"))
var schemes []string
err := json.Unmarshal(w.Body.Bytes(), &schemes)
require.NoError(t, err)
require.NotEmpty(t, schemes)
// Check that our test schemes are in the response
require.Contains(t, schemes, "rtsp")
require.Contains(t, schemes, "rtmp")
require.Contains(t, schemes, "http")
})
}
func TestApiSchemesNoDuplicates(t *testing.T) {
// Setup: Register a scheme in both handlers and redirects
HandleFunc("duplicate", func(url string) (core.Producer, error) { return nil, nil })
RedirectFunc("duplicate", func(url string) (string, error) { return "", nil })
req := httptest.NewRequest("GET", "/api/schemes", nil)
w := httptest.NewRecorder()
apiSchemes(w, req)
require.Equal(t, http.StatusOK, w.Code)
var schemes []string
err := json.Unmarshal(w.Body.Bytes(), &schemes)
require.NoError(t, err)
// Count occurrences of "duplicate"
count := 0
for _, scheme := range schemes {
if scheme == "duplicate" {
count++
}
}
// Should only appear once
require.Equal(t, 1, count, "scheme 'duplicate' should appear exactly once")
}
+3 -3
View File
@@ -111,12 +111,12 @@ type conn struct {
func (c *conn) appendDOT(dot []byte, group string) []byte { func (c *conn) appendDOT(dot []byte, group string) []byte {
host := c.host() host := c.host()
dot = fmt.Appendf(dot, "%s [group=host];\n", host) dot = fmt.Appendf(dot, "%q [group=host];\n", host)
dot = fmt.Appendf(dot, "%d [group=%s, label=%q, title=%q];\n", c.ID, group, c.FormatName, c.label()) dot = fmt.Appendf(dot, "%d [group=%s, label=%q, title=%q];\n", c.ID, group, c.FormatName, c.label())
if group == "producer" { if group == "producer" {
dot = fmt.Appendf(dot, "%s -> %d [label=%q];\n", host, c.ID, humanBytes(c.BytesRecv)) dot = fmt.Appendf(dot, "%q -> %d [label=%q];\n", host, c.ID, humanBytes(c.BytesRecv))
} else { } else {
dot = fmt.Appendf(dot, "%d -> %s [label=%q];\n", c.ID, host, humanBytes(c.BytesSend)) dot = fmt.Appendf(dot, "%d -> %q [label=%q];\n", c.ID, host, humanBytes(c.BytesSend))
} }
for _, recv := range c.Receivers { for _, recv := range c.Receivers {
+37
View File
@@ -2,6 +2,7 @@ package streams
import ( import (
"errors" "errors"
"regexp"
"strings" "strings"
"github.com/AlexxIT/go2rtc/pkg/core" "github.com/AlexxIT/go2rtc/pkg/core"
@@ -15,6 +16,21 @@ func HandleFunc(scheme string, handler Handler) {
handlers[scheme] = handler handlers[scheme] = handler
} }
func SupportedSchemes() []string {
uniqueKeys := make(map[string]struct{}, len(handlers)+len(redirects))
for scheme := range handlers {
uniqueKeys[scheme] = struct{}{}
}
for scheme := range redirects {
uniqueKeys[scheme] = struct{}{}
}
resultKeys := make([]string, 0, len(uniqueKeys))
for key := range uniqueKeys {
resultKeys = append(resultKeys, key)
}
return resultKeys
}
func HasProducer(url string) bool { func HasProducer(url string) bool {
if i := strings.IndexByte(url, ':'); i > 0 { if i := strings.IndexByte(url, ':'); i > 0 {
scheme := url[:i] scheme := url[:i]
@@ -95,3 +111,24 @@ func GetConsumer(url string) (core.Consumer, func(), error) {
return nil, nil, errors.New("streams: unsupported scheme: " + url) return nil, nil, errors.New("streams: unsupported scheme: " + url)
} }
var insecure = map[string]bool{}
func MarkInsecure(scheme string) {
insecure[scheme] = true
}
var sanitize = regexp.MustCompile(`\s`)
func Validate(source string) error {
// TODO: Review the entire logic of insecure sources
if i := strings.IndexByte(source, ':'); i > 0 {
if insecure[source[:i]] {
return errors.New("streams: source from insecure producer")
}
}
if sanitize.MatchString(source) {
return errors.New("streams: source with spaces may be insecure")
}
return nil
}
+28 -17
View File
@@ -1,23 +1,24 @@
package streams package streams
import ( import (
"errors" "fmt"
"maps"
"net/url" "net/url"
"sync" "sync"
"github.com/AlexxIT/go2rtc/pkg/probe" "github.com/AlexxIT/go2rtc/pkg/probe"
) )
var preloads = map[*Stream]*probe.Probe{} type Preload struct {
var preloadsMu sync.Mutex stream *Stream // Don't include the stream in JSON to avoid leaking secrets.
Cons *probe.Probe `json:"consumer"`
func Preload(stream *Stream, rawQuery string) { Query string `json:"query"`
if err := AddPreload(stream, rawQuery); err != nil {
log.Error().Err(err).Caller().Send()
}
} }
func AddPreload(stream *Stream, rawQuery string) error { var preloads = map[string]*Preload{}
var preloadsMu sync.Mutex
func AddPreload(name, rawQuery string) error {
if rawQuery == "" { if rawQuery == "" {
rawQuery = "video&audio" rawQuery = "video&audio"
} }
@@ -30,29 +31,39 @@ func AddPreload(stream *Stream, rawQuery string) error {
preloadsMu.Lock() preloadsMu.Lock()
defer preloadsMu.Unlock() defer preloadsMu.Unlock()
if cons := preloads[stream]; cons != nil { if p := preloads[name]; p != nil {
stream.RemoveConsumer(cons) p.stream.RemoveConsumer(p.Cons)
} }
stream := Get(name)
if stream == nil {
return fmt.Errorf("streams: stream not found: %s", name)
}
cons := probe.Create("preload", query) cons := probe.Create("preload", query)
if err = stream.AddConsumer(cons); err != nil { if err = stream.AddConsumer(cons); err != nil {
return err return err
} }
preloads[stream] = cons preloads[name] = &Preload{stream: stream, Cons: cons, Query: rawQuery}
return nil return nil
} }
func DelPreload(stream *Stream) error { func DelPreload(name string) error {
preloadsMu.Lock() preloadsMu.Lock()
defer preloadsMu.Unlock() defer preloadsMu.Unlock()
if cons := preloads[stream]; cons != nil { if p := preloads[name]; p != nil {
stream.RemoveConsumer(cons) p.stream.RemoveConsumer(p.Cons)
delete(preloads, stream) delete(preloads, name)
return nil return nil
} }
return errors.New("streams: preload not found") return fmt.Errorf("streams: preload not found: %s", name)
}
func GetPreloads() map[string]*Preload {
preloadsMu.Lock()
defer preloadsMu.Unlock()
return maps.Clone(preloads)
} }
+9 -5
View File
@@ -10,13 +10,15 @@ import (
func TestRecursion(t *testing.T) { func TestRecursion(t *testing.T) {
// create stream with some source // create stream with some source
stream1 := New("from_yaml", "does_not_matter") stream1, err := New("from_yaml", "does_not_matter")
require.NoError(t, err)
require.Len(t, streams, 1) require.Len(t, streams, 1)
// ask another unnamed stream that links go2rtc // ask another unnamed stream that links go2rtc
query, err := url.ParseQuery("src=rtsp://localhost:8554/from_yaml?video") query, err := url.ParseQuery("src=rtsp://localhost:8554/from_yaml?video")
require.Nil(t, err) require.NoError(t, err)
stream2 := GetOrPatch(query) stream2, err := GetOrPatch(query)
require.NoError(t, err)
// check stream is same // check stream is same
require.Equal(t, stream1, stream2) require.Equal(t, stream1, stream2)
@@ -29,9 +31,11 @@ func TestTempate(t *testing.T) {
HandleFunc("rtsp", func(url string) (core.Producer, error) { return nil, nil }) // bypass HasProducer HandleFunc("rtsp", func(url string) (core.Producer, error) { return nil, nil }) // bypass HasProducer
// config from yaml // config from yaml
stream1 := New("camera.from_hass", "ffmpeg:{input}#video=copy") stream1, err := New("camera.from_hass", "ffmpeg:{input}#video=copy")
require.NoError(t, err)
// request from hass // request from hass
stream2 := Patch("camera.from_hass", "rtsp://example.com") stream2, err := Patch("camera.from_hass", "rtsp://example.com")
require.NoError(t, err)
require.Equal(t, stream1, stream2) require.Equal(t, stream1, stream2)
require.Equal(t, "ffmpeg:rtsp://example.com#video=copy", stream1.producers[0].url) require.Equal(t, "ffmpeg:rtsp://example.com#video=copy", stream1.producers[0].url)
+22 -30
View File
@@ -3,7 +3,6 @@ package streams
import ( import (
"errors" "errors"
"net/url" "net/url"
"regexp"
"sync" "sync"
"time" "time"
@@ -30,6 +29,7 @@ func Init() {
api.HandleFunc("api/streams", apiStreams) api.HandleFunc("api/streams", apiStreams)
api.HandleFunc("api/streams.dot", apiStreamsDOT) api.HandleFunc("api/streams.dot", apiStreamsDOT)
api.HandleFunc("api/preload", apiPreload) api.HandleFunc("api/preload", apiPreload)
api.HandleFunc("api/schemes", apiSchemes)
if cfg.Publish == nil && cfg.Preload == nil { if cfg.Publish == nil && cfg.Preload == nil {
return return
@@ -43,27 +43,21 @@ func Init() {
} }
} }
for name, rawQuery := range cfg.Preload { for name, rawQuery := range cfg.Preload {
if stream := Get(name); stream != nil { if err := AddPreload(name, rawQuery); err != nil {
Preload(stream, rawQuery) log.Error().Err(err).Caller().Send()
} }
} }
}) })
} }
var sanitize = regexp.MustCompile(`\s`) func New(name string, sources ...string) (*Stream, error) {
// Validate - not allow creating dynamic streams with spaces in the source
func Validate(source string) error {
if sanitize.MatchString(source) {
return errors.New("streams: invalid dynamic source")
}
return nil
}
func New(name string, sources ...string) *Stream {
for _, source := range sources { for _, source := range sources {
if Validate(source) != nil { if !HasProducer(source) {
return nil return nil, errors.New("streams: source not supported")
}
if err := Validate(source); err != nil {
return nil, err
} }
} }
@@ -73,10 +67,10 @@ func New(name string, sources ...string) *Stream {
streams[name] = stream streams[name] = stream
streamsMu.Unlock() streamsMu.Unlock()
return stream return stream, nil
} }
func Patch(name string, source string) *Stream { func Patch(name string, source string) (*Stream, error) {
streamsMu.Lock() streamsMu.Lock()
defer streamsMu.Unlock() defer streamsMu.Unlock()
@@ -88,7 +82,7 @@ func Patch(name string, source string) *Stream {
// link (alias) streams[name] to streams[rtspName] // link (alias) streams[name] to streams[rtspName]
streams[name] = stream streams[name] = stream
} }
return stream return stream, nil
} }
} }
@@ -97,46 +91,44 @@ func Patch(name string, source string) *Stream {
// link (alias) streams[name] to streams[source] // link (alias) streams[name] to streams[source]
streams[name] = stream streams[name] = stream
} }
return stream return stream, nil
} }
// check if src has supported scheme // check if src has supported scheme
if !HasProducer(source) { if !HasProducer(source) {
return nil return nil, errors.New("streams: source not supported")
} }
if Validate(source) != nil { if err := Validate(source); err != nil {
return nil return nil, err
} }
// check an existing stream with this name // check an existing stream with this name
if stream, ok := streams[name]; ok { if stream, ok := streams[name]; ok {
stream.SetSource(source) stream.SetSource(source)
return stream return stream, nil
} }
// create new stream with this name // create new stream with this name
stream := NewStream(source) stream := NewStream(source)
streams[name] = stream streams[name] = stream
return stream return stream, nil
} }
func GetOrPatch(query url.Values) *Stream { func GetOrPatch(query url.Values) (*Stream, error) {
// check if src param exists // check if src param exists
source := query.Get("src") source := query.Get("src")
if source == "" { if source == "" {
return nil return nil, errors.New("streams: source empty")
} }
// check if src is stream name // check if src is stream name
if stream := Get(source); stream != nil { if stream := Get(source); stream != nil {
return stream return stream, nil
} }
// check if name param provided // check if name param provided
if name := query.Get("name"); name != "" { if name := query.Get("name"); name != "" {
log.Info().Msgf("[streams] create new stream url=%s", source)
return Patch(name, source) return Patch(name, source)
} }
+61
View File
@@ -0,0 +1,61 @@
# TP-Link Tapo
[`new in v1.2.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.2.0)
[TP-Link Tapo](https://www.tapo.com/) proprietary camera protocol with **two-way audio** support.
- stream quality is the same as [RTSP protocol](https://www.tapo.com/en/faq/34/)
- use the **cloud password**, this is not the RTSP password! you do not need to add a login!
- you can also use **UPPERCASE** MD5 hash from your cloud password with `admin` username
- some new camera firmwares require SHA256 instead of MD5
## Configuration
```yaml
streams:
# cloud password without username
camera1: tapo://cloud-password@192.168.1.123
# admin username and UPPERCASE MD5 cloud-password hash
camera2: tapo://admin:UPPERCASE-MD5@192.168.1.123
# admin username and UPPERCASE SHA256 cloud-password hash
camera3: tapo://admin:UPPERCASE-SHA256@192.168.1.123
# VGA stream (the so called substream, the lower resolution one)
camera4: tapo://cloud-password@192.168.1.123?subtype=1
# HD stream (default)
camera5: tapo://cloud-password@192.168.1.123?subtype=0
```
```bash
echo -n "cloud password" | md5 | awk '{print toupper($0)}'
echo -n "cloud password" | shasum -a 256 | awk '{print toupper($0)}'
```
## TP-Link Kasa
[`new in v1.7.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.7.0)
> [!NOTE]
> This source should be moved to separate module. Because it's source code not related to Tapo.
[TP-Link Kasa](https://www.kasasmart.com/) non-standard protocol [more info](https://medium.com/@hu3vjeen/reverse-engineering-tp-link-kc100-bac4641bf1cd).
- `username` - urlsafe email, `alex@gmail.com` -> `alex%40gmail.com`
- `password` - base64password, `secret1` -> `c2VjcmV0MQ==`
```yaml
streams:
kc401: kasa://username:password@192.168.1.123:19443/https/stream/mixed
```
Tested: KD110, KC200, KC401, KC420WS, EC71.
## TP-Link Vigi
[`new in v1.9.8`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.8)
[TP-Link VIGI](https://www.vigi.com/) cameras. These are cameras from a different sub-brand, but the format is very similar to Tapo. Only the authorization is different. Read more [here](https://github.com/AlexxIT/go2rtc/issues/1470).
```yaml
streams:
camera1: vigi://admin:{password}@192.168.1.123
```
+39
View File
@@ -0,0 +1,39 @@
# Tuya
[`new in v1.9.13`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.13) by [@seydx](https://github.com/seydx)
[Tuya](https://www.tuya.com/) is a proprietary camera protocol with **two-way audio** support. go2rtc supports `Tuya Smart API` and `Tuya Cloud API`.
**Tuya Smart API (recommended)**:
- **Smart Life accounts are NOT supported**, you need to create a Tuya Smart account. If the cameras are already added to the Smart Life app, you need to remove them and add them again to the [Tuya Smart](https://play.google.com/store/apps/details?id=com.tuya.smart) app.
- Cameras can be discovered through the go2rtc web interface via Tuya Smart account (Add > Tuya > Select region and fill in email and password > Login).
**Tuya Cloud API**:
- Requires setting up a cloud project in the Tuya Developer Platform.
- Obtain `device_id`, `client_id`, `client_secret`, and `uid` from [Tuya IoT Platform](https://iot.tuya.com/). [Here's a guide](https://xzetsubou.github.io/hass-localtuya/cloud_api/).
- Please ensure that you have subscribed to the `IoT Video Live Stream` service (Free Trial) in the Tuya Developer Platform, otherwise the stream will not work (Tuya Developer Platform > Service API > Authorize > IoT Video Live Stream).
## Configuration
Use the `resolution` parameter to select the stream (not all cameras support an `hd` stream through WebRTC even if the camera supports it):
- `hd` - HD stream (default)
- `sd` - SD stream
```yaml
streams:
# Tuya Smart API: WebRTC main stream (use Add > Tuya to discover the URL)
tuya_main:
- tuya://protect-us.ismartlife.me?device_id=XXX&email=XXX&password=XXX
# Tuya Smart API: WebRTC sub stream (use Add > Tuya to discover the URL)
tuya_sub:
- tuya://protect-us.ismartlife.me?device_id=XXX&email=XXX&password=XXX&resolution=sd
# Tuya Cloud API: WebRTC main stream
tuya_webrtc:
- tuya://openapi.tuyaus.com?device_id=XXX&uid=XXX&client_id=XXX&client_secret=XXX
# Tuya Cloud API: WebRTC sub stream
tuya_webrtc_sd:
- tuya://openapi.tuyaus.com?device_id=XXX&uid=XXX&client_id=XXX&client_secret=XXX&resolution=sd
```
+248
View File
@@ -0,0 +1,248 @@
package tuya
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/streams"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tuya"
)
func Init() {
streams.HandleFunc("tuya", func(source string) (core.Producer, error) {
return tuya.Dial(source)
})
api.HandleFunc("api/tuya", apiTuya)
}
func apiTuya(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
region := query.Get("region")
email := query.Get("email")
password := query.Get("password")
if email == "" || password == "" || region == "" {
http.Error(w, "email, password and region are required", http.StatusBadRequest)
return
}
var tuyaRegion *tuya.Region
for _, r := range tuya.AvailableRegions {
if r.Host == region {
tuyaRegion = &r
break
}
}
if tuyaRegion == nil {
http.Error(w, fmt.Sprintf("invalid region: %s", region), http.StatusBadRequest)
return
}
httpClient := tuya.CreateHTTPClientWithSession()
_, err := login(httpClient, tuyaRegion.Host, email, password, tuyaRegion.Continent)
if err != nil {
http.Error(w, fmt.Sprintf("login failed: %v", err), http.StatusInternalServerError)
return
}
tuyaAPI, err := tuya.NewTuyaSmartApiClient(
httpClient,
tuyaRegion.Host,
email,
password,
"",
)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
var devices []tuya.Device
homes, _ := tuyaAPI.GetHomeList()
if homes != nil && len(homes.Result) > 0 {
for _, home := range homes.Result {
roomList, err := tuyaAPI.GetRoomList(strconv.Itoa(home.Gid))
if err != nil {
continue
}
for _, room := range roomList.Result {
for _, device := range room.DeviceList {
if (device.Category == "sp" || device.Category == "dghsxj") && !containsDevice(devices, device.DeviceId) {
devices = append(devices, device)
}
}
}
}
}
sharedHomes, _ := tuyaAPI.GetSharedHomeList()
if sharedHomes != nil && len(sharedHomes.Result.SecurityWebCShareInfoList) > 0 {
for _, sharedHome := range sharedHomes.Result.SecurityWebCShareInfoList {
for _, device := range sharedHome.DeviceInfoList {
if (device.Category == "sp" || device.Category == "dghsxj") && !containsDevice(devices, device.DeviceId) {
devices = append(devices, device)
}
}
}
}
if len(devices) == 0 {
http.Error(w, "no cameras found", http.StatusNotFound)
return
}
var items []*api.Source
for _, device := range devices {
cleanQuery := url.Values{}
cleanQuery.Set("device_id", device.DeviceId)
cleanQuery.Set("email", email)
cleanQuery.Set("password", password)
url := fmt.Sprintf("tuya://%s?%s", tuyaRegion.Host, cleanQuery.Encode())
items = append(items, &api.Source{
Name: device.DeviceName,
URL: url,
})
}
api.ResponseSources(w, items)
}
func login(client *http.Client, serverHost, email, password, countryCode string) (*tuya.LoginResult, error) {
tokenResp, err := getLoginToken(client, serverHost, email, countryCode)
if err != nil {
return nil, err
}
encryptedPassword, err := tuya.EncryptPassword(password, tokenResp.Result.PbKey)
if err != nil {
return nil, fmt.Errorf("failed to encrypt password: %v", err)
}
var loginResp *tuya.PasswordLoginResponse
var url string
loginReq := tuya.PasswordLoginRequest{
CountryCode: countryCode,
Passwd: encryptedPassword,
Token: tokenResp.Result.Token,
IfEncrypt: 1,
Options: `{"group":1}`,
}
if tuya.IsEmailAddress(email) {
url = fmt.Sprintf("https://%s/api/private/email/login", serverHost)
loginReq.Email = email
} else {
url = fmt.Sprintf("https://%s/api/private/phone/login", serverHost)
loginReq.Mobile = email
}
loginResp, err = performLogin(client, url, loginReq, serverHost)
if err != nil {
return nil, err
}
if !loginResp.Success {
return nil, errors.New(loginResp.ErrorMsg)
}
return &loginResp.Result, nil
}
func getLoginToken(client *http.Client, serverHost, username, countryCode string) (*tuya.LoginTokenResponse, error) {
url := fmt.Sprintf("https://%s/api/login/token", serverHost)
tokenReq := tuya.LoginTokenRequest{
CountryCode: countryCode,
Username: username,
IsUid: false,
}
jsonData, err := json.Marshal(tokenReq)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")
req.Header.Set("Accept", "*/*")
req.Header.Set("Origin", fmt.Sprintf("https://%s", serverHost))
req.Header.Set("Referer", fmt.Sprintf("https://%s/login", serverHost))
req.Header.Set("X-Requested-With", "XMLHttpRequest")
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var tokenResp tuya.LoginTokenResponse
if err = json.NewDecoder(resp.Body).Decode(&tokenResp); err != nil {
return nil, err
}
if !tokenResp.Success {
return nil, errors.New("tuya: " + tokenResp.Msg)
}
return &tokenResp, nil
}
func performLogin(client *http.Client, url string, loginReq tuya.PasswordLoginRequest, serverHost string) (*tuya.PasswordLoginResponse, error) {
jsonData, err := json.Marshal(loginReq)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json; charset=utf-8")
req.Header.Set("Accept", "*/*")
req.Header.Set("Origin", fmt.Sprintf("https://%s", serverHost))
req.Header.Set("Referer", fmt.Sprintf("https://%s/login", serverHost))
req.Header.Set("X-Requested-With", "XMLHttpRequest")
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var loginResp tuya.PasswordLoginResponse
if err := json.NewDecoder(resp.Body).Decode(&loginResp); err != nil {
return nil, err
}
return &loginResp, nil
}
func containsDevice(devices []tuya.Device, deviceID string) bool {
for _, device := range devices {
if device.DeviceId == deviceID {
return true
}
}
return false
}
+3 -1
View File
@@ -1,4 +1,6 @@
# V4L2 # Video4Linux
[`new in v1.9.9`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.9)
What you should to know about [V4L2](https://en.wikipedia.org/wiki/Video4Linux): What you should to know about [V4L2](https://en.wikipedia.org/wiki/Video4Linux):
+182 -35
View File
@@ -1,32 +1,157 @@
What you should to know about WebRTC: # WebRTC
- It's almost always a **direct [peer-to-peer](https://en.wikipedia.org/wiki/Peer-to-peer) connection** from your browser to go2rtc app ## WebRTC Client
- When you use Home Assistant, Frigate, Nginx, Nabu Casa, Cloudflare and other software - they are only **involved in establishing** the connection, but they are **not involved in transferring** media data
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
This source type supports four connection formats.
### Creality
[`new in v1.9.10`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.10)
[Creality](https://www.creality.com/) 3D printer camera. Read more [here](https://github.com/AlexxIT/go2rtc/issues/1600).
```yaml
streams:
creality_k2p: webrtc:http://192.168.1.123:8000/call/webrtc_local#format=creality
```
### go2rtc
This format is only supported in go2rtc. Unlike WHEP, it supports asynchronous WebRTC connections and two-way audio.
```yaml
streams:
webrtc-go2rtc: webrtc:ws://192.168.1.123:1984/api/ws?src=camera1
```
### Kinesis
[`new in v1.6.1`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.6.1)
Supports [Amazon Kinesis Video Streams](https://aws.amazon.com/kinesis/video-streams/), using WebRTC protocol. You need to specify the signaling WebSocket URL with all credentials in query params, `client_id` and `ice_servers` list in [JSON format](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer).
```yaml
streams:
webrtc-kinesis: webrtc:wss://...amazonaws.com/?...#format=kinesis#client_id=...#ice_servers=[{...},{...}]
```
**PS.** For `kinesis` sources, you can use [echo](../echo/README.md) to get connection params using `bash`, `python` or any other script language.
### OpenIPC
[`new in v1.7.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.7.0)
Cameras on open-source [OpenIPC](https://openipc.org/) firmware.
```yaml
streams:
webrtc-openipc: webrtc:ws://192.168.1.123/webrtc_ws#format=openipc#ice_servers=[{"urls":"stun:stun.kinesisvideo.eu-north-1.amazonaws.com:443"}]
```
### SwitchBot
Support connection to [SwitchBot](https://us.switch-bot.com/) cameras that are based on Kinesis Video Streams. Specifically, this includes [Pan/Tilt Cam Plus 2K](https://us.switch-bot.com/pages/switchbot-pan-tilt-cam-plus-2k) and [Pan/Tilt Cam Plus 3K](https://us.switch-bot.com/pages/switchbot-pan-tilt-cam-plus-3k) and [Smart Video Doorbell](https://www.switchbot.jp/products/switchbot-smart-video-doorbell). `Outdoor Spotlight Cam 1080P`, `Outdoor Spotlight Cam 2K`, `Pan/Tilt Cam`, `Pan/Tilt Cam 2K`, `Indoor Cam` are based on Tuya, so this feature is not available.
```yaml
streams:
webrtc-switchbot: webrtc:wss://...amazonaws.com/?...#format=switchbot#resolution=hd#play_type=0#client_id=...#ice_servers=[{...},{...}]
```
### WHEP
[WebRTC/WHEP](https://datatracker.ietf.org/doc/draft-murillo-whep/) is replaced by [WebRTC/WISH](https://datatracker.ietf.org/doc/charter-ietf-wish/02/) standard for WebRTC video/audio viewers. But it may already be supported in some third-party software. It is supported in go2rtc.
```yaml
streams:
webrtc-whep: webrtc:http://192.168.1.123:1984/api/webrtc?src=camera1
```
### Wyze
[`new in v1.6.1`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.6.1)
Legacy method to connect to [Wyze](https://www.wyze.com/) cameras using WebRTC protocol via [docker-wyze-bridge](https://github.com/mrlt8/docker-wyze-bridge). For native P2P support without docker-wyze-bridge, see [Source: Wyze](../wyze/README.md).
```yaml
streams:
webrtc-wyze: webrtc:http://192.168.1.123:5000/signaling/camera1?kvs#format=wyze
```
## WebRTC Server
What you should know about WebRTC:
- It's almost always a **direct [peer-to-peer](https://en.wikipedia.org/wiki/Peer-to-peer) connection** from your browser to the go2rtc app
- When you use Home Assistant, Frigate, Nginx, Nabu Casa, Cloudflare, and other software, they are only **involved in establishing** the connection; they are **not involved in transferring** media data
- WebRTC media cannot be transferred inside an HTTP connection - WebRTC media cannot be transferred inside an HTTP connection
- Usually, WebRTC uses random UDP ports on client and server side to establish a connection - Usually, WebRTC uses random UDP ports on the client and server to establish a connection
- Usually, WebRTC uses public [STUN](https://en.wikipedia.org/wiki/STUN) servers to establish a connection outside LAN, such servers are only needed to establish a connection and are not involved in data transfer - Usually, WebRTC uses public [STUN](https://en.wikipedia.org/wiki/STUN) servers to establish a connection outside the LAN; these servers are only needed to establish a connection and are not involved in data transfer
- Usually, WebRTC will automatically discover all of your local addresses and all of your public addresses and try to establish a connection - Usually, WebRTC will automatically discover all of your local and public addresses and try to establish a connection
If an external connection via STUN is used: If an external connection via STUN is used:
- Uses [UDP hole punching](https://en.wikipedia.org/wiki/UDP_hole_punching) technology to bypass NAT even if you not open your server to the World - Uses [UDP hole punching](https://en.wikipedia.org/wiki/UDP_hole_punching) technology to bypass NAT even if you haven't opened your server to the world
- For about 20% of users, the techology will not work because of the [Symmetric NAT](https://tomchen.github.io/symmetric-nat-test/) - For about 20% of users, the technology will not work because of the [Symmetric NAT](https://tomchen.github.io/symmetric-nat-test/)
- UDP is not suitable for transmitting 2K and 4K high bitrate video over open networks because of the high loss rate: - UDP is not suitable for transmitting 2K and 4K high bit rate video over open networks because of the high loss rate:
- https://habr.com/ru/companies/flashphoner/articles/480006/ - https://habr.com/ru/companies/flashphoner/articles/480006/
- https://www.youtube.com/watch?v=FXVg2ckuKfs - https://www.youtube.com/watch?v=FXVg2ckuKfs
## Default config ### Configuration suggestions
- by default, WebRTC uses both TCP and UDP on port 8555 for connections
- you can use this port for external access
- you can change the port in YAML config:
```yaml ```yaml
webrtc: webrtc:
listen: ":8555" listen: ":8555" # address of your local server and port (TCP/UDP)
ice_servers:
- urls: [ "stun:stun.l.google.com:19302" ]
``` ```
## Config #### Static public IP
**Important!** This example is not for copypasting! - forward the port 8555 on your router (you can use the same 8555 port or any other as external port)
- add your external IP address and external port to the YAML config
```yaml
webrtc:
candidates:
- 216.58.210.174:8555 # if you have a static public IP address
```
#### Dynamic public IP
- forward the port 8555 on your router (you can use the same 8555 port or any other as the external port)
- add `stun` word and external port to YAML config
- go2rtc automatically detects your external address with STUN server
```yaml
webrtc:
candidates:
- stun:8555 # if you have a dynamic public IP address
```
#### Hard tech way 1. Own TCP-tunnel
If you have a personal [VPS](https://en.wikipedia.org/wiki/Virtual_private_server), you can create a TCP tunnel and setup in the same way as "Static public IP". But use your VPS IP address in the YAML config.
#### Hard tech way 2. Using TURN-server
If you have personal [VPS](https://en.wikipedia.org/wiki/Virtual_private_server), you can install TURN server (e.g. [coturn](https://github.com/coturn/coturn), config [example](https://github.com/AlexxIT/WebRTC/wiki/Coturn-Example)).
```yaml
webrtc:
ice_servers:
- urls: [stun:stun.l.google.com:19302]
- urls: [turn:123.123.123.123:3478]
username: your_user
credential: your_pass
```
### Full configuration
**Important!** This example is not for copy/pasting!
```yaml ```yaml
webrtc: webrtc:
@@ -41,34 +166,34 @@ webrtc:
- home.duckdns.org:8555 # if you have domain - home.duckdns.org:8555 # if you have domain
# add custom STUN and TURN servers # add custom STUN and TURN servers
# use `ice_servers: []` for remove defaults and leave empty # use `ice_servers: []` to remove defaults and leave it empty
ice_servers: ice_servers:
- urls: [ stun:stun1.l.google.com:19302 ] - urls: [ stun:stun1.l.google.com:19302 ]
- urls: [ turn:123.123.123.123:3478 ] - urls: [ turn:123.123.123.123:3478 ]
username: your_user username: your_user
credential: your_pass credential: your_pass
# optional filter list for auto discovery logic # optional filter list for auto-discovery logic
# some settings only make sense if you don't specify a fixed UDP port # some settings only make sense if you don't specify a fixed UDP port
filters: filters:
# list of host candidates from auto discovery to be sent # list of host candidates from auto-discovery to be sent
# including candidates from the `listen` option # includes candidates from the `listen` option
# use `candidates: []` to remove all auto discovery candidates # use `candidates: []` to remove all auto-discovery candidates
candidates: [ 192.168.1.123 ] candidates: [ 192.168.1.123 ]
# enable localhost candidates # enable localhost candidates
loopback: true loopback: true
# list of network types to be used for connection # list of network types to be used for the connection
# including candidates from the `listen` option # includes candidates from the `listen` option
networks: [ udp4, udp6, tcp4, tcp6 ] networks: [ udp4, udp6, tcp4, tcp6 ]
# list of interfaces to be used for connection # list of interfaces to be used for the connection
# including interfaces from unspecified `listen` option (empty host) # includes interfaces from unspecified `listen` option (empty host)
interfaces: [ eno1 ] interfaces: [ eno1 ]
# list of host IP-addresses to be used for connection # list of host IP addresses to be used for the connection
# including IPs from unspecified `listen` option (empty host) # includes IPs from unspecified `listen` option (empty host)
ips: [ 192.168.1.123 ] ips: [ 192.168.1.123 ]
# range for random UDP ports [min, max] to be used for connection # range for random UDP ports [min, max] to be used for connection
@@ -76,15 +201,15 @@ webrtc:
udp_ports: [ 50000, 50100 ] udp_ports: [ 50000, 50100 ]
``` ```
By default go2rtc uses **fixed TCP** port and **fixed UDP** ports for each **direct** WebRTC connection - `listen: ":8555"`. By default, go2rtc uses a **fixed TCP** port and **fixed UDP** ports for each **direct** WebRTC connection: `listen: ":8555"`.
You can set **fixed TCP** and **random UDP** port for all connections - `listen: ":8555/tcp"`. You can set a **fixed TCP** port and a **random UDP** port for all connections: `listen: ":8555/tcp"`.
Don't know why, but you can disable TCP port and leave only random UDP ports - `listen: ""`. You can also disable the TCP port and leave only random UDP ports: `listen: ""`.
## Config filters ### Configuration filters
**Importan!** By default go2rtc exclude all Docker-like candidates (`172.16.0.0/12`). This can not be disabled. **Important!** By default, go2rtc excludes all Docker-like candidates (`172.16.0.0/12`). This cannot be disabled.
Filters allow you to exclude unnecessary candidates. Extra candidates don't make your connection worse or better. But the wrong filter settings can break everything. Skip this setting if you don't understand it. Filters allow you to exclude unnecessary candidates. Extra candidates don't make your connection worse or better. But the wrong filter settings can break everything. Skip this setting if you don't understand it.
@@ -98,7 +223,7 @@ webrtc:
networks: [ udp4, tcp4 ] # skip IPv6, if it's not supported for you networks: [ udp4, tcp4 ] # skip IPv6, if it's not supported for you
``` ```
For example, go2rtc inside closed docker container (ex. [Frigate](https://frigate.video/)). You shouldn't filter docker interfaces, otherwise go2rtc will not be able to connect anywhere. But you can filter the docker candidates because no one can connect to them. For example, go2rtc is inside a closed Docker container (e.g. [Frigate](https://frigate.video/)). You shouldn't filter Docker interfaces; otherwise, go2rtc won't be able to connect anywhere. But you can filter the Docker candidates because no one can connect to them.
```yaml ```yaml
webrtc: webrtc:
@@ -106,7 +231,29 @@ webrtc:
candidates: [ 192.168.1.2:8555 ] # add manual host candidate (use docker port forwarding) candidates: [ 192.168.1.2:8555 ] # add manual host candidate (use docker port forwarding)
``` ```
## Userful links ## Streaming ingest
### Ingest: Browser
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
You can turn the browser of any PC or mobile into an IP camera with support for video and two-way audio. Or even broadcast your PC screen:
1. Create empty stream in the `go2rtc.yaml`
2. Go to go2rtc WebUI
3. Open `links` page for your stream
4. Select `camera+microphone` or `display+speaker` option
5. Open `webrtc` local page (your go2rtc **should work over HTTPS!**) or `share link` via [WebTorrent](../webtorrent/README.md) technology (work over HTTPS by default)
### Ingest: WHIP
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
You can use **OBS Studio** or any other broadcast software with [WHIP](https://www.ietf.org/archive/id/draft-ietf-wish-whip-01.html) protocol support. This standard has not yet been approved. But you can download OBS Studio [dev version](https://github.com/obsproject/obs-studio/actions/runs/3969201209):
- Settings > Stream > Service: WHIP > `http://192.168.1.123:1984/api/webrtc?dst=camera1`
## Useful links
- https://www.ietf.org/archive/id/draft-ietf-wish-whip-01.html - https://www.ietf.org/archive/id/draft-ietf-wish-whip-01.html
- https://www.ietf.org/id/draft-murillo-whep-01.html - https://www.ietf.org/id/draft-murillo-whep-01.html
+3 -1
View File
@@ -18,9 +18,11 @@ type Address struct {
Priority uint32 Priority uint32
} }
var stuns []string
func (a *Address) Host() string { func (a *Address) Host() string {
if a.host == "stun" { if a.host == "stun" {
ip, err := webrtc.GetCachedPublicIP() ip, err := webrtc.GetCachedPublicIP(stuns...)
if err != nil { if err != nil {
return "" return ""
} }
+30 -5
View File
@@ -2,6 +2,7 @@ package webrtc
import ( import (
"errors" "errors"
"net"
"strings" "strings"
"github.com/AlexxIT/go2rtc/internal/api" "github.com/AlexxIT/go2rtc/internal/api"
@@ -26,24 +27,49 @@ func Init() {
cfg.Mod.Listen = ":8555" cfg.Mod.Listen = ":8555"
cfg.Mod.IceServers = []pion.ICEServer{ cfg.Mod.IceServers = []pion.ICEServer{
{URLs: []string{"stun:stun.l.google.com:19302"}}, {URLs: []string{"stun:stun.cloudflare.com:3478", "stun:stun.l.google.com:19302"}},
} }
app.LoadConfig(&cfg) app.LoadConfig(&cfg)
log = app.GetLogger("webrtc") log = app.GetLogger("webrtc")
filters = cfg.Mod.Filters if log.Debug().Enabled() {
itfs, _ := net.Interfaces()
for _, itf := range itfs {
addrs, _ := itf.Addrs()
log.Debug().Msgf("[webrtc] interface %+v addrs %v", itf, addrs)
}
}
address, network, _ := strings.Cut(cfg.Mod.Listen, "/") address, network, _ := strings.Cut(cfg.Mod.Listen, "/")
for _, candidate := range cfg.Mod.Candidates { for _, candidate := range cfg.Mod.Candidates {
AddCandidate(network, candidate) AddCandidate(network, candidate)
if strings.HasPrefix(candidate, "stun:") && stuns == nil {
for _, ice := range cfg.Mod.IceServers {
for _, url := range ice.URLs {
if strings.HasPrefix(url, "stun:") {
stuns = append(stuns, url[5:])
}
}
}
}
}
webrtc.OnNewListener = func(ln any) {
switch ln := ln.(type) {
case *net.TCPListener:
log.Info().Stringer("addr", ln.Addr()).Msg("[webrtc] listen tcp")
case *net.UDPConn:
log.Info().Stringer("addr", ln.LocalAddr()).Msg("[webrtc] listen udp")
}
} }
var err error var err error
// create pionAPI with custom codecs list and custom network settings // create pionAPI with custom codecs list and custom network settings
serverAPI, err = webrtc.NewServerAPI(network, address, &filters) serverAPI, err = webrtc.NewServerAPI(network, address, &cfg.Mod.Filters)
if err != nil { if err != nil {
log.Error().Err(err).Caller().Send() log.Error().Err(err).Caller().Send()
return return
@@ -53,7 +79,6 @@ func Init() {
clientAPI = serverAPI clientAPI = serverAPI
if address != "" { if address != "" {
log.Info().Str("addr", cfg.Mod.Listen).Msg("[webrtc] listen")
clientAPI, _ = webrtc.NewAPI() clientAPI, _ = webrtc.NewAPI()
} }
@@ -95,7 +120,7 @@ func asyncHandler(tr *ws.Transport, msg *ws.Message) (err error) {
query := tr.Request.URL.Query() query := tr.Request.URL.Query()
if name := query.Get("src"); name != "" { if name := query.Get("src"); name != "" {
stream = streams.GetOrPatch(query) stream, _ = streams.GetOrPatch(query)
mode = core.ModePassiveConsumer mode = core.ModePassiveConsumer
log.Debug().Str("src", name).Msg("[webrtc] new consumer") log.Debug().Str("src", name).Msg("[webrtc] new consumer")
} else if name = query.Get("dst"); name != "" { } else if name = query.Get("dst"); name != "" {
+45
View File
@@ -0,0 +1,45 @@
# WebTorrent
> [!NOTE]
> This section needs some improvement.
## WebTorrent Client
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
This source can get a stream from another go2rtc via [WebTorrent](https://en.wikipedia.org/wiki/WebTorrent) protocol.
### Client Configuration
```yaml
streams:
webtorrent1: webtorrent:?share=huofssuxaty00izc&pwd=k3l2j9djeg8v8r7e
```
## WebTorrent Server
[`new in v1.3.0`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.3.0)
This module supports:
- Share any local stream via [WebTorrent](https://webtorrent.io/) technology
- Get any [incoming stream](../webrtc/README.md#ingest-browser) from PC or mobile via [WebTorrent](https://webtorrent.io/) technology
- Get any remote go2rtc source via [WebTorrent](https://webtorrent.io/) technology
Securely and freely. You do not need to open a public access to the go2rtc server. But in some cases (Symmetric NAT), you may need to set up external access to [WebRTC module](../webrtc/README.md).
To generate a sharing link or incoming link, go to the go2rtc WebUI (stream links page). This link is **temporary** and will stop working after go2rtc is restarted!
### Server Configuration
You can create permanent external links in the go2rtc config:
```yaml
webtorrent:
shares:
super-secret-share: # share name, should be unique among all go2rtc users!
pwd: super-secret-password
src: rtsp-dahua1 # stream name from streams section
```
Link example: `https://go2rtc.org/webtorrent/#share=02SNtgjKXY&pwd=wznEQqznxW&media=video+audio`
+8 -5
View File
@@ -1,5 +1,8 @@
# Wyoming # Wyoming
> [!NOTE]
> The format is under development and does not yet work stably.
This module provide [Wyoming Protocol](https://www.home-assistant.io/integrations/wyoming/) support to create local voice assistants using [Home Assistant](https://www.home-assistant.io/). This module provide [Wyoming Protocol](https://www.home-assistant.io/integrations/wyoming/) support to create local voice assistants using [Home Assistant](https://www.home-assistant.io/).
- go2rtc can act as [Wyoming Satellite](https://github.com/rhasspy/wyoming-satellite) - go2rtc can act as [Wyoming Satellite](https://github.com/rhasspy/wyoming-satellite)
@@ -20,13 +23,13 @@ This module provide [Wyoming Protocol](https://www.home-assistant.io/integration
3. Wake Word (WAKE) 3. Wake Word (WAKE)
- [OpenWakeWord](https://www.home-assistant.io/voice_control/create_wake_word/) - [OpenWakeWord](https://www.home-assistant.io/voice_control/create_wake_word/)
4. Speech-to-Text (STT) 4. Speech-to-Text (STT)
- [Whisper](https://github.com/home-assistant/addons/blob/master/whisper/README.md) - [Whisper](https://github.com/home-assistant/addons/blob/master/whisper/)
- [Vosk](https://github.com/rhasspy/hassio-addons/blob/master/vosk/README.md) - [Vosk](https://github.com/rhasspy/hassio-addons/blob/master/vosk/)
5. Conversation agent (INTENT) 5. Conversation agent (INTENT)
- [Home Assistant](https://www.home-assistant.io/integrations/conversation/) - [Home Assistant](https://www.home-assistant.io/integrations/conversation/)
6. Text-to-speech (TTS) 6. Text-to-speech (TTS)
- [Google Translate](https://www.home-assistant.io/integrations/google_translate/) - [Google Translate](https://www.home-assistant.io/integrations/google_translate/)
- [Piper](https://github.com/home-assistant/addons/blob/master/piper/README.md) - [Piper](https://github.com/home-assistant/addons/blob/master/piper/)
7. Audio stream (SND) 7. Audio stream (SND)
- any source with two-way audio (backchannel) and PCM codec support (include PCMA/PCMU) - any source with two-way audio (backchannel) and PCM codec support (include PCMA/PCMU)
@@ -60,7 +63,7 @@ wake_uri: tcp://192.168.1.23:10400?name=alexa_v0.1&name=hey_jarvis_v0.1&name=hey
## Events ## Events
You can add wyoming event handling using the [expr](https://github.com/AlexxIT/go2rtc/blob/master/internal/expr/README.md) language. For example, to pronounce TTS on some media player from HA. You can add wyoming event handling using the [expr](../expr/README.md) language. For example, to pronounce TTS on some media player from HA.
Turn on the logs to see what kind of events happens. Turn on the logs to see what kind of events happens.
@@ -91,7 +94,7 @@ Supported functions and variables:
- `PlayFile(path)` - play audio from `wav` file - `PlayFile(path)` - play audio from `wav` file
- `Type` - type (name) of event - `Type` - type (name) of event
- `Data` - event data in JSON format (ex. `{"text":"how are you"}`) - `Data` - event data in JSON format (ex. `{"text":"how are you"}`)
- also available other functions from [expr](https://github.com/AlexxIT/go2rtc/blob/master/internal/expr/README.md) module (ex. `fetch`) - also available other functions from [expr](../expr/README.md) module (ex. `fetch`)
If you write a script for an event - the default action is no longer executed. You need to repeat the necessary steps yourself. If you write a script for an event - the default action is no longer executed. You need to repeat the necessary steps yourself.
+108
View File
@@ -0,0 +1,108 @@
# Wyze
[`new in v1.9.14`](https://github.com/AlexxIT/go2rtc/releases/tag/v1.9.14) by [@seydx](https://github.com/seydx)
This source allows you to stream from [Wyze](https://wyze.com/) cameras using native P2P protocol without the Wyze app or SDK.
**Important:**
1. **Requires Wyze account**. You need to login once via the WebUI to load your cameras.
2. **Requires firmware with DTLS**. Only cameras with DTLS-enabled firmware are supported.
3. Internet access is only needed when loading cameras from your account. After that, all streaming is local P2P.
4. Connection to the camera is local only (direct P2P to camera IP).
**Features:**
- H.264 and H.265 video codec support
- AAC, G.711, PCM, and Opus audio codec support
- Two-way audio (intercom) support
- Resolution switching (HD/SD)
## Setup
1. Get your API Key from [Wyze Developer Portal](https://support.wyze.com/hc/en-us/articles/16129834216731)
2. Go to go2rtc WebUI > Add > Wyze
3. Enter your API ID, API Key, email, and password
4. Select cameras to add - stream URLs are generated automatically
**Example Config**
```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
```
## Stream URL Format
The stream URL is automatically generated when you add cameras via the WebUI:
```
wyze://[IP]?uid=[P2P_ID]&enr=[ENR]&mac=[MAC]&model=[MODEL]&subtype=[hd|sd]&dtls=true
```
| Parameter | Description |
|-----------|-------------------------------------------------|
| `IP` | Camera's local IP address |
| `uid` | P2P identifier (20 chars) |
| `enr` | Encryption key for DTLS |
| `mac` | Device MAC address |
| `model` | Camera model (e.g., HL_CAM4) |
| `dtls` | Enable DTLS encryption (default: true) |
| `subtype` | Camera resolution: `hd` or `sd` (default: `hd`) |
## Configuration
### Resolution
You can change the camera's resolution using the `subtype` parameter:
```yaml
streams:
wyze_hd: wyze://...&subtype=hd
wyze_sd: wyze://...&subtype=sd
```
### Two-Way Audio
Two-way audio (intercom) is supported automatically. When a consumer sends audio to the stream, it will be transmitted to the camera's speaker.
## Camera Compatibility
| Name | Model | Firmware | Protocol | Encryption | Codecs |
|-----------------------------|----------------|--------------|----------|------------|------------|
| Wyze Cam v4 | HL_CAM4 | 4.52.9.4188 | TUTK | TransCode | h264, aac |
| | | 4.52.9.5332 | TUTK | HMAC-SHA1 | h264, aac |
| Wyze Cam v3 Pro | | | TUTK | | |
| Wyze Cam v3 | WYZE_CAKP2JFUS | 4.36.14.3497 | TUTK | TransCode | h264, pcm |
| Wyze Cam v2 | WYZEC1-JZ | 4.9.9.3006 | TUTK | TransCode | h264, pcmu |
| Wyze Cam v1 | | | TUTK | | |
| Wyze Cam Pan v4 | | | Gwell* | | |
| Wyze Cam Pan v3 | | | TUTK | | |
| Wyze Cam Pan v2 | | | TUTK | | |
| Wyze Cam Pan v1 | | | TUTK | | |
| Wyze Cam OG | | | Gwell* | | |
| Wyze Cam OG Telephoto | | | Gwell* | | |
| Wyze Cam OG (2025) | | | Gwell* | | |
| Wyze Cam Outdoor v2 | | | TUTK | | |
| Wyze Cam Outdoor v1 | | | TUTK | | |
| Wyze Cam Floodlight Pro | | | ? | | |
| Wyze Cam Floodlight v2 | | | TUTK | | |
| Wyze Cam Floodlight | | | TUTK | | |
| Wyze Video Doorbell v2 | HL_DB2 | 4.51.3.4992 | TUTK | TransCode | h264, pcm |
| Wyze Video Doorbell v1 | | | TUTK | | |
| Wyze Video Doorbell Pro | | | ? | | |
| Wyze Battery Video Doorbell | | | ? | | |
| Wyze Duo Cam Doorbell | | | ? | | |
| Wyze Battery Cam Pro | | | ? | | |
| Wyze Solar Cam Pan | | | ? | | |
| Wyze Duo Cam Pan | | | ? | | |
| Wyze Window Cam | | | ? | | |
| Wyze Bulb Cam | | | ? | | |
_* Gwell based protocols are not yet supported._

Some files were not shown because too many files have changed in this diff Show More