Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

333
Views
Boto3 Kinesis Vídeo GetMedia y OpenCV

Estoy tratando de usar Boto3 para obtener una transmisión de video de Kinesis y luego usar OpenCV para mostrar la transmisión y guardarla en un archivo al mismo tiempo.

El proceso de obtener la URL firmada y luego la solicitud de Getmedia parece funcionar perfectamente, pero cuando intento renderizarlo con OpenCV, parece que no funciona.

Los datos van desafiantemente a la corriente

 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()
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para finalmente responder a esto, encontré una solución básica utilizando la salida HLS disponible en las transmisiones de video de Kineses. Que estuvo disponible JUL 2018

Publicación de blog: https://aws.amazon.com/blogs/aws/amazon-kinesis-video-streams-adds-support-for-hls-output-streams/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+AmazonWebServicesBlog+% 28Amazon+Servicios+Web+Blog%29

He pegado la versión de trabajo de mi código a continuación.

Estoy usando variables ENV de AWS para la autenticación 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")
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!