mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 07:17:12 +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.stdout is not None
|
||||||
assert proc.stderr 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:
|
try:
|
||||||
# Pull audio chunks from ffmpeg and pass them to the HTTP client
|
# Pull audio chunks from ffmpeg and pass them to the HTTP client
|
||||||
while (
|
while (
|
||||||
@ -230,18 +234,14 @@ class FFmpegConvertResponse(web.StreamResponse):
|
|||||||
raise # don't log error
|
raise # don't log error
|
||||||
except:
|
except:
|
||||||
_LOGGER.exception("Unexpected error during ffmpeg conversion")
|
_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
|
raise
|
||||||
finally:
|
finally:
|
||||||
# Allow conversion info to be removed
|
# Allow conversion info to be removed
|
||||||
self.convert_info.is_finished = True
|
self.convert_info.is_finished = True
|
||||||
|
|
||||||
|
# stop dumping ffmpeg stderr task
|
||||||
|
stderr_task.cancel()
|
||||||
|
|
||||||
# Terminate hangs, so kill is used
|
# Terminate hangs, so kill is used
|
||||||
if proc.returncode is None:
|
if proc.returncode is None:
|
||||||
proc.kill()
|
proc.kill()
|
||||||
@ -250,6 +250,16 @@ class FFmpegConvertResponse(web.StreamResponse):
|
|||||||
if request.transport and not request.transport.is_closing():
|
if request.transport and not request.transport.is_closing():
|
||||||
await writer.write_eof()
|
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):
|
class FFmpegProxyView(HomeAssistantView):
|
||||||
"""FFmpeg web view to convert audio and stream back to client."""
|
"""FFmpeg web view to convert audio and stream back to client."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user