A simple Node.js utility to download and join Transport Stream (TS) video files from an M3U8 playlist. This tool downloads individual TS segments and combines them into a single file using FFmpeg.
Warning
This project is intended for educational purposes only. Ensure you have the right to download and use the content from the M3U8 playlist.
- Downloads TS segments from an M3U8 playlist
- Handles both HTTP and HTTPS URLs
- Parallel downloading with concurrency control
- Automatic cleanup after processing
- TLS bypass for self-signed certificates
- Download from FFmpeg official website or install using Chocolatey:
choco install ffmpeg
brew install ffmpeg
sudo apt update
sudo apt install ffmpeg
ts-joiner/
├── index.js # Main script
├── playlist.m3u8 # M3U8 playlist file (must be updated)
├── ts-files/ # Temporary folder for downloaded segments
└── ts-videos/ # Output folder for joined TS files
- Update the
playlist.m3u8
file with your TS segment URLs - Open
index.js
and set thebaseUrl
variable to your base URL (if segments use relative paths) - Run the script:
node index.js
The joined video file will be saved to ./ts-videos/
with a unique filename
- The script parses the M3U8 playlist file to extract TS segment URLs
- It downloads each segment in parallel (with a concurrency limit of 10)
- It creates a filelist for FFmpeg
- FFmpeg joins all segments into a single TS file
- The script moves the joined file to the output directory
- Temporary files are cleaned up automatically
This project uses standard Node.js libraries with no external dependencies:
fs
- File system operationshttps/http
- Network requestschild_process
- For executing FFmpegpath
- Path manipulationurl
- URL resolution
To modify the concurrency limit, change the CONCURRENCY_LIMIT
constant in index.js
.