From f564b2155a5339a411c0954c8591688284d56c66 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Sat, 14 Jan 2023 15:09:06 -0700 Subject: [PATCH] Update docs and tests --- docs/docs/configuration/index.md | 8 ++++++-- docs/docs/configuration/restream.md | 4 ++-- frigate/restream.py | 13 ++++++++----- frigate/test/test_restream.py | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 34ee7c4a6..969f693e4 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -356,8 +356,12 @@ rtmp: restream: # Optional: Enable the restream (default: True) enabled: True - # Optional: Force audio compatibility with browsers (default: shown below) - force_audio: True + # Optional: Set the audio codecs to restream with + # possible values are aac, copy, opus. Set to copy + # only to avoid transcoding (default: shown below) + audio_encoding: + - aac + - opus # Optional: Video encoding to be used. By default the codec will be copied but # it can be switched to another or an MJPEG stream can be encoded and restreamed # as h264 (default: shown below) diff --git a/docs/docs/configuration/restream.md b/docs/docs/configuration/restream.md index fda1c874a..8cea0e019 100644 --- a/docs/docs/configuration/restream.md +++ b/docs/docs/configuration/restream.md @@ -7,9 +7,9 @@ title: Restream Frigate can restream your video feed as an RTSP feed for other applications such as Home Assistant to utilize it at `rtsp://:8554/`. Port 8554 must be open. [This allows you to use a video feed for detection in Frigate and Home Assistant live view at the same time without having to make two separate connections to the camera](#reduce-connections-to-camera). The video feed is copied from the original video feed directly to avoid re-encoding. This feed does not include any annotation by Frigate. -#### Force Audio +#### Copy Audio -Different live view technologies (ex: MSE, WebRTC) support different audio codecs. The `restream -> force_audio` flag tells the restream to make multiple streams available so that all live view technologies are supported. Some camera streams don't work well with this, in which case `restream -> force_audio` should be disabled. +Different live view technologies (ex: MSE, WebRTC) support different audio codecs. The `restream -> audio_encoding` field tells the restream to make multiple streams available so that all live view technologies are supported. Some camera streams don't work well with this, in which case `restream -> audio_encoding` should be set to `copy` only. #### Birdseye Restream diff --git a/frigate/restream.py b/frigate/restream.py index 25eb3449c..edc628140 100644 --- a/frigate/restream.py +++ b/frigate/restream.py @@ -56,11 +56,13 @@ class RestreamApi: for input in camera.ffmpeg.inputs: if "restream" in input.roles: - if input.path.startswith( - "rtsp" - ) and not camera.restream.audio_encoding == [ - RestreamAudioCodecEnum.copy - ]: + if ( + input.path.startswith("rtsp") + and camera.restream.video_encoding + == RestreamVideoCodecEnum.copy + and not camera.restream.audio_encoding + == [RestreamAudioCodecEnum.copy] + ): self.relays[ cam_name ] = f"{escape_special_characters(input.path)}#backchannel=0" @@ -68,6 +70,7 @@ class RestreamApi: # go2rtc only supports rtsp for direct relay, otherwise ffmpeg is used self.relays[cam_name] = get_manual_go2rtc_stream( escape_special_characters(input.path), + camera.restream.audio_encoding, camera.restream.video_encoding, parse_preset_hardware_acceleration_go2rtc_engine( self.config.ffmpeg.hwaccel_args diff --git a/frigate/test/test_restream.py b/frigate/test/test_restream.py index 5de8c5cf1..2be781306 100644 --- a/frigate/test/test_restream.py +++ b/frigate/test/test_restream.py @@ -25,7 +25,7 @@ class TestRestream(TestCase): }, "restream": { "enabled": True, - "force_audio": False, + "audio_encoding": ["copy"], }, }, "front": {