1
mirror of https://github.com/streamlink/streamlink synced 2024-10-05 01:01:30 +02:00

Prebuffer some data before outputing to player/file.

This is a simple way to check if stream server is
dead/has problems before launching a player/file output.
This commit is contained in:
Christopher Rosell 2012-08-15 14:57:58 +02:00
parent 327585ccd4
commit 0c5563f5e4

View File

@ -105,6 +105,11 @@ def output_stream(stream, args):
except livestreamer.StreamError as err:
exit(("Could not open stream - {0}").format(err))
try:
prebuffer = fd.read(8192)
except IOError:
exit("Failed to read data from stream")
if args.output:
if args.output == "-":
out = stdout
@ -134,6 +139,8 @@ def output_stream(stream, args):
import msvcrt
msvcrt.setmode(out.fileno(), os.O_BINARY)
out.write(prebuffer)
try:
write_stream(fd, out, progress)
except KeyboardInterrupt: