Skip to content

Commit

Permalink
v2.10.2 - V4 FPS fix (#1329)
Browse files Browse the repository at this point in the history
* Use copyts and copytb #1287

Thanks @cdoolin!

* add custom_string to run_action for restart #1287

* Update battery level in WebUI

* Update site.js

* mono audio

* changelog
  • Loading branch information
mrlt8 authored Aug 22, 2024
1 parent 1b40e49 commit 611c5d4
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 15 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ It just works!

Streams direct from camera without additional bandwidth or subscriptions.

Based on [@noelhibbard's script](https://gist.github.com/noelhibbard/03703f551298c6460f2fd0bfdbc328bd#file-readme-md) with [kroo/wyzecam](https://github.com/kroo/wyzecam) and [bluenviron/mediamtx](https://github.com/bluenviron/mediamtx).

Please consider ⭐️ starring or [☕️ sponsoring](https://ko-fi.com/mrlt8) this project if you found it useful, or use the [affiliate link](https://amzn.to/3NLnbvt) when shopping on amazon!


Expand Down Expand Up @@ -52,20 +50,18 @@ See the [supported cameras](#supported-cameras) section for additional informati
Install [docker](https://docs.docker.com/get-docker/) and run:

```bash
docker run -p 8554:8554 -p 8888:8888 -p 5000:5000 mrlt8/wyze-bridge
docker run -p 8554:8554 -p 8888:8888 -p 5050:5000 -e WB_AUTH=false mrlt8/wyze-bridge
```

You can then use the web interface at `http://localhost:5000` where localhost is the hostname or ip of the machine running the bridge.

The default login for the WebUI will be:
```
username: wbadmin
password: <username portion of your wyze email>
```
Example: For the wyze email `[email protected]`, the default password would be `myEmail123`.
You can then use the web interface at `http://localhost:5050` where `localhost` is the hostname or ip of the machine running the bridge.

See [basic usage](#basic-usage) for additional information or visit the [wiki page](https://github.com/mrlt8/docker-wyze-bridge/wiki/Home-Assistant) for additional information on using the bridge as a Home Assistant Add-on.

## What's Changed in v2.10.2

- FIX: day/night FPS slowdown for V4 cameras (#1287) Thanks @cdoolin and @Answer-1!
- NEW: Update battery level in WebUI

## What's Changed in v2.10.0/v2.10.1

FIXED: Could not disable `WB_AUTH` if `WB_API` is set. (#1304)
Expand Down Expand Up @@ -284,6 +280,11 @@ All environment variables are optional.

## Other Wyze Projects

Honorable Mentions:

* [@noelhibbard's script](https://gist.github.com/noelhibbard/03703f551298c6460f2fd0bfdbc328bd#file-readme-md) - Original script that the bridge is bassd on.
* [kroo/wyzecam](https://github.com/kroo/wyzecam) - Original library that the bridge is based on.

Video Streaming:

* [gtxaspec/wz_mini_hacks](https://github.com/gtxaspec/wz_mini_hacks) - Firmware level modification for Ingenic based cameras with an RTSP server and [self-hosted mode](https://github.com/gtxaspec/wz_mini_hacks/wiki/Configuration-File#self-hosted--isolated-mode) to use the cameras without the wyze services.
Expand Down
3 changes: 2 additions & 1 deletion app/static/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ video {
.status .fa-circle-play,
.status .fa-circle-pause,
.status .fa-satellite-dish,
.fa-arrows-rotate {
.fa-arrows-rotate,
.card-header-title .icon.battery {
cursor: pointer;
}

Expand Down
35 changes: 35 additions & 0 deletions app/static/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ document.addEventListener("DOMContentLoaded", () => {
const preview = card.querySelector(`img.refresh_img, video[data-cam='${cam}']`);
const motionIcon = card.querySelector(".icon.motion");
const connected = card.dataset.connected.toLowerCase() === "true";
updateBatteryLevel(card);

card.dataset.connected = false;
statusIcon.className = "fas";
Expand Down Expand Up @@ -752,4 +753,38 @@ document.addEventListener("DOMContentLoaded", () => {
bulmaToast.toast({ message: `<strong>${title}</strong> - ${message}`, type: `is-${type}`, pauseOnHover: true, duration: 10000 })
}
}
function updateBatteryLevel(card) {
if (card.dataset.battery?.toLowerCase() !== "true") { return; }
const iconElement = card.querySelector(".icon.battery i");
fetch(`api/${card.id}/battery`)
.then((resp) => resp.json())
.then((data) => {
if (data.status != "success" || !data.value) { return; }
const batteryLevel = parseInt(data.value);
let batteryIcon;
iconElement.classList.remove("has-text-danger");
iconElement.classList.forEach(cls => {
if (cls.startsWith('fa-battery-')) {
iconElement.classList.remove(cls);
}
});
if (batteryLevel > 90) {
batteryIcon = "full";
} else if (batteryLevel > 75) {
batteryIcon = "three-quarters";
} else if (batteryLevel > 50) {
batteryIcon = "half";
} else if (batteryLevel > 10) {
batteryIcon = "quarter";
} else {
batteryIcon = "empty";
iconElement.classList.add("has-text-danger");
}
iconElement.classList.add(`fa-battery-${batteryIcon}`);
iconElement.parentElement.title = `Battery Level: ${batteryLevel}%`;
})
}
document.querySelectorAll('div.camera[data-battery="True"]').forEach((card) => {
card.querySelector(".icon.battery").addEventListener("click", () => updateBatteryLevel(card));
});
});
2 changes: 1 addition & 1 deletion app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
{% endif %}
{% endif %}
{% if camera.is_battery %}
<span class="icon" title="Battery">
<span class="icon battery">
<i class="fas fa-battery-empty" aria-hidden="true"></i>
</span>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions app/wyzebridge/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_ffmpeg_cmd(
thread_queue = "-thread_queue_size 8 -analyzeduration 32 -probesize 32"
if audio and "codec" in audio:
# `Option sample_rate not found.` if we try to specify -ar for aac:
rate = "" if audio["codec"] == "aac" else f" -ar {audio['rate']}"
rate = "" if audio["codec"] == "aac" else f" -ar {audio['rate']} -ac 1"
audio_in = f"{thread_queue} -f {audio['codec']}{rate} -i /tmp/{uri}_audio.pipe"
audio_out = audio["codec_out"] or "copy"
a_filter = env_bool("AUDIO_FILTER", "volume=5") + ",adelay=0|0"
Expand Down Expand Up @@ -66,7 +66,7 @@ def get_ffmpeg_cmd(
+ (["-map", "1:a", "-c:a", audio_out] if audio_in else [])
+ (a_options if audio and audio_out != "copy" else [])
+ ["-fps_mode", "passthrough", "-flush_packets", "1"]
+ ["-rtbufsize", "1"]
+ ["-rtbufsize", "1", "-copyts", "-copytb", "1"]
+ ["-f", "tee"]
+ [rtsp_ss + livestream]
)
Expand Down
1 change: 1 addition & 0 deletions app/wyzecam/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def run_action(auth_info: WyzeCredential, camera: WyzeCamera, action: str):
action_key=action,
instance_id=camera.mac,
provider_key=camera.product_model,
custom_string="",
)
resp = post(f"{WYZE_API}/v2/auto/run_action", json=payload, headers=_headers())

Expand Down
5 changes: 5 additions & 0 deletions home_assistant/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## What's Changed in v2.10.2

- FIX: day/night FPS slowdown for V4 cameras (#1287) Thanks @cdoolin and @Answer-1!
- NEW: Update battery level in WebUI

## What's Changed in v2.10.0/v2.10.1

FIXED: Could not disable `WB_AUTH` if `WB_API` is set. Thanks @bengthu! (#1304)
Expand Down

0 comments on commit 611c5d4

Please sign in to comment.