File tree Expand file tree Collapse file tree
projects/Capture_Video_Frames Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ import boto3
3+ import cv2
4+
5+ STREAM_NAME = "your_stream_name"
6+ kvs = boto3 .client ("kinesisvideo" , )
7+ # Grab the endpoint from GetDataEndpoint
8+ endpoint = kvs .get_data_endpoint (
9+ APIName = "GET_HLS_STREAMING_SESSION_URL" ,
10+ StreamName = STREAM_NAME
11+ )['DataEndpoint' ]
12+
13+ print (endpoint )
14+
15+ # # Grab the HLS Stream URL from the endpoint
16+ kvam = boto3 .client ("kinesis-video-archived-media" , endpoint_url = endpoint )
17+ url = kvam .get_hls_streaming_session_url (
18+ StreamName = STREAM_NAME ,
19+ #PlaybackMode="ON_DEMAND",
20+ PlaybackMode = "LIVE"
21+ )['HLSStreamingSessionURL' ]
22+
23+ print (url )
24+
25+ vcap = cv2 .VideoCapture (url )
26+
27+ while (True ):
28+ # Capture frame-by-frame
29+ ret , frame = vcap .read ()
30+
31+ if frame is not None :
32+ # Display the resulting frame
33+ cv2 .imshow ('frame' ,frame )
34+
35+ # Press q to close the video windows before it ends if you want
36+ if cv2 .waitKey (2 ) & 0xFF == ord ('q' ):
37+ break
38+ else :
39+ print ("Frame is None" )
40+ break
41+
42+ # When everything done, release the capture
43+ vcap .release ()
44+ cv2 .destroyAllWindows ()
45+ print ("Video stop" )
46+
You can’t perform that action at this time.
0 commit comments