From 2e7750dc9f9c9eeec6153a8992d354d528a02c51 Mon Sep 17 00:00:00 2001 From: Bryce Boe Date: Sun, 20 Sep 2026 23:45:31 -0700 Subject: [PATCH] Omit ffmpeg encoder metadata from converted TTS audio (#182833) --- homeassistant/components/tts/__init__.py | 3 +++ tests/components/tts/test_init.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index 1262e8132131..fc5fe4ffe23c 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -355,6 +355,9 @@ async def _async_convert_audio( if to_sample_bytes == 2: # 16-bit samples. command.extend(["-sample_fmt", "s16"]) + # Do not write the muxer's own encoder metadata; metadata from the input + # is still copied. + command.extend(["-fflags", "+bitexact"]) command.append("pipe:1") # Send output to stdout. process = await asyncio.create_subprocess_exec( diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py index c03cc2b380ab..3382c63f69b0 100644 --- a/tests/components/tts/test_init.py +++ b/tests/components/tts/test_init.py @@ -1920,6 +1920,8 @@ async def test_async_convert_audio_probe_size( "1", "-sample_fmt", "s16", + "-fflags", + "+bitexact", "pipe:1", ] @@ -1968,6 +1970,8 @@ async def test_async_convert_audio_mp3_bitrate( "-ac", "1", *expected_encoder_args, + "-fflags", + "+bitexact", "pipe:1", ]