dimanche 21 juin 2020

How to import a video that is being saved as a videowriter from html

Now, using two threads, one is using the thread to save the video on the webcam as a file, and the other is passing the file on to the html and showing it on the web as html. I don't know much about the web, but I'd like to pass the video variable that is being saved as a radar_template by flask and receive it from html to url_for and print it out. But the video is not being printed.

Python code for storing videos.

fourcc = VideoWriter_fourcc(*'H264')
out = VideoWriter('/content/drive/My Drive/Colab Notebooks/MRCNN_pure/static/image/output.mp4', fourcc, 13.0, (1280, 720))

_lock = threading.Lock()

def webcam(capture):
  while True:
    frame_pos = capture.get(cv2.CAP_PROP_POS_FRAMES)
    frame_count = capture.get(cv2.CAP_PROP_FRAME_COUNT)

    grabbed, frame = capture.read()
    if not grabbed:
      print ("Not grabbed.")
      break;

    if grabbed:
      _lock.acquire()
      out.write(frame)
      _lock.release()

The following is a flask execution code that passes it to the render_template.

app = Flask(__name__)
run_with_ngrok(app)

@app.route("/")
def home()-> 'html':
  return render_template('test.html', output = "image/output.mp4")

if __name__ == "__main__":
  app.run()

Next is the html file.

<body>
    <h1>HTML5 오픈 커뮤니티</h1>
    <p>이 자료는 <a href="http://www.htmlfive.co.kr">HTML5 오픈 커뮤니티</a>에서 배포합니다.</p>

    
</body>

I can turn over another complete video file and print it on the web, but I can't print the video I'm saving. Is there a good way?




Aucun commentaire:

Enregistrer un commentaire