flask - 可以在 javafx 内的 web 视图中播放 multipart/x-mixed-replace 流吗?
问题描述
我正在使用 Flask 服务器将视频从网络摄像头流式传输到 Java 客户端这是 Flask 实现:
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")
我有一个 javafx webview 屏幕,但它没有显示任何内容。是因为 Webview 不支持 multipart/x-mixed-replace 吗?这有什么解决办法?有没有其他选择可以将 python 视频流放到 JavaFX 应用程序上?
解决方案
推荐阅读
- python - 如何在不一次加载整个数据集的情况下将数据集拆分为 K 折叠?
- date - GNU 日期如何解析年份的最后两位数字?
- javascript - 异步函数不会等到在 nodejs/javascript 中执行调用的异步函数
- python - 无法标记整列
- slurm - concurrent.futures.ProcessPoolExecutor 不适用于 Slurm
- node.js - fs_promises_readdir 是异步函数吗?
- r - RMarkdown 中的连字符
- java - Android GreenDao 如何获取不区分大小写的搜索
- flutter - Flutter CustomScrollView中Stepper上方的空白
- sql - Oracle:从字符串中删除某些字符