This is the whole code, for easy reference:
import urllib.request
import streamlink
import ffmpeg
stream_url = streamlink.streams("https://www.twitch.tv/videos/783301562")['best'].url
print(stream_url)
try:
urllib.request.urlretrieve(stream_url, "vod.m3u8")
except Exception as e:
print(e)
stream = (
ffmpeg
.input('vod.m3u8')
.output('output.mp4')
.run
)
print(stream)
I am looking at a way of downloading Twitch VODs. I started with the link to a VOD: https://www.twitch.tv/videos/783301562 . I then used the code:
stream_url = streamlink.streams("https://www.twitch.tv/videos/783301562")['best'].url
print(stream_url)
This gave me a new link which, when I go to this link it downloaded a file with a '.m3u8' extension. This link is: https://dqrpb9wgowsf5.cloudfront.net/ab3654a5992fbfa52ccb_briziana_40240109614_1603789265/chunked/index-dvr.m3u8
From here, I first tried to put the link directly into the following code:
stream = (
ffmpeg
.input(stream_url)
.output('output.mp4')
.run
)
print(stream)
This didn't output any mp4 file but did give the output:
<bound method run of output(filename='output.mp4')[None] <2606681a>>
I then added the following code to download the file, I also change the ffmpeg code to use the downloaded file rather then the url:
try:
urllib.request.urlretrieve(stream_url, "vod.m3u8")
except Exception as e:
print(e)
stream = (
ffmpeg
.input('vod.m3u8')
.output('output.mp4')
.run
)
print(stream)
This gave the same result, no mp4 file with the same output as above. Any help would be greatly appreciated!