Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

337
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda