2

I am using a flask server to stream video from a webcam to a java client Here is the Flask implementation:

def generate():
    # grab global references to the output frame and lock variables
    global outputFrame, lock

    # loop over frames from the output stream
    while True:
        # wait until the lock is acquired
        with lock:
            # check if the output frame is available, otherwise skip
            # the iteration of the loop
            if outputFrame is None:
                continue

            # encode the frame in JPEG format
            (flag, encodedImage) = cv2.imencode(".jpg", outputFrame)

            # ensure the frame was successfully encoded
            if not flag:
                continue

        # yield the output frame in the byte format
        yield(b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + 
            bytearray(encodedImage) + b'\r\n')

@app.route("/video_feed")
def video_feed():
    # return the response generated along with the specific media
    # type (mime type)
    return Response(generate(),
        mimetype = "multipart/x-mixed-replace; boundary=frame")

I have a javafx webview screen, but it doesnt show anything. Is it because Webview does not support multipart/x-mixed-replace? Whats the solution for this? Is there any other option to get a python video stream onto a JavaFX application?

Arun Baby
  • 67
  • 6
  • 1
    Have you found a response ? I try to stream a x-mixed-replace in react native – Arnold Mapps May 07 '20 at 12:27
  • @ArnoldMapps: No I had not received any responses. Thank you for reaching out. I had to serve as a webpage itself. Will I be able to embed in a JavaFX application? – Arun Baby May 08 '20 at 13:53
  • 1
    I am working with react native. For now I have add a web view who display the video but I want a best solution to display raspberry pi camera to my smartphone – Arnold Mapps May 09 '20 at 13:21
  • @ArnoldMapps: I am needed to have a high-performance solution too. Do share if you find anything similar. Much appreciated. Thanks. – Arun Baby May 10 '20 at 14:31

0 Answers0