Skip to content

dubisdev/ffmpeg-ts-downloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TS Video Downloader and Joiner

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.

🚀 Features

  • 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

⚙️ Requirements

  • Node.js (v22 or later recommended)
  • FFmpeg installed and available in your PATH

Installing FFmpeg

Windows

  1. Download from FFmpeg official website or install using Chocolatey:
choco install ffmpeg

macOS

brew install ffmpeg

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install ffmpeg

📂 Project Structure

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

🔧 Usage

  1. Update the playlist.m3u8 file with your TS segment URLs
  2. Open index.js and set the baseUrl variable to your base URL (if segments use relative paths)
  3. Run the script:
node index.js

The joined video file will be saved to ./ts-videos/ with a unique filename

💻 How it Works

  1. The script parses the M3U8 playlist file to extract TS segment URLs
  2. It downloads each segment in parallel (with a concurrency limit of 10)
  3. It creates a filelist for FFmpeg
  4. FFmpeg joins all segments into a single TS file
  5. The script moves the joined file to the output directory
  6. Temporary files are cleaned up automatically

🔍 Development

This project uses standard Node.js libraries with no external dependencies:

  • fs - File system operations
  • https/http - Network requests
  • child_process - For executing FFmpeg
  • path - Path manipulation
  • url - URL resolution

To modify the concurrency limit, change the CONCURRENCY_LIMIT constant in index.js.

📝 License

MIT © David Jimenez

About

Node JS script to download FFMPEG ts files

Topics

Resources

License

Stars

Watchers

Forks