Closed rodzebird closed 7 years ago
If you don't need progress, you can try:
session = Livestreamer()
tw = session.resolve_url('https://www.twitch.tv/danbergen/v/130213028')
stream = tw.streams()['source']
fd = stream.open()
with open('new_out.mp4', 'wb') as f:
while True:
data = fd.read(8192)
if not data:
break
f.write(data)
fd.close()
if you need progress report, you can try:
import os
from functools import partial
from livestreamer import Livestreamer
from livestreamer_cli.utils import progress
session = Livestreamer()
tw = session.resolve_url('https://www.twitch.tv/danbergen/v/130213028')
stream = tw.streams()['source']
fd = stream.open()
output_filename = 'new_out.mp4'
with open(output_filename, 'wb') as f:
for data in progress(iter(partial(fd.read, 8192), b""), prefix=os.path.basename(output_filename)):
f.write(data)
fd.close()
Thanks for the info mate ! It doesn't change the fact that it seems far slower than the command line but it helped me !
Hi there,
I'm using the Python library to load a VOD stream on Twitch and I try to save it into a
new_out.mp4
file. The thing is that mynew_out.mp4
is approximately 16MB at the end of the operation for 1.1GB when downloading the VOD through Livestreamer CLI.The original VOD lasts for about an hour, and the copied
new_out.mp4
file is only 50 seconds long.My script is as follows:
I tried this method too:
But neither seem to output more than 50 seconds of a 1 hour VOD.
Do you have any idea why ? Maybe the
stream.open()
produces segments ? Or is it a bug ?