A simple script to convert MP4 files into multi-bitrate HLS format with adaptive streaming. The script processes multiple videos in the current directory, creates individual folders for each video, and organizes resolution-specific playlists into separate subfolders. It supports Windows (Batch script) and Linux (Shell script).
- Automatically detects
.mp4
files in the current directory. - Creates a dedicated folder for each video with resolution-specific subfolders:
title/ ├── master.m3u8 ├── 540p/ │ └── playlist_540p.m3u8 ├── 720p/ │ └── playlist_720p.m3u8 ├── 1080p/ └── playlist_1080p.m3u8
- Supports resolutions: 1080p, 720p, and 540p.
- Generates adaptive HLS playlists with a master playlist (
master.m3u8
).
- Install FFmpeg:
- Download FFmpeg from the official website.
- Extract the files and add the
bin
folder to your system'sPATH
.
- Place the
convert_to_hls.bat
script in the directory containing your.mp4
files.
- Install FFmpeg:
- Use the package manager to install FFmpeg:
sudo apt update sudo apt install ffmpeg
- Use the package manager to install FFmpeg:
- Place the
convert_to_hls.sh
script in the directory containing your.mp4
files.
- Save the
convert_to_hls.bat
script in the folder containing.mp4
files. - Double-click the
convert_to_hls.bat
script. - HLS files will be generated in individual folders, each named after the video.
- Save the
convert_to_hls.sh
script in the folder containing.mp4
files. - Make the script executable:
chmod +x convert_to_hls.sh
- Run the script:
./convert_to_hls.sh
- HLS files will be generated in individual folders, each named after the video.
For a file named Video_001.mp4
, the output directory will look like this:
Video_001/
├── master.m3u8
├── 540p/
│ └── playlist_540p.m3u8
├── 720p/
│ └── playlist_720p.m3u8
└── 1080p/
└── playlist_1080p.m3u8
- Windows: Uses a Batch script (
convert_to_hls.bat
). - Linux: Uses a Shell script (
convert_to_hls.sh
).
This script was created by Sunil Prasad Regmi. It leverages FFmpeg, a powerful open-source tool for multimedia processing. Special thanks to the open-source community for their contributions to FFmpeg and adaptive streaming solutions.
This project is licensed under the MIT License.