Python 3 Script to Convert & Play Local MP4 Video as HLS Live Video Streaming in Browser






A simple tool to convert a video to a set of files to play it using HLS. HLS is an adaptive bitrate streaming protocol: the video is sliced in small chunks and made available at a variety of different bit rates. Depending on current network conditions, the player automatically selects the appropriate bitrate to download the next segment.

The script needs Python 3.6 and you can run it with --help to get more information about it.

Some browsers may not support natively HLS. In this case, one can use hls.js to get appropriate support. Many video players also support this format. See this blog post for more information.


Convert using default parameters (MPEG2-TS with many resolutions):

Add an overlay to distinguish the different resolutions:

Use fragmented MP4:

Specify more bitrates:

When using --debug, you’ll get a detailed explanation of the executed commands (and you can copy/paste them):


Leave a Reply