【问题标题】:how to get an image from the url video (stored on s3 bucket)如何从 url 视频中获取图像(存储在 s3 存储桶中)
【发布时间】:2018-03-20 03:46:51
【问题描述】:

我想从存储在 s3 存储桶中的 url 视频中获取图像。 我试图用 cv2.VideoCapture 来做,但它只适用于静态文件。 如果有人可以帮助我

【问题讨论】:

标签: python image url video amazon-s3


【解决方案1】:

我认为为时已晚,但我正在为其他面临同样问题的人写这篇文章,因为我正在尝试但找不到任何解决方案。

所以您必须设置指向您的 S3 存储桶的 amazon cloudfront 下载分发(如果不知道如何设置,请参阅here),然后只需使用 http 访问(不是 https,不知道为什么它不使用 https 或直接通过 s3 url)。

只需将 cloudfront url 设置为:

cv2.VideoCapture('http://xyz.cloudfront.net/myvideo.mp4')

现在它可以正常工作了。

【讨论】:

    【解决方案2】:

    可以使用用于 S3 对象的 presigned url

    url = s3_client.generate_presigned_url( ClientMethod='get_object', Params={ 'Bucket': bucket, 'Key': key } )

    vidcap = cv2.VideoCapture(url)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 1970-01-01
      • 2020-07-02
      • 2019-11-29
      • 2020-11-10
      • 1970-01-01
      相关资源
      最近更新 更多