mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Dump ffmpeg stderr to ESPhome debug log (#130808)
* dump the stderr from ffmpeg to debug log * add pid to indentify the ffmpeg process * be more explosive :) * move stderr task into _write_ffmpeg_data
This commit is contained in:
parent
ce20670d84
commit
70c8c57401
@ -212,6 +212,10 @@ class FFmpegConvertResponse(web.StreamResponse):
|
||||
assert proc.stdout is not None
|
||||
assert proc.stderr is not None
|
||||
|
||||
stderr_task = self.hass.async_create_background_task(
|
||||
self._dump_ffmpeg_stderr(proc), "ESPHome media proxy dump stderr"
|
||||
)
|
||||
|
||||
try:
|
||||
# Pull audio chunks from ffmpeg and pass them to the HTTP client
|
||||
while (
|
||||
@ -230,18 +234,14 @@ class FFmpegConvertResponse(web.StreamResponse):
|
||||
raise # don't log error
|
||||
except:
|
||||
_LOGGER.exception("Unexpected error during ffmpeg conversion")
|
||||
|
||||
# Process did not exit successfully
|
||||
stderr_text = ""
|
||||
while line := await proc.stderr.readline():
|
||||
stderr_text += line.decode()
|
||||
_LOGGER.error("FFmpeg output: %s", stderr_text)
|
||||
|
||||
raise
|
||||
finally:
|
||||
# Allow conversion info to be removed
|
||||
self.convert_info.is_finished = True
|
||||
|
||||
# stop dumping ffmpeg stderr task
|
||||
stderr_task.cancel()
|
||||
|
||||
# Terminate hangs, so kill is used
|
||||
if proc.returncode is None:
|
||||
proc.kill()
|
||||
@ -250,6 +250,16 @@ class FFmpegConvertResponse(web.StreamResponse):
|
||||
if request.transport and not request.transport.is_closing():
|
||||
await writer.write_eof()
|
||||
|
||||
async def _dump_ffmpeg_stderr(
|
||||
self,
|
||||
proc: asyncio.subprocess.Process,
|
||||
) -> None:
|
||||
assert proc.stdout is not None
|
||||
assert proc.stderr is not None
|
||||
|
||||
while self.hass.is_running and (chunk := await proc.stderr.readline()):
|
||||
_LOGGER.debug("ffmpeg[%s] output: %s", proc.pid, chunk.decode().rstrip())
|
||||
|
||||
|
||||
class FFmpegProxyView(HomeAssistantView):
|
||||
"""FFmpeg web view to convert audio and stream back to client."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user