I am using a simple opencv code to read a video file from the system.
import cv2
cap = cv2.VideoCapture("1.mp4")
while True:
res,frame = cap.imread()
cv2.imshow("frame",frame)
cv2.waitKey(1)
Now i want to stream this video feed to an HTTP server, so that it can be accessed by multiple users using the given URL.
I came across Flask but it supports only one user at time.
After going through various blogs, i came to know that FFSERVER and FFMPEG might solve the problem.Now i am stuck on how to send a frame to FFSERVER.
I run the following command..
ffmpeg -i sintel.mp4 http://localhost:8090/feed1.ffm
But i didn't send anything to the FFSERVER.
I am using the code from this blog post
Flask normally runs in single-threaded mode and can only handle one request at a time meaning that any parallel requests should wait until they can be handled.
In order to solve this problem, you only need to put
threaded=Truein your script and this will result in your application handling each request on a different thread.I attach here in the following two sample Python scripts that should do the job:
main.py
camera.py