veld

package module
v0.0.0-...-3a72003 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 12 Imported by: 0

README

Veld Logo

Veld - HLS & DASH Video Downloader

The fastest open-source streaming video downloader for HLS and DASH

Release Go Version License Stars

InstallationQuick StartFeaturesTrack SelectionLibrary Usage


What is Veld?

Veld is a high-performance command-line tool and Go library for downloading HLS (m3u8) and DASH (mpd) video streams. Whether you're archiving live streams, downloading VOD content, or building video applications, Veld makes it fast and easy.

Why Choose Veld?

Feature Veld yt-dlp N_m3u8DL-RE
Concurrent downloads ✅ 128 threads
Resume interrupted downloads
Interactive track picker
Rate limiting
Go library API
Memory efficient (disk-based)
HLS AES-128 decryption
DASH CENC decryption

🚀 Installation

Download Binary

Grab the latest release for your platform:

# Linux
curl -L https://github.com/mohaanymo/veld/releases/latest/download/veld-linux-amd64 -o veld
chmod +x veld
sudo mv veld /usr/local/bin/

# macOS
brew install mohaanymo/tap/veld

# Windows
# Download veld.exe from Releases page

Install with Go

go install github.com/mohaanymo/veld/cmd/veld@latest

Build from Source

git clone https://github.com/mohaanymo/veld.git
cd veld
go build -o veld ./cmd/veld

⚡ Quick Start

Download a Video (Interactive)

veld -u "https://example.com/video.m3u8"

This opens an interactive picker to choose video quality, audio tracks, and subtitles.

Download Best Quality Automatically

veld -u "https://example.com/video.m3u8" -s best -fn movie.mp4

Download with Limited Bandwidth

veld -u "https://example.com/video.m3u8" -s best --max-bandwidth 2M

✨ Features

🎯 Smart Track Selection

Veld has the most powerful track selector of any streaming downloader:

# Resolution ranges
veld -u URL -s "720p-1080p"           # Between 720p and 1080p
veld -u URL -s "-720p"                # Best up to 720p

# Multiple audio languages
veld -u URL -s "v:best + a:en,es,fr"  # Video + 3 audio tracks

# Bandwidth filtering
veld -u URL -s "a:[128k-256k]"        # Audio 128-256 kbps

# Modifiers
veld -u URL -s "s:en!"                # English subs (required, fail if missing)
veld -u URL -s "a:?*"                 # All audio including undefined language

💾 Resume Downloads

Downloads automatically resume if interrupted:

veld -u "https://example.com/video.m3u8" -s best
# Downloads 60%... connection drops

veld -u "https://example.com/video.m3u8" -s best
# ✓ Resuming: skipped 180/300 segments

🔐 Encrypted Streams

# HLS with AES-128 (key auto-fetched from manifest)
veld -u "https://example.com/encrypted.m3u8" -s best

# DASH with CENC (provide key manually)
veld -u "https://example.com/drm.mpd" -s best --key "KID:KEY"

🎨 Beautiful Terminal UI

Terminal UI


📖 Track Selection

Basic Selectors

Selector Description
best Best video + best audio
all All tracks
1080p 720p 480p By resolution
4k hd sd Quality presets

Advanced Selectors

Selector Description
v:best + a:en + s:en Video + English audio + English subs
v:-1080p Best video up to 1080p
a:en,es,fr* All English, Spanish, French audio
v:0 + a:1 By index (first video, second audio)
a:[>128k] Audio above 128kbps

Modifiers

Modifier Meaning
! Required (fail if not found)
? Include undefined/unknown language
* Select all matching tracks

📚 Library Usage

Use Veld as a Go library in your applications:

package main

import (
    "context"
    "log"
    
    "github.com/mohaanymo/veld"
)

func main() {
    d, err := veld.New(
        veld.WithURL("https://example.com/video.m3u8"),
        veld.WithFileName("output.mp4"),
        veld.WithTrackSelector("best"),
        veld.WithMaxBandwidth(5*1024*1024), // 5 MB/s limit
    )
    if err != nil {
        log.Fatal(err)
    }
    defer d.Close()

    ctx := context.Background()
    
    // Parse manifest
    if err := d.Parse(ctx); err != nil {
        log.Fatal(err)
    }
    
    // Select tracks
    if err := d.SelectTracks(); err != nil {
        log.Fatal(err)
    }
    
    // Download
    if err := d.Download(ctx); err != nil {
        log.Fatal(err)
    }
}

Available Options

veld.WithURL(url string)                    // Stream URL (required)
veld.WithFileName(name string)              // Output filename
veld.WithOutputDir(dir string)              // Output directory
veld.WithFormat(fmt string)                 // mp4, mkv, ts
veld.WithThreads(n int)                     // Concurrent downloads (1-128)
veld.WithTrackSelector(sel string)          // Track selection expression
veld.WithHeaders(h map[string]string)       // Custom HTTP headers
veld.WithDecryptionKeys(keys []string)      // KID:KEY pairs
veld.WithMaxBandwidth(bps int64)            // Rate limit in bytes/sec
veld.WithVerbose(v bool)                    // Enable verbose logging

⚙️ CLI Reference

veld - High-performance HLS/DASH video downloader

Usage: veld [options] -u <URL>

Options:
  -u, --url <URL>           Stream URL (m3u8 or mpd) [required]
  -fn, --filename <name>    Output filename
  -n, --threads <num>       Concurrent downloads (default: 16, max: 128)
  -s, --select-track <sel>  Track selection (omit for interactive picker)
  -P, --parallel-tracks     Download all tracks in parallel
  -f, --format <fmt>        Output format: mp4, mkv, ts (default: mp4)
  -H, --header <header>     Custom HTTP header (can repeat)
      --cookie <cookies>    Cookies for authenticated requests
      --key <KID:KEY>       Decryption key(s), comma-separated
      --muxer <backend>     Muxer: auto, ffmpeg, binary (default: auto)
      --no-progress         Disable TUI, output to stdout
  -v, --verbose             Verbose output
      --version             Show version

🔧 Requirements

  • FFmpeg (optional but recommended) - Required for muxing to MP4/MKV with multiple tracks

📈 Performance

Veld is optimized for maximum throughput:

  • ✅ HTTP/2 multiplexing
  • ✅ Connection pooling (100+ connections per host)
  • ✅ Disk-based segment storage (low memory usage)
  • ✅ Concurrent track downloads

Typical speeds on a 100 Mbps connection:

File Size Time
500 MB ~40s
1 GB ~80s
5 GB ~7 min

🤝 Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

📄 License

MIT License - see LICENSE for details.


Veld - Fast. Resumable. Beautiful.
Made with ❤️ in Go


🏷️ Keywords

hls-downloader dash-downloader m3u8-downloader mpd-downloader video-downloader streaming-downloader go golang cli terminal ffmpeg media-downloader vod-downloader live-stream-downloader concurrent-downloader resumable-downloads

Documentation

Overview

Package veld provides a high-performance HLS/DASH media downloader.

Basic usage:

d, err := veld.New(
	veld.WithURL("https://example.com/video.m3u8"),
	veld.WithOutput("video.mp4"),
)
if err != nil {
	log.Fatal(err)
}
defer d.Close()

if err := d.Parse(ctx); err != nil {
	log.Fatal(err)
}
if err := d.SelectTracks(); err != nil {
	log.Fatal(err)
}
if err := d.Download(ctx); err != nil {
	log.Fatal(err)
}

Or use the convenience function:

err := veld.DownloadURL(ctx, "https://example.com/video.m3u8", "video.mp4")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadURL

func DownloadURL(ctx context.Context, url, filename string, opts ...Option) error

DownloadURL is a convenience function for simple downloads. It parses the manifest, selects tracks (using "best" or configured selector), and downloads to the specified output path.

Types

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

Downloader is the main API for downloading media streams.

func New

func New(opts ...Option) (*Downloader, error)

New creates a new Downloader with the given options.

func (*Downloader) Close

func (d *Downloader) Close() error

Close releases all resources held by the downloader. Always call Close() when done, preferably with defer.

func (*Downloader) Download

func (d *Downloader) Download(ctx context.Context) error

Download starts the download process. Blocks until complete or context is canceled.

func (*Downloader) ManifestType

func (d *Downloader) ManifestType() string

ManifestType returns the type of manifest ("HLS" or "DASH"). Returns empty string if Parse() hasn't been called.

func (*Downloader) Parse

func (d *Downloader) Parse(ctx context.Context) error

Parse fetches and parses the manifest from the configured URL. Must be called before Tracks(), SelectTracks(), or Download().

func (*Downloader) Progress

func (d *Downloader) Progress() <-chan ProgressUpdate

Progress returns a channel for receiving download progress updates. The channel is closed when the download completes.

func (*Downloader) SelectTracks

func (d *Downloader) SelectTracks() error

SelectTracks selects tracks based on the configured selector. If no selector was configured, uses "best" (best video + best audio).

func (*Downloader) SelectedTracks

func (d *Downloader) SelectedTracks() []*Track

SelectedTracks returns the currently selected tracks.

func (*Downloader) SetSelectedTracks

func (d *Downloader) SetSelectedTracks(tracks []*Track)

SetSelectedTracks allows manual track selection. Pass tracks obtained from Tracks().

func (*Downloader) Tracks

func (d *Downloader) Tracks() []*Track

Tracks returns all available tracks after parsing. Returns nil if Parse() hasn't been called.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles queued downloads with concurrency control.

func NewManager

func NewManager(opts ...ManagerOption) *Manager

NewManager creates a new download manager.

func (*Manager) AddTask

func (m *Manager) AddTask(id, url, filename string, opts ...Option) (*Task, error)

AddTask adds a new download task to the queue.

func (*Manager) CancelTask

func (m *Manager) CancelTask(id string) error

CancelTask cancels a specific task.

func (*Manager) GetActiveTasks

func (m *Manager) GetActiveTasks() []*Task

GetActiveTasks returns currently downloading tasks.

func (*Manager) GetAllTasks

func (m *Manager) GetAllTasks() []*Task

GetAllTasks returns all tasks in order.

func (*Manager) GetPendingCount

func (m *Manager) GetPendingCount() int

GetPendingCount returns the number of pending tasks.

func (*Manager) GetTask

func (m *Manager) GetTask(id string) *Task

GetTask returns a task by ID.

func (*Manager) RemoveTask

func (m *Manager) RemoveTask(id string) error

RemoveTask removes a completed/failed/canceled task.

func (*Manager) Start

func (m *Manager) Start()

Start begins processing the download queue.

func (*Manager) Stats

func (m *Manager) Stats() ManagerStats

Stats returns current manager statistics.

func (*Manager) Stop

func (m *Manager) Stop()

Stop gracefully stops the manager and waits for active downloads.

func (*Manager) WaitAll

func (m *Manager) WaitAll()

WaitAll blocks until all tasks complete.

func (*Manager) WaitForTask

func (m *Manager) WaitForTask(id string) error

WaitForTask blocks until a specific task completes.

type ManagerOption

type ManagerOption func(*Manager)

ManagerOption configures the Manager.

func WithDefaultOptions

func WithDefaultOptions(opts ...Option) ManagerOption

WithDefaultOptions sets default options applied to all tasks.

func WithMaxConcurrent

func WithMaxConcurrent(n int) ManagerOption

WithMaxConcurrent sets the maximum number of concurrent downloads.

func WithOnComplete

func WithOnComplete(fn func(task *Task)) ManagerOption

WithOnComplete sets a callback for task completion.

func WithOnError

func WithOnError(fn func(task *Task, err error)) ManagerOption

WithOnError sets a callback for task errors.

func WithOnProgress

func WithOnProgress(fn func(task *Task)) ManagerOption

WithOnProgress sets a callback for progress updates.

func WithOnStateChange

func WithOnStateChange(fn func(task *Task)) ManagerOption

WithOnStateChange sets a callback for task state changes.

func WithTitle

func WithTitle(t string) ManagerOption

WithTitle sets the dowmloader manger title.

type ManagerStats

type ManagerStats struct {
	Total     int
	Pending   int
	Active    int
	Completed int
	Failed    int
	Canceled  int
}

ManagerStats holds manager statistics.

type ManagerUI

type ManagerUI struct {
	// contains filtered or unexported fields
}

ManagerUI provides a beautiful terminal UI for the download manager.

func NewManagerUI

func NewManagerUI(manager *Manager) *ManagerUI

NewManagerUI creates a new manager UI.

func (*ManagerUI) Refresh

func (ui *ManagerUI) Refresh()

Refresh forces a UI refresh.

func (*ManagerUI) Run

func (ui *ManagerUI) Run() error

Run starts the TUI and blocks until it exits.

type Option

type Option func(*config.Config)

Option configures the downloader.

func WithCookies

func WithCookies(cookies string) Option

WithCookies sets cookies for HTTP requests.

func WithDecryptionKeys

func WithDecryptionKeys(keys []string) Option

WithDecryptionKey sets the decryption key in "KID:KEY" format (32 hex chars each).

func WithDir

func WithDir(dir string) Option

WithDir sets the directory path.

func WithFileName

func WithFileName(filename string) Option

WithOutput sets the output file path.

func WithFormat

func WithFormat(format string) Option

WithFormat sets the output format: "mp4", "mkv", or "ts" (default: "mp4").

func WithHeader

func WithHeader(key, value string) Option

WithHeader adds a single HTTP header.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders sets custom HTTP headers for requests.

func WithMaxBandwidth

func WithMaxBandwidth(bytesPerSec int64) Option

WithMaxBandwidth sets maximum download speed in bytes per second. Set to 0 for unlimited (default).

func WithParallelTracks

func WithParallelTracks(parallel bool) Option

WithParallelTracks enables downloading all tracks concurrently.

func WithThreads

func WithThreads(n int) Option

WithThreads sets the number of concurrent download threads (default: 16, max: 128).

func WithTrackSelector

func WithTrackSelector(selector string) Option

WithTrackSelector sets the track selection string. Examples: "best", "1080p", "720p", "all", "video:0+audio:1"

func WithURL

func WithURL(url string) Option

WithURL sets the stream URL (required).

func WithVerbose

func WithVerbose(verbose bool) Option

WithVerbose enables verbose logging.

type ProgressUpdate

type ProgressUpdate struct {
	// SegmentIndex is the index of the segment that was processed.
	SegmentIndex int

	// TrackID is the ID of the track this segment belongs to.
	TrackID string

	// BytesLoaded is the number of bytes downloaded for this segment.
	BytesLoaded int64

	// Completed is true if the segment was successfully downloaded.
	Completed bool

	// Error is non-nil if the segment download failed.
	Error error
}

ProgressUpdate represents a download progress update.

type Task

type Task struct {
	ID             string
	URL            string
	FileName       string
	Options        []Option
	State          TaskState
	Error          error
	Progress       TaskProgress
	CreatedAt      time.Time
	StartedAt      time.Time
	CompletedAt    time.Time
	Tracks         []*Track
	SelectedTracks []*Track
	// contains filtered or unexported fields
}

Task represents a download task in the queue.

type TaskProgress

type TaskProgress struct {
	TotalSegments     int
	CompletedSegments int
	TotalBytes        int64
	DownloadedBytes   int64
	Speed             float64 // bytes per second
	ETA               time.Duration
	CurrentTrack      string
}

TaskProgress holds progress information for a task.

func (TaskProgress) Percent

func (p TaskProgress) Percent() float64

Percent returns the download progress as a percentage.

type TaskState

type TaskState int

TaskState represents the current state of a download task.

const (
	TaskPending TaskState = iota
	TaskParsing
	TaskDownloading
	TaskMuxing
	TaskCompleted
	TaskFailed
	TaskCanceled
)

func (TaskState) String

func (s TaskState) String() string

type Track

type Track struct {
	// contains filtered or unexported fields
}

Track represents a media track (video, audio, or subtitle).

func (*Track) Bandwidth

func (t *Track) Bandwidth() int64

Bandwidth returns the track's bandwidth in bits per second.

func (*Track) Codec

func (t *Track) Codec() string

Codec returns the track's codec string (e.g., "avc1.64001f", "mp4a.40.2").

func (*Track) Height

func (t *Track) Height() int

Height returns the video height in pixels (0 for non-video tracks).

func (*Track) ID

func (t *Track) ID() string

ID returns the track's unique identifier.

func (*Track) IsAudio

func (t *Track) IsAudio() bool

IsAudio returns true if this is an audio track.

func (*Track) IsEncrypted

func (t *Track) IsEncrypted() bool

IsEncrypted returns true if the track is encrypted.

func (*Track) IsSubtitle

func (t *Track) IsSubtitle() bool

IsSubtitle returns true if this is a subtitle track.

func (*Track) IsVideo

func (t *Track) IsVideo() bool

IsVideo returns true if this is a video track.

func (*Track) Language

func (t *Track) Language() string

Language returns the track's language code (e.g., "en", "es").

func (*Track) Name

func (t *Track) Name() string

Name returns the track's name/label.

func (*Track) QualityLabel

func (t *Track) QualityLabel() string

QualityLabel returns a human-readable quality label (e.g., "1080p", "720p", "4K").

func (*Track) Resolution

func (t *Track) Resolution() string

Resolution returns the resolution as "WxH" string (empty for non-video).

func (*Track) SegmentCount

func (t *Track) SegmentCount() int

SegmentCount returns the number of segments in this track.

func (*Track) Type

func (t *Track) Type() TrackType

Type returns the track type (video, audio, or subtitle).

func (*Track) Width

func (t *Track) Width() int

Width returns the video width in pixels (0 for non-video tracks).

type TrackType

type TrackType int

TrackType represents the type of media track.

func (TrackType) String

func (t TrackType) String() string

Directories

Path Synopsis
cmd
selector_test command
veld command
internal
config
Package config provides configuration types for the downloader.
Package config provides configuration types for the downloader.
decryptor
Package decryptor handles decryption of encrypted DASH segments.
Package decryptor handles decryption of encrypted DASH segments.
engine
Package engine provides the high-performance download engine.
Package engine provides the high-performance download engine.
httpclient
Package httpclient provides a shared, optimized HTTP client for veld.
Package httpclient provides a shared, optimized HTTP client for veld.
models
Package models defines core data structures for media streams.
Package models defines core data structures for media streams.
parser
Package parser provides manifest parsing for HLS and DASH streams.
Package parser provides manifest parsing for HLS and DASH streams.
tui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL