-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProducer.py
executable file
·42 lines (33 loc) · 1.19 KB
/
Producer.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
42
import argparse
from streaming import VideoProducer
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--topic",
type=str,
required=True,
help="The Topic Name.")
parser.add_argument("-c", "--camera",
type=str,
required=False,
help="Path to the camera demo video.")
parser.add_argument("-i", "--interval",
type=float,
default=-1,
help="The delay between each image (in second). "
"If not specified, default to the video FPS "
"(12 FPS for image folder)")
args = parser.parse_args()
return args
def main():
"""
Producer will publish to Kafka Server a video file given as a system arg.
Otherwise it will default by streaming webcam feed.
"""
args = vars(parse_args())
camera = args['camera']
topic = args['topic']
interval = args['interval']
producer = VideoProducer(topic, interval)
producer.publish_video(camera)
if __name__ == '__main__':
main()