From 4eb3e9807684ba5927af44a567ae2bc6b4a25cc8 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 16 Nov 2022 05:29:47 -0700 Subject: [PATCH] Update go2rtc, simplify manual stream, and support audio for MSE & WebRTC (#4391) * Update go2rtc to rc3 * Simplify ffmpeg / audio conversions * Set ffmpeg bin location * Manually set video as copied * Run go2rtc with env vars * Remove manual ffmpeg declaration * Enable force_audio by default * Fix test --- docker/Dockerfile | 2 +- docker/rootfs/etc/services.d/go2rtc/run | 2 +- docs/docs/configuration/index.md | 2 +- frigate/config.py | 2 +- frigate/restream.py | 2 +- frigate/test/test_restream.py | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 420bf3c54..2964dc080 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -119,7 +119,7 @@ RUN --mount=type=bind,from=wheels,source=/wheels,target=/wheels \ ENV PATH=$PATH:/usr/lib/btbn-ffmpeg/bin # install go2rtc -RUN wget -O go2rtc "https://github.com/AlexxIT/go2rtc/releases/download/v0.1-rc.2/go2rtc_linux_${TARGETARCH}" \ +RUN wget -O go2rtc "https://github.com/AlexxIT/go2rtc/releases/download/v0.1-rc.3/go2rtc_linux_${TARGETARCH}" \ && chmod +x go2rtc \ && mkdir -p /usr/local/go2rtc/sbin/ \ && mv go2rtc /usr/local/go2rtc/sbin/go2rtc diff --git a/docker/rootfs/etc/services.d/go2rtc/run b/docker/rootfs/etc/services.d/go2rtc/run index 55d206414..866a8ab8f 100644 --- a/docker/rootfs/etc/services.d/go2rtc/run +++ b/docker/rootfs/etc/services.d/go2rtc/run @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/with-contenv bash # https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425?permalink_comment_id=3945021 set -euo pipefail diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 6f1600563..eacb8cb1f 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -354,7 +354,7 @@ restream: # Optional: Enable the restream (default: True) enabled: True # Optional: Force audio compatibility with browsers (default: shown below) - force_audio: False + force_audio: True # Optional: jsmpeg stream configuration for WebUI jsmpeg: # Optional: Set the height of the jsmpeg stream. (default: 720) diff --git a/frigate/config.py b/frigate/config.py index cf3ae6398..e52a81d35 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -536,7 +536,7 @@ class JsmpegStreamConfig(FrigateBaseModel): class RestreamConfig(FrigateBaseModel): enabled: bool = Field(default=True, title="Restreaming enabled.") force_audio: bool = Field( - default=False, title="Force audio compatibility with the browser." + default=True, title="Force audio compatibility with the browser." ) jsmpeg: JsmpegStreamConfig = Field( default_factory=JsmpegStreamConfig, title="Jsmpeg Stream Configuration." diff --git a/frigate/restream.py b/frigate/restream.py index b06ae95e2..0d72c3f5a 100644 --- a/frigate/restream.py +++ b/frigate/restream.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) def get_manual_go2rtc_stream(camera_url: str) -> str: """Get a manual stream for go2rtc.""" - return f"exec: /usr/lib/btbn-ffmpeg/bin/ffmpeg -i {camera_url} -c:v copy -c:a libopus -rtsp_transport tcp -f rtsp {{output}}" + return f"ffmpeg:{camera_url}#video=copy#audio=aac#audio=opus" class RestreamApi: diff --git a/frigate/test/test_restream.py b/frigate/test/test_restream.py index 7170bf06b..6e4096a05 100644 --- a/frigate/test/test_restream.py +++ b/frigate/test/test_restream.py @@ -25,6 +25,7 @@ class TestRestream(TestCase): }, "restream": { "enabled": True, + "force_audio": False, }, }, "front": {