- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 Boto3 从 kinesis 获取视频流,然后使用 OpenCV 显示提要并同时将其保存到文件中。
获取签名 URL 和 Getmedia 请求的过程似乎完美无缺,只是当我尝试使用 OpenCV 呈现它时,它似乎不起作用。
数据正在挑衅地流向流
import boto3
import numpy as np
import cv2
kinesis_client = boto3.client('kinesisvideo',
region_name='eu-west-1',
aws_access_key_id='ACC',
aws_secret_access_key='KEY'
)
response = kinesis_client.get_data_endpoint(
StreamARN='ARN',
APIName='GET_MEDIA'
)
video_client = boto3.client('kinesis-video-media',
endpoint_url=response['DataEndpoint']
)
stream = video_client.get_media(
StreamARN='ARN',
StartSelector={'StartSelectorType': 'NOW'}
)
# print(stream)
datafeed = stream['Payload'].read()
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
while(True):
ret, frame = stream['Payload'].read()
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
最佳答案
为了最终回答这个问题,我找到了一个使用 HLS 输出的基本解决方案,该输出可从 kineses 视频流中获取。 2018 年 7 月可用
我在下面粘贴了我的代码的工作版本。
我正在使用 AWS ENV 变量进行 BOTO3 身份验证。
import boto3
import cv2
STREAM_NAME = "test-stream"
kvs = boto3.client("kinesisvideo")
# Grab the endpoint from GetDataEndpoint
endpoint = kvs.get_data_endpoint(
APIName="GET_HLS_STREAMING_SESSION_URL",
StreamName=STREAM_NAME
)['DataEndpoint']
print(endpoint)
# # Grab the HLS Stream URL from the endpoint
kvam = boto3.client("kinesis-video-archived-media", endpoint_url=endpoint)
url = kvam.get_hls_streaming_session_url(
StreamName=STREAM_NAME,
PlaybackMode="LIVE"
)['HLSStreamingSessionURL']
vcap = cv2.VideoCapture(url)
while True:
# Capture frame-by-frame
ret, frame = vcap.read()
if frame is not None:
# Display the resulting frame
cv2.imshow('frame',frame)
# Press q to close the video windows before it ends if you want
if cv2.waitKey(22) & 0xFF == ord('q'):
break
else:
print("Frame is None")
break
# When everything done, release the capture
vcap.release()
cv2.destroyAllWindows()
print("Video stop")
关于python - Boto3 Kinesis Video GetMedia 和 OpenCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50061634/
我有一个带有 2 个分片的 kinesis 流,如下所示: { "StreamDescription": { "StreamStatus": "ACTIVE",
我们可以从单个 Kinesis Firehose 获得多个目的地吗?我看到了这张图片 由此看来,可以从单个 Firehose 添加 s3、红移和 Elasticsearch 。我正是想这样做。 但是当
我正在尝试在流级别收集 Kinesis 的指标,更具体地说,我想获得工作进程/消费者进程在流级别落后的计数,我不关心分片级别的滞后.我在 AWS 文档上找到了一个计算消耗滞后的示例,但它计算的是滞后时
是否可以定义一个具有滑动间隔的窗口?例如。我需要每 10 秒计算过去 30 秒的总和吗? Kinesis Analytics SQL 是否支持此类具有重叠的滑动窗口? 最佳答案 我认为跳窗代表你的需求
我想将来自 AWS Kinesis 流的消息处理延迟一小时。我已将 KCL 使用者配置为每四分钟读取一批记录,检查每条记录的时间戳,并在任何记录不到一小时的情况下停止处理该批处理,没有检查点。我希望同
将分片拆分为 2 个子分片时,父分片将关闭。当发生这种情况时,期望记录处理器(此处使用 KCL)将检查点,如以下 KCL 源代码所示: try { recordProc
在生产者-消费者 Web 应用程序中,为 kinesis 流分片创建分区键的思考过程应该是什么。 假设,我有一个包含 16 个分片的 kinesis 流,我应该创建多少个分区键?它真的取决于分片的数量
有没有办法创建具有缓冲区限制的 Kinesis 使用者?赞 here : #Flush when buffer exceeds 100000 Amazon Kinesis records, 64 MB
他们似乎对我做同样的事情。任何人都可以向我解释其中的区别吗? 最佳答案 两者的高层次区别: 运动流 允许您生成和使用大量数据(日志、Web 数据等),其中 DynamoDB 流 是 DynamoDB
从文档中可以清楚地看出,当以 TRIM_HORIZON 作为迭代器类型启动 KCL 应用程序时,将从流的开头读取记录。文档还提到应用程序的状态是通过使用检查点在 DynamoDB 表中维护的。 但是我
我的问题 我有一个日志管道,其中使用 Filebeat 将日志写入文件并发送到 ElasticSearch。 .我想从 ElasticSearch 切换到 AWS Kinesis,我想知道为新输出配置
我正在尝试通过 Amazon Kinesis 抽取大量数据(每秒订购 10,000 个点)。 为了通过我的分片最大限度地提高每秒记录数,我想通过分片循环我的请求(我的应用程序逻辑不关心分片单个消息去哪
无法打开与monitoring.us-east-1.amazonaws.com:443的连接:连接到AWS kinesis时证书验证失败 public static KinesisProducer g
我正在将 Java API 用于 Kinesis Firehose,并在可能的情况下利用 putRecordBatch()。但是,在我的应用程序中,我偶尔只发送一条记录,无法等待更多记录或将其缓存在内
添加时aws-xray-recorder-sdk-aws-sdk-instrumentor KCL 提出 SegmentNotFoundException . 据我所知,这是因为 KCL 正在启动他们
我正在研究与移动分析相关的 AWS 服务,因为我们使用 AWS 作为我们的后端基础设施,现在想了解如何最好地利用 Pinpoint 和/或 Kinesis 以最终将事件存储在 S3 中以供以后分析。
Kinesis Firehose 以及 Kinesis Streams 用于根据 AWS 博客中提到的详细信息加载流数据。对于 Firehose,没有分片或维护的概念。在这种情况下,Kinesis F
Firehose 是完全托管的,而 Streams 是手动管理的。 如果其他人知道其他主要差异,请添加它们。我只是在学习。 谢谢.. 最佳答案 Amazon Kinesis Data Firehose
我正在做一个点击跟踪项目,我正在使用 Snowplow (开源)为此。我正在使用 Scala 扫雪机收集器来收集数据并将其路由到 Amazon Kinesis。但是,当我使用此配置启动它时: coll
我正在尝试发送 HTTP Post 请求以将记录放入 Amazon Kinesis Stream。有多种方法(Kinesis 客户端、KPL、将 AWS 网关设置为 Kinesis 代理)。 我看到了
我是一名优秀的程序员,十分优秀!