/FlaskHlsLiveStreamingServer

A simple python flask hls live streaming server example.

Primary LanguagePython

Flask HLS Live Streming Server

This is a simple python flask hls live streaming server example.

1. Quik Start

1.1. Cloning project

$ git clone https://github.com/CatScarf/FlaskHlsLiveStreamingServer.git

1.2. Installing FFmpeg

FFmpeg must be installed. I recommend that you use docker to install.

$ docker pull jrottenberg/ffmpeg

And make sure you can run docker run jrottenberg/ffmpeg in your terminal. If you have to use sudo docker, please add your user to the docker user group.

If you are using another docker image, please change the parameter ffmpeg to IMAGENAME/ffmpeg in the init parameter of class M3U8 in main.py. If you have installed ffmpeg without docker, please change this parameter to ffmpeg. Please note that your ffmpeg must contain the libx264 encoder. This is why I recommend that you use docker. Generally speaking installing ffmpeg without docker is a bit tricky, so I still recommend you use docker.

1.3. Installing Python Libraries

$ pip install -r requirements.txt

1.4. Running main.py

$ cd FlaskHlsLiveStreamingServer/
$ python main.py

1.5 Play live video in the player

You can directly visit the http address show in your terminal. This page uses the popular javasccript library hls.js.

You can also play the example video in a player (PotPlayer or IINA) that supports the hls protocol by entering the following address http://127.0.0.1:5000/video/playlist.m3u8. If you have an Apple device, you can also enter this address in Safari. This is because the hls protocol was developed by apple.

2. Relevant documents

HLS Live streaming documentation provided by apple