栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

下载twitch.tv流的第一帧

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

下载twitch.tv流的第一帧

好吧,我知道了。确保将其写入二进制数据,并且OpenCV能够解码第一个视频帧。生成的图像具有切换的R和B通道,但是很容易校正。下载大约300
kB似乎足以确保有完整的图像。

import time, Imageimport cv2from livestreamer import Livestreamer# change to a stream that is actually onlinelivestreamer = Livestreamer()plugin = livestreamer.resolve_url("http://twitch.tv/flosd")streams = plugin.get_streams()stream = streams['mobile_High']# download enough data to make sure the first frame is therefd = stream.open()data = ''while len(data) < 3e5:    data += fd.read()    time.sleep(0.1)fd.close()fname = 'stream.bin'open(fname, 'wb').write(data)capture = cv2.VideoCapture(fname)imgdata = capture.read()[1]imgdata = imgdata[...,::-1] # BGR -> RGBimg = Image.fromarray(imgdata)img.save('frame.png')# img.show()


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/646652.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号