boto / boto

For the latest version of boto, see https://github.com/boto/boto3 -- Python interface to Amazon Web Services

Home Page:http://docs.pythonboto.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to read image as a numpy array from a kinesis video stream

istranic opened this issue · comments

Hello,

I'm trying to read a frame from a kinesis video stream into a numpy array. The code below works well, but I'm wondering if there's a direct way to implement it without creating a temporary file. I've tried various iterations of cv.imdecode(output_bytes, 1) and PIL.Image.open(BytesIO(output_bytes)). Any help is much appreciated.

stream = video_client.get_media(
    StreamName = "ZZZZZZ",
    StartSelector={'StartSelectorType': 'NOW'}
)
streamingBody = stream['Payload']
output_bytes = streamingBody.read(50000)
# Write video to a temporary file
new_file, filename = tempfile.mkstemp()
os.write(new_file, output_bytes)
os.close(new_file)

cap = cv.VideoCapture(filename)
ret, frame = cap.read()
cap.release()
os.remove(filename)

Hi there,

This package is deprecated and no longer supported. Please review the deprecation notice for migration to boto3. Thanks!

https://github.com/boto/boto#deprecation-notice