This is a web service that streams a video file as an MJPEG stream.
The service has a REST interface and takes a video file name as arequired parameter (--video="video.mp4" or -v="video.mp4"), when it is started from terminal. If the parameter is not provided, or the file specified cannot be opened (it does not exist, the app does not have sufficient permissions, etc.), an error image is shown.
Also, to show the video with an appropriate speed, a framerate parameter can be passed (--framerate=10 or -f=10). It has the defaul tvalue of 30 frames per second, and limited to MIN_FRAMERATE <= framerate <= MAX_FRAMERATE - constants that are defined in the apllication code.
To remove any pauses between frames, simply comment the line with the sleep function call:
# sleep(pause_between_frames)Before starting the service, dependencies should be installed. The best way is to create a virtual environment (with Python 3.6+), activate it and run dependencies installation process:
% pip install -r requirements.txt Typical usage example:
% python streaming_app.py --video="double_decker_video.mp4"or
% python streaming_app.py -v="double_decker_video.mp4"Typical usage example with the framerate parameter specified:
% python streaming_app.py --video="double_decker_video.mp4" --framerate=10To see the streaming, open https://127.0.0.1:5000/ in a browser that supports MJPEG playback.