diff --git a/app/core/media/ffmpeg_builders/base.py b/app/core/media/ffmpeg_builders/base.py index cdc0139e..ec47d027 100644 --- a/app/core/media/ffmpeg_builders/base.py +++ b/app/core/media/ffmpeg_builders/base.py @@ -82,6 +82,17 @@ 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. 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", "1", "-reconnect_at_eof", "1"] + # fmt: off command = [ "ffmpeg", @@ -98,13 +109,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", 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 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"])