Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MediaMTX #1224

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open

Update MediaMTX #1224

wants to merge 37 commits into from

Conversation

mrlt8
Copy link
Owner

@mrlt8 mrlt8 commented May 22, 2024

Update MediaMTX which offers an updated authentication system for streams and recording.

NEW: STREAM_AUTH option to specify multiple users and paths:

  • Username and password should be separated by a :
  • An additional : can be used to specify the allowed IP address for the user.
    • This does NOT work with docker desktop
    • Specify multiple IPs using a comma
  • Use the @ to specify paths accessible to the user.
    • Paths are optional for each user.
    • Multiple paths can be specified by using a comma. If none are provided, the user will have access to all paths/streams
  • Multiple users can be specified by using | as a separator

EXAMPLES:

STREAM_AUTH=user:pass@cam-1,other-cam|second-user:password@just-one-cam|user3:pass
  • user:pass has access to cam-1 and other-cam
  • second-user:password has access to just-one-cam
  • user3:pass has access to all paths/cameras
STREAM_AUTH= user:pass:192.168.0.7|::192.168.0.10|::192.168.0.15,192.168.0.20@just-one-cam
  • user:pass has access to all paths/cameras when streaming from 192.168.0.7
  • No authentication required for all paths/cameras when streaming from 192.168.0.10
  • No authentication required for just-one-cam when streaming from 192.168.0.15 or from 192.168.0.20
STREAM_AUTH=user:pass|:@public-cam|::192.168.0.17
  • user:pass has access to all paths/cameras
  • No authentication required for public-cam
  • No authentication required for all paths/cameras when streaming from 192.168.0.17

Recording via MediaMTX:

RECORD_PATH Available variables are %path or {cam_name}, %Y %m %d %H %M %S %f %s (time in strftime format).

RECORD_LENGTH Length of each clip. Use s for seconds , h for hours. Defaults to 60s
RECORD_KEEP Delete older clips. Use s for seconds , h for hours. Set to 0s to disable automatic deletion. Defaults to 0s

@JA16122000
Copy link

JA16122000 commented Jun 23, 2024

volumes:

  • /mnt/usbhdd/Record/:/record/

Changed '/record/' to '/Record/' and now it is recording ;) [On the 'latest' branche and 'previous build', this won't record at all]
But now i don't get a live stream.
Just an frozen image

HLS Stream is working fine, but WebRTC stream is not working

So:
..............................................................................................................
DEV BUILD:
volumes:

  • /mnt/usbhdd/Record/:/record/ <== wont record.

volumes:

  • /mnt/usbhdd/Record/:/Record/ <== record!

..............................................................................................................
LATEST BUILD:
volumes:

  • /mnt/usbhdd/Record/:/record/ <== record.

volumes:

  • /mnt/usbhdd/Record/:/Record/ <== wont record!

..............................................................................................................

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 24, 2024

@JA16122000 default settings will record to /record/ , however, if you changed this with RECORD_PATH then you need to mount the location you're recording to.

@JA16122000
Copy link

Unfortunately, the WebRTC stream is not working.

HLS is working, though.

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 24, 2024

@JA16122000 WebRTC should be fixed with the latest changes. Please let me know if your run into any other issues.

@JA16122000
Copy link

JA16122000 commented Jun 24, 2024

@JA16122000 WebRTC should be fixed with the latest changes. Please let me know if your run into any other issues.

Still not playing with WebRTC

docker-compose.yml looks like:


services:
wyze-bridge:
container_name: wyze-bridge
restart: unless-stopped
image: mrlt8/wyze-bridge:dev
ports:
- 1935:1935 # RTMP
- 8554:8554 # RTSP
- 8888:8888 # HLS
- 5000:5000 # WEB-UI
- 9997:9997 # Expose port for API
- 8889:8889 # WebRTC
- 8189:8189/udp # WebRTC/ICE
environment:
- API_ID=blob
- API_KEY=blob
- WYZE_EMAIL=blob
- WYZE_PASSWORD=blob
- STREAM_AUTH=blob:blob
- WB_AUTH=True
- WB_USERNAME=blob
- WB_PASSWORD=blob
- WB_IP=192.168.178.78
- NET_MODE=LAN
- KEEP_BAD_FRAMES=True
- FRESH_DATA=True
- TZ=Europe/Amsterdam
- RECORD_ALL=True
- RECORD_PATH=/Record/{cam_name}
- RECORD_FILE_NAME={cam_name}%Y%m_%d_%H_%M_%S
- RECORD_LENGTH=1800s
volumes:
- /mnt/usbhdd/Record/:/Record/
- ./tokens:/tokens/


LOG:

🚀 DOCKER-WYZE-BRIDGE v2.9.9 ARMV7L DEV BUILD [2024-06-24t14:25:28.918z] 357857c
[WyzeBridge] ♻️ Clearing local cache...
[WyzeBridge] [MTX] Custom stream auth enabled
[WyzeBridge] [MTX] Auth [blob:blob] paths='all'
[WyzeBridge] 🔍 Could not find local cache for 'auth'
[WyzeBridge] ☁️ Fetching 'auth' from the Wyze API...

  • Serving Flask app 'frontend'
  • Debug mode: off
    [WyzeBridge] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Running on all addresses (0.0.0.0)
  • Running on http://127.0.0.1:5000
  • Running on http://172.18.0.2:5000
    [WyzeBridge] Press CTRL+C to quit
    [WyzeBridge] 💾 Saving 'auth' to local cache...
    [WyzeBridge] 🔍 Could not find local cache for 'user'
    [WyzeBridge] ☁️ Fetching 'user' from the Wyze API...
    [WyzeBridge] 💾 Saving 'user' to local cache...
    [WyzeBridge] 🔍 Could not find local cache for 'cameras'
    [WyzeBridge] ☁️ Fetching 'cameras' from the Wyze API...
    [WyzeBridge] 🔍 Could not find local cache for 'cameras'
    [WyzeBridge] ☁️ Fetching 'cameras' from the Wyze API...
    [WyzeBridge] [API] Fetched [2] cameras
    [WyzeBridge] 💾 Saving 'cameras' to local cache...
    [WyzeBridge] [+] Adding Voortuin [HL_CAM3P]
    [WyzeBridge] [MTX] 📹 Will record 1800s clips to /Record/voortuin/voortuin_%Y_%m_%d_%H_%M_%S.mp4
    [WyzeBridge] [+] Adding Achtertuin [HL_CAM3P]
    [WyzeBridge] [MTX] 📹 Will record 1800s clips to /Record/achtertuin/achtertuin_%Y_%m_%d_%H_%M_%S.mp4
    [WyzeBridge] [API] Fetched [2] cameras
    [WyzeBridge] 💾 Saving 'cameras' to local cache...
    [WyzeBridge] [MTX] starting MediaMTX 1.8.3
    [WyzeBridge] 🎬 2 streams enabled
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET / HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /static/bulma-toast.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /static/webrtc.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /static/site.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /static/bulma.css HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /static/site.css HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /static/loading.svg HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:21] "GET /api/sse_status HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:22] "GET /api/sse_status HTTP/1.1" 200 -
    [WyzeBridge] 🎉 Connecting to WyzeCam V3 Pro - Voortuin on 192.168.178.70
    [WyzeBridge] 🎉 Connecting to WyzeCam V3 Pro - Voortuin on 192.168.178.70
    [WyzeBridge] 173.239.217.129 - - [24/Jun/2024 16:45:22] "GET /signaling/voortuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 🎉 Connecting to WyzeCam V3 Pro - Voortuin on 192.168.178.70
    [WyzeBridge] 🎉 Connecting to WyzeCam V3 Pro - Achtertuin on 192.168.178.69
    Connection closed by remote. Closing connection.
    Connection closed by remote. Closing connection.
    [voortuin] [-22] IOTC_ER_SESSION_CLOSE_BY_REMOTE

@JA16122000
Copy link

JA16122000 commented Jun 24, 2024

Noticed that MTX auth:

🚀 DOCKER-WYZE-BRIDGE v2.9.9 ARMV7L DEV BUILD [2024-06-24t14:25:28.918z] 357857c
[WyzeBridge] ♻️ Clearing local cache...
[WyzeBridge] [MTX] Custom stream auth enabled
[WyzeBridge] [MTX] Auth [blob:blob] paths='all' <<<=========

I noticed that 'MTX auth' is not case-sensitive for passwords. (I have capital letters, but in the log they are NOT capital)

@JA16122000
Copy link

Thanks for the feedback @JA16122000! Is the webRTC issue with the VPN only on the dev branch? Did your VPN work with the previous builds?

The WebRTC issue with the VPN enabled is indeed only on the 'dev' branch.

I suspect it has to do with the newer MTX variant, as it worked with older 'dev' branches with older MTX versions

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 25, 2024

Could you post some more details about your vpn config so I can replicate the issue? Are you connecting to the bridge over a VPN or is the VPN unrelated to the bridge?

@JA16122000
Copy link

JA16122000 commented Jun 25, 2024

Could you post some more details about your vpn config so I can replicate the issue? Are you connecting to the bridge over a VPN or is the VPN unrelated to the bridge?

On my laptop (locally, not on the entire network), I use PIA (Private Internet Access) as a VPN.
As soon as I turn on PIA (i.e., turn on the VPN on my local laptop), I can no longer see WebRTC from the laptop.
If I turn off the VPN on the laptop, WebRTC works perfectly.

Addition:

On my phone, I use a VPN tunnel so that I can use my home network (no matter where I am).
As soon as I use this VPN tunnel, I cannot see WebRTC on the phone.
If I turn off the VPN tunnel, I can see WebRTC.


For clarity, my own network is VPN-free.

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 25, 2024

hmm, so I can kind of replicate the issue by connecting to a commercial VPN service...

chrome safari firefox
dev yes no yes on linux; no on macOS
latest yes yes on linux; no on macOS yes on linux; no on macOS

@JA16122000
Copy link

hmm, so I can kind of replicate the issue by connecting to a commercial VPN service...

WebRTC doesn't work with VPNs.

No matter which VPN you use.

It doesn't work on my phone to access my home network through a VPN tunnel.
And it also doesn't work with paid VPN services.

It seems that WebRTC is simply not discoverable from outside the network?

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 25, 2024

So are you trying to VPN back to your LAN to view the WebRTC or are you routing your traffic via a VPN while on your local network?

Chrome seems to be resilient to VPN changes for me on DEV/Latest.

@JA16122000
Copy link

JA16122000 commented Jun 25, 2024

So are you trying to VPN back to your LAN to view the WebRTC or are you routing your traffic via a VPN while on your local network?

Chrome seems to be resilient to VPN changes for me on DEV/Latest.

On my LAN-network, i don't have an VPN (NO VPN Network-wide, only my laptop is localy routing traffic by VPN)

PHONE:
On my phone, i'm trying to VPN back to my LAN indeed [WebRTC NOT working]
When i'm home and not using VPN back to my LAN, WebRTC is working.
When i'm home and also using VPN back to my LAN, WebRTC is NOT working.
When i'm NOT home, i cannot acces WebRTC

LAPTOP
My laptop (Local) i'm routing my traffic via VPN, then WebRTC is NOT working on any browser
My laptop (Local) when i'm not routing via VPN, then WebRTC is working.

@JA16122000
Copy link

JA16122000 commented Jun 29, 2024

Working without VPN.
Not working with VPN


🚀 DOCKER-WYZE-BRIDGE v2.9.10 ARMV7L DEV BUILD [2024-06-29t13:56:12.963z] 71df0c2
[WyzeBridge] ♻️ Clearing local cache...
[WyzeBridge] [MTX] Custom stream auth enabled
[WyzeBridge] [MTX] Auth [blob:blob]paths='all'
[WyzeBridge] 🔍 Could not find local cache for 'auth'
[WyzeBridge] ☁️ Fetching 'auth' from the Wyze API...

  • Serving Flask app 'frontend'
  • Debug mode: off
    [WyzeBridge] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Running on all addresses (0.0.0.0)
  • Running on http://127.0.0.1:5000
  • Running on http://172.18.0.2:5000
    [WyzeBridge] Press CTRL+C to quit
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:17] "GET /?video HTTP/1.1" 302 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:17] "GET /login HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:17] "GET /static/site.css HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:17] "GET /static/bulma.css HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:18] "GET /static/bulma-toast.js HTTP/1.1" 200 -
    [WyzeBridge] 💾 Saving 'auth' to local cache...
    [WyzeBridge] 🔍 Could not find local cache for 'user'
    [WyzeBridge] ☁️ Fetching 'user' from the Wyze API...
    [WyzeBridge] 💾 Saving 'user' to local cache...
    [WyzeBridge] 🔍 Could not find local cache for 'cameras'
    [WyzeBridge] ☁️ Fetching 'cameras' from the Wyze API...
    [WyzeBridge] [API] Fetched [2] cameras
    [WyzeBridge] 💾 Saving 'cameras' to local cache...
    [WyzeBridge] [+] Adding Voortuin [HL_CAM3P]
    [WyzeBridge] [MTX] 📹 Will record 1800s clips to /Record/voortuin/voortuin_%Y_%m_%d_%H_%M_%S.mp4
    [WyzeBridge] [+] Adding Achtertuin [HL_CAM3P]
    [WyzeBridge] [MTX] 📹 Will record 1800s clips to /Record/achtertuin/achtertuin_%Y_%m_%d_%H_%M_%S.mp4
    [WyzeBridge] [MTX] starting MediaMTX 1.8.3
    [WyzeBridge] 🎬 2 streams enabled
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:20] "GET /login HTTP/1.1" 302 -
    [WyzeBridge] 🎉 Connecting to WyzeCam V3 Pro - Voortuin on 192.168.178.70
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET / HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET /static/bulma.css HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET /static/site.css HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET /static/bulma-toast.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET /static/webrtc.js HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET /static/site.js HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:21] "GET /static/loading.svg HTTP/1.1" 200 -
    [WyzeBridge] 🎉 Connecting to WyzeCam V3 Pro - Achtertuin on 192.168.178.69
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:22] "GET /api/sse_status HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:22] "GET /signaling/voortuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:22] "GET /signaling/achtertuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] ☁️ Pulling "voortuin" thumbnail to /img/voortuin.jpg
    [WyzeBridge] ☁️ Pulling "achtertuin" thumbnail to /img/achtertuin.jpg
    [achtertuin] 📡 Getting 180kb/s 2K stream (H264/20fps) via LAN mode (WiFi: 70%) FW: 4.58.12.9751 🔒
    [voortuin] 📡 Getting 180kb/s 2K stream (H264/20fps) via LAN mode (WiFi: 61%) FW: 4.58.12.9751 🔒
    [voortuin] WARNING: Skipping wrong frame_size at start of stream [frame_size=1]
    [achtertuin] WARNING: Skipping wrong frame_size at start of stream [frame_size=1]
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:25] "GET /img/achtertuin.jpg HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:25] "GET /img/voortuin.jpg HTTP/1.1" 200 -
    [WyzeBridge] ✅ '/voortuin stream is UP! (3/3)
    [WyzeBridge] ✅ '/achtertuin stream is UP! (3/3)
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:25] "GET /img/achtertuin.jpg HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:26] "GET /img/voortuin.jpg HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:26] "GET /signaling/voortuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:27] "GET /signaling/achtertuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:36] "GET / HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:36] "GET /static/bulma.css HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:36] "GET /static/site.css HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:36] "GET /static/webrtc.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:36] "GET /static/bulma-toast.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:36] "GET /static/site.js HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /img/achtertuin.jpg HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /img/achtertuin.jpg HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /img/voortuin.jpg HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /api/sse_status HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /img/voortuin.jpg HTTP/1.1" 304 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /signaling/voortuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:37] "GET /signaling/achtertuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:52] "GET /signaling/voortuin?webrtc HTTP/1.1" 200 -
    [WyzeBridge] 173.239.217.165 - - [29/Jun/2024 16:01:52] "GET /signaling/achtertuin?webrtc HTTP/1.1" 200 -

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 30, 2024

No changes have been made re: webrtc, so there shouldn't be any difference.

potential work around:

ports:
    - 8189:8189
    - 8189:8189/udp
    ...
environment:
    - MTX_WEBRTCLOCALTCPADDRESS=:8189
    ...

@JA16122000
Copy link

No changes have been made re: webrtc, so there shouldn't be any difference.

potential work around:

ports:
    - 8189:8189
    - 8189:8189/udp
    ...
environment:
    - MTX_WEBRTCLOCALTCPADDRESS=:8189
    ...

So:

ports:
- 8189:8189
- 8189:8189/udp
...
environment:
- MTX_WEBRTCLOCALTCPADDRESS=192.168.178.78:8189

Thats also not working
...

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 30, 2024

no, should be:

- MTX_WEBRTCLOCALTCPADDRESS=:8189

@JA16122000
Copy link

no, should be:

- MTX_WEBRTCLOCALTCPADDRESS=:8189

Also tried, but doesn't work either

@mrlt8
Copy link
Owner Author

mrlt8 commented Jun 30, 2024

then you should probably open an issue with mediamtx as you seem to be having a different issue.

@JA16122000
Copy link

Where and how do I do that?
I will do that ;)
Can I refer to this topic?

@JA16122000
Copy link

This one?
https://github.com/bluenviron/mediamtx

@JA16122000
Copy link

The same as: bluenviron/mediamtx#3522 ??

@mrlt8
Copy link
Owner Author

mrlt8 commented Jul 2, 2024

No, you already confirmed you have a different issue.

Repository owner locked and limited conversation to collaborators Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants