producer/producer.py
def publish_video(producer, frameDetails):
    """
    Publish given video file to a specified Kafka topic.
    Kafka Server is expected to be running on the localhost. Not partitioned.

    """
    # Open file
    video = cv2.VideoCapture(frameDetails.url)

    print("publishing media stream %s " % (frameDetails.url))

    frame_sample = frameDetails.frameRate

    count = 1
    while video.isOpened():
        while count % frame_sample != 0:
            count += 1
            success, frame = video.read()

        count += 1

        # Ensure file was read successfully
        if not success:
            print("bad read!")
            break

        # Convert image to png
        ret, buffer = cv2.imencode(".jpg", frame)
        frameDetails.setFrame(count, buffer.tobytes())

        # Convert to bytes and send to kafka
        producer.send(frameDetails.topic, frameDetails)

    #        time.sleep(0.2)

    video.release()
    print("publish complete")

    Publish given video file to a specified Kafka topic.
    Kafka Server is expected to be running on the localhost. Not partitioned.

    
Publish given video file to a specified Kafka topic.
Kafka Server is expected to be running on the localhost. Not partitioned.
Publish given video file to a specified Kafka topic . Kafka Server is expected to be running on the localhost . Not partitioned .
def publish_video(producer, frameDetails):
    video = cv2.VideoCapture(frameDetails.url)
    print("publishing media stream %s " % (frameDetails.url))
    frame_sample = frameDetails.frameRate
    count = 1
    while video.isOpened():
        while count % frame_sample != 0:
            count += 1
            success, frame = video.read()
        count += 1
        if not success:
            print("bad read!")
            break
        ret, buffer = cv2.imencode(".jpg", frame)
        frameDetails.setFrame(count, buffer.tobytes())
        producer.send(frameDetails.topic, frameDetails)
    video.release()
    print("publish complete")
def publish_video ( producer , frameDetails ) : video = cv2 . VideoCapture ( frameDetails . url ) print ( "publishing media stream %s " % ( frameDetails . url ) ) frame_sample = frameDetails . frameRate count = 1 while video . isOpened ( ) : while count % frame_sample != 0 : count += 1 success , frame = video . read ( ) count += 1 if not success : print ( "bad read!" ) break ret , buffer = cv2 . imencode ( ".jpg" , frame ) frameDetails . setFrame ( count , buffer . tobytes ( ) ) producer . send ( frameDetails . topic , frameDetails ) video . release ( ) print ( "publish complete" )
Publish given video file to a specified Kafka topic.
Publish given video file to a specified Kafka topic .
"""
    Publish given video file to a specified Kafka topic.
    Kafka Server is expected to be running on the localhost. Not partitioned.

    """ # Open file # Ensure file was read successfully # Convert image to png # Convert to bytes and send to kafka #        time.sleep(0.2)
producer
frameDetails