Skip to content

Commit

Permalink
dump FFmpeg output on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Mar 29, 2012
1 parent 271a268 commit 715cbce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -64,7 +64,7 @@ Version History
---------------

0.6
Make FFmpeg timeout more robust.
Make FFmpeg timeout more robust. Dump FFmpeg output on timeout.

0.5
Fix crash when FFmpeg fails to report a duration.
Expand Down
12 changes: 8 additions & 4 deletions audioread/ffdec.py
Expand Up @@ -74,8 +74,8 @@ def __init__(self, filename):

# Start a separate thread to read the rest of the data from
# stderr.
stderr_reader = ReaderThread(self.proc.stderr)
stderr_reader.start()
self.stderr_reader = ReaderThread(self.proc.stderr)
self.stderr_reader.start()

def read_data(self, block_size=4096, timeout=10.0):
"""Read blocks of raw PCM data from the file."""
Expand All @@ -89,8 +89,12 @@ def read_data(self, block_size=4096, timeout=10.0):
end_time = time.time()
if not rready and not xready:
if end_time - start_time >= timeout:
# Nothing interesting has happened.
raise ReadTimeoutError()
# Nothing interesting has happened for a while --
# FFmpeg is probably hanging.
raise ReadTimeoutError(
'ffmpeg output: %s' %
''.join(self.stderr_reader.data)
)
else:
# Keep waiting.
continue
Expand Down

0 comments on commit 715cbce

Please sign in to comment.