video_producer.py 430 Bytes
from kafka import KafkaProducer
import cv2


topic = "testing"  # 구독할 topic
producer = KafkaProducer(bootstrap_servers='')  # kafka 부트스트랩 서버 입력

video_file = ""  # 입력 파일
video = cv2.VideoCapture(video_file)

while video.isOpened():
    success, frame = video.read()
    if not success:
        break
    _, img = cv2.imencode('.jpg', frame)

    producer.send(topic, img.tobytes())

video.release()