问题描述
这是完整的代码,以供参考:
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)
我正在寻找一种下载Twitch VOD的方法。我从指向VOD的链接开始:https://www.twitch.tv/videos/783301562。然后,我使用了代码:
stream_url = streamlink.streams("https://www.twitch.tv/videos/783301562")['best'].url
print(stream_url)
这给了我一个新的链接,当我转到该链接时,它下载了扩展名为'.m3u8'的文件。该链接是:https://dqrpb9wgowsf5.cloudfront.net/ab3654a5992fbfa52ccb_briziana_40240109614_1603789265/chunked/index-dvr.m3u8
stream = (
ffmpeg
.input(stream_url)
.output('output.mp4')
.run
)
print(stream)
>
然后我添加了以下代码来下载文件,我还更改了ffmpeg代码以使用下载的文件而不是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)
这给出了相同的结果,没有mp4文件具有与上面相同的输出。任何帮助将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)