From 0d3a18d5a331de102ec9427412a831aab30daccb Mon Sep 17 00:00:00 2001 From: qinzihan Date: Tue, 10 Nov 2026 08:48:31 +0800 Subject: [PATCH 1/4] fix: place -reconnect* options before -i so stream reconnection actually works The three reconnect options sat after -i (output options area) where ffmpeg silently ignores them, so automatic reconnection on network drops never worked for any platform. They are HTTP-protocol input options and must precede -i; only added for http(s) URLs to avoid errors on rtmp inputs. Helps #502 (douyu 5-min disconnects). --- app/core/media/ffmpeg_builders/base.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/core/media/ffmpeg_builders/base.py b/app/core/media/ffmpeg_builders/base.py index cdc0139e..4e62d3df 100644 --- a/app/core/media/ffmpeg_builders/base.py +++ b/app/core/media/ffmpeg_builders/base.py @@ -82,6 +82,14 @@ def _get_basic_ffmpeg_command(self) -> list[str]: # FFmpeg 8 rejects container/extension mismatches in strict mode. hls_input_options = ["-extension_picky", "0"] + # -reconnect* are HTTP-protocol *input* options: they only take effect + # before -i. Placing them after -i (output options area) made ffmpeg + # silently drop them, so automatic reconnection never worked. They are + # only valid for http(s) inputs. + reconnect_options = [] + if self.record_url.startswith(("http://", "https://")): + reconnect_options = ["-reconnect_delay_max", "60", "-reconnect_streamed", "-reconnect_at_eof"] + # fmt: off command = [ "ffmpeg", @@ -98,13 +106,11 @@ def _get_basic_ffmpeg_command(self) -> list[str]: "-fflags", "+discardcorrupt+igndts", "-re", *hls_input_options, + *reconnect_options, "-i", self.record_url, "-bufsize", config["bufsize"], "-sn", "-dn", - "-reconnect_delay_max", "60", - "-reconnect_streamed", - "-reconnect_at_eof", "-max_muxing_queue_size", config["max_muxing_queue_size"], "-correct_ts_overflow", "1", "-avoid_negative_ts", "1", From e214b7ad6e6c0c20a146b718d89b60b5f77bc940 Mon Sep 17 00:00:00 2001 From: qinzihan Date: Tue, 10 Nov 2026 08:48:32 +0800 Subject: [PATCH 2/4] fix: never overwrite a custom streamer name on live-end checks (#500) The offline branch of check_if_live updated streamer_name to the platform anchor whenever the display title carried the live marker, silently discarding the name the user typed and persisting the overwrite. Only auto-fill the name while it still holds the default placeholder; custom names (and titles built from them) are kept. --- app/core/recording/record_manager.py | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/app/core/recording/record_manager.py b/app/core/recording/record_manager.py index b2ab7bb0..6e33bdac 100644 --- a/app/core/recording/record_manager.py +++ b/app/core/recording/record_manager.py @@ -255,8 +255,13 @@ async def periodic_check(): else: logger.info("Periodic live check task already running globally, skipping initialization") - async def check_if_live(self, recording: Recording): - """Check if the live stream is available, fetch stream data and update is_live status.""" + async def check_if_live(self, recording: Recording, manual_start: bool = False): + """Check if the live stream is available, fetch stream data and update is_live status. + + ``manual_start`` is set when the user explicitly starts a recording from + the card button: it bypasses the per-room "only notify, don't record" + setting so a manual click really starts ffmpeg (issue #504). + """ recording.manually_stopped = False if recording.is_recording or recording.stopping_in_progress: @@ -389,7 +394,7 @@ async def check_if_live(self, recording: Recording): BackgroundService.get_instance().add_task(msg_manager.push_messages_sync, msg_title, push_content) recording.notified_live_start = True - if not recording.only_notify_no_record: + if not recording.only_notify_no_record or manual_start: recording.status_info = RecordingStatus.PREPARING_RECORDING recording.loop_time_seconds = self.loop_time_seconds self.start_update(recording) @@ -412,15 +417,20 @@ async def check_if_live(self, recording: Recording): asyncio.create_task(recorder.end_message_push()) recording.status_info = RecordingStatus.MONITORING - title = f"{stream_info.anchor_name or recording.streamer_name} - {self._[recording.quality]}" - if recording.streamer_name == self._["live_room"] or f"[{self._['is_live']}]" in recording.display_title: - recording.update( - { - "streamer_name": stream_info.anchor_name, - "title": title, - "display_title": title, - } - ) + # Only auto-fill the streamer name while it still holds the default + # placeholder; a user-provided custom name must never be overwritten + # by the platform anchor name (issue #500). + is_default_name = recording.streamer_name == self._["live_room"] + if is_default_name and stream_info.anchor_name: + name_for_title = stream_info.anchor_name + else: + name_for_title = recording.streamer_name + title = f"{name_for_title} - {self._[recording.quality]}" + if is_default_name or f"[{self._['is_live']}]" in recording.display_title: + updates = {"title": title, "display_title": title} + if is_default_name and stream_info.anchor_name: + updates["streamer_name"] = stream_info.anchor_name + recording.update(updates) self.services.run_coro(self.persist_recordings()) recording.is_checking = False From 66c34e8f71fbc0e9b87e8aa6644805f8891f3749 Mon Sep 17 00:00:00 2001 From: qinzihan Date: Tue, 10 Nov 2026 08:48:33 +0800 Subject: [PATCH 3/4] fix: manual start button now really records with only-notify-no-record rooms (#504) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For rooms with only_notify_no_record enabled, on_toggle_recording called check_if_live (which skips starting ffmpeg) and then start_update, which only flips the is_recording flag — the card showed a fake recording with no file. Pass manual_start=True so check_if_live bypasses the setting and launches ffmpeg itself; drop the redundant manual start_update call. --- app/ui/components/business/recording_card.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/ui/components/business/recording_card.py b/app/ui/components/business/recording_card.py index 658b79b8..509663c4 100644 --- a/app/ui/components/business/recording_card.py +++ b/app/ui/components/business/recording_card.py @@ -320,9 +320,12 @@ async def on_toggle_recording(self, recording: Recording): await self.app.snack_bar.show_snack_bar(self._["stop_record_tip"]) else: if recording.monitor_status: - await self.app.record_manager.check_if_live(recording) + # manual_start bypasses the "only notify, don't record" + # room setting so the click really launches ffmpeg; the + # previous extra start_update() call only flipped the + # is_recording flag and produced a fake recording (#504). + await self.app.record_manager.check_if_live(recording, manual_start=True) if recording.is_live: - self.app.record_manager.start_update(recording) await self.app.snack_bar.show_snack_bar(self._["pre_record_tip"], bgcolor=ft.Colors.PRIMARY) else: await self.app.snack_bar.show_snack_bar(self._["is_not_live_tip"]) From 1d116d55076897993e360c8b4c885704120e4da5 Mon Sep 17 00:00:00 2001 From: qinzihan Date: Tue, 10 Nov 2026 11:24:16 +0800 Subject: [PATCH 4/4] fix: give the reconnect boolean flags explicit values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -reconnect_streamed followed directly by another option made ffmpeg parse the next option name as its value ("Unable to parse ... as boolean") and refuse to start — every http(s) recording would have failed to launch. Verified by actually executing the builder command against a local HTTP source this time; with explicit values it records normally (exit 0). --- app/core/media/ffmpeg_builders/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/core/media/ffmpeg_builders/base.py b/app/core/media/ffmpeg_builders/base.py index 4e62d3df..ec47d027 100644 --- a/app/core/media/ffmpeg_builders/base.py +++ b/app/core/media/ffmpeg_builders/base.py @@ -85,10 +85,13 @@ def _get_basic_ffmpeg_command(self) -> list[str]: # -reconnect* are HTTP-protocol *input* options: they only take effect # before -i. Placing them after -i (output options area) made ffmpeg # silently drop them, so automatic reconnection never worked. They are - # only valid for http(s) inputs. + # only valid for http(s) inputs. The boolean flags need explicit + # values — two adjacent bare flags make ffmpeg try to parse the next + # option name as the value ("Unable to parse ... as boolean") and the + # whole command fails to start. reconnect_options = [] if self.record_url.startswith(("http://", "https://")): - reconnect_options = ["-reconnect_delay_max", "60", "-reconnect_streamed", "-reconnect_at_eof"] + reconnect_options = ["-reconnect_delay_max", "60", "-reconnect_streamed", "1", "-reconnect_at_eof", "1"] # fmt: off command = [