-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvideo-stream-helper.py
41 lines (34 loc) · 1.47 KB
/
video-stream-helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import boto3, botocore, argparse, sys, json
parser = argparse.ArgumentParser(description='create video stream')
parser.add_argument('-c', '--create', action='store_true', help='create video stream for vidoe face rek')
parser.add_argument('-d', '--delete', action='store_true', help='delete video stream for vidoe face rek')
def createVideoStream(kinesisVideoStreamName):
try:
respone = client.create_stream(StreamName=kinesisVideoStreamName)
print respone
except botocore.exceptions.ClientError as e:
print "Error: {0}".format(e)
def deleteVideoStream(kinesisVideoStreamName):
stsClient = session.client('sts')
accountID = stsClient.get_caller_identity()["Account"]
# Get KinesisVideoStream Arn
kinesisVideoStreamArn = client.describe_stream(StreamName=kinesisVideoStreamName)['StreamInfo']['StreamARN']
response = client.delete_stream(
StreamARN=kinesisVideoStreamArn
)
print response
if __name__ == '__main__':
if len(sys.argv)==1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
with open('config.json') as json_data_file:
config = json.load(json_data_file)
region = config['region']
kinesisVideoStreamName = config['kinesisVideoStreamName']
session = boto3.Session()
client = session.client('kinesisvideo', region_name=region)
if (args.create):
createVideoStream(kinesisVideoStreamName)
elif (args.delete):
deleteVideoStream(kinesisVideoStreamName)