@efinixit/video-encoder
v1.1.0
Published
Professional video encoder CLI for HLS streaming with multi-resolution support
Maintainers
Readme
EFINIX Video Encoder
╔══════════════════════════════════════════════════════════════════╗
║ ███████╗███████╗██╗███╗ ██╗██╗██╗ ██╗ ║
║ ██╔════╝██╔════╝██║████╗ ██║██║╚██╗██╔╝ ║
║ █████╗ █████╗ ██║██╔██╗ ██║██║ ╚███╔╝ ║
║ ██╔══╝ ██╔══╝ ██║██║╚██╗██║██║ ██╔██╗ ║
║ ██║ ███████╗██║██║ ╚████║██║██╔╝ ██╗ ║
║ ╚═╝ ╚══════╝╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ ║
║ ║
║ ▓▓▓▓▓ I T L A B S ▓▓▓▓▓ ║
║ ║
║ Professional Video Encoding Platform ║
║ HLS Streaming • Multi-Resolution • High Performance ║
╠══════════════════════════════════════════════════════════════════╣
║ © 2024 EFINIX IT Labs. All rights reserved. ║
║ Version 1.0.0 | Licensed under MIT ║
╚══════════════════════════════════════════════════════════════════╝Professional video encoder CLI for HLS streaming with multi-resolution support. Built by EFINIX IT Labs.
Features
- HLS Streaming: Generates standard HLS playlists compatible with all major players
- Multi-Resolution: Automatic encoding to 240p through 1080p
- Configurable Segments: Set segment duration from 2-10 seconds
- Multiple Codecs: Support for H.264, H.265 (HEVC), and VP9
- Progress Tracking: Real-time progress bars for each resolution
- Preset Control: Fine-tune encoding speed vs quality trade-offs
- Professional Output: Properly formatted master playlists with bandwidth estimation
Prerequisites
- Node.js 18 or higher
- FFmpeg 4.4 or higher (with libx264, libx265, or libvpx)
Installing FFmpeg
Ubuntu/Debian:
sudo apt update
sudo apt install ffmpegmacOS:
brew install ffmpegWindows: Download from ffmpeg.org and add to PATH.
Installation
# Install globally
npm install -g @efinixit/video-encoder
# Or use with npx (no install)
npx @efinixit/video-encoder -i video.mp4Usage
Interactive Mode (Recommended)
Run without arguments to launch the interactive wizard:
efinix-encode
# or explicitly
efinix-encode --interactiveInteractive mode guides you through:
- 📹 Video file selection - Browse recent videos or enter a path
- 📁 Output directory - Create new or select existing directory
- ⏱️ Segment duration - Choose from presets (2s, 4s, 6s, 8s, 10s) or custom
- 📐 Resolution preset - Select from predefined packages or custom multi-select
- ⚡ Encoding preset - Speed vs quality trade-off
- 🔵 Codec selection - H.264, H.265, or VP9
Basic Usage (CLI Mode)
efinix-encode -i input.mp4 -o ./outputAdvanced Options
efinix-encode \
-i input.mp4 \
-o ./encoded \
-s 6 \
-r hd \
-p medium \
-c libx264CLI Options
| Option | Short | Description | Default |
|--------|-------|-------------|---------|
| --input | -i | Input video file path (required) | - |
| --output | -o | Output directory | ./encoded |
| --segment-duration | -s | HLS segment duration (2-10 seconds) | 6 |
| --resolutions | -r | Resolution preset (all, hd, sd, mobile, minimal) | all |
| --custom-res | - | Custom resolutions (e.g., "720p,480p,360p") | - |
| --preset | -p | Encoding speed preset | medium |
| --codec | -c | Video codec (libx264, libx265, libvpx-vp9) | libx264 |
| --audio-codec | - | Audio codec (aac, mp3, opus) | aac |
| --fps | - | Target frame rate | Source |
| --threads | - | Encoding threads | Auto |
| --overwrite | - | Overwrite existing files | false |
| --no-banner | - | Suppress startup banner | false |
| --list-presets | - | Show available resolution presets | - |
| -I, --interactive | - | Run interactive mode | - |
Resolution Presets
Use --list-presets to see available options:
efinix-encode --list-presetsAvailable Presets:
| Preset | Resolutions | Use Case |
|--------|-------------|----------|
| all | 1080p, 720p, 480p, 360p, 240p | Full quality ladder |
| hd | 1080p, 720p | HD streaming only |
| sd | 480p, 360p, 240p | Standard definition |
| mobile | 480p, 360p, 240p | Mobile-optimized |
| minimal | 360p, 240p | Low bandwidth |
Segment Duration Options
| Duration | Use Case | Best For | |----------|----------|----------| | 2 seconds | Low latency streaming | Live sports, real-time | | 4 seconds | Fast streaming | News, events | | 6 seconds | Balanced (Recommended) | General purpose | | 8 seconds | Efficient packaging | Movies, series | | 10 seconds | Movie/VOD | Long-form content | | Custom | 2-10 seconds | Specific requirements |
Encoding Speed Presets
| Preset | Use Case |
|--------|----------|
| ultrafast | Draft encoding, fastest |
| superfast | Quick previews |
| veryfast | Fast encoding |
| faster | Good balance for speed |
| fast | Recommended for speed |
| medium | Default, good balance |
| slow | Better compression |
| slower | High quality |
| veryslow | Best compression, slowest |
Examples
Encode with 4-second segments for live streaming
efinix-encode -i video.mp4 -s 4 -r hdCustom resolutions only
efinix-encode -i video.mp4 --custom-res "1080p,720p,480p"High-quality encoding (slow)
efinix-encode -i video.mp4 -p slow -c libx265Mobile-only with small segments
efinix-encode -i video.mp4 -r mobile -s 4Output Structure
encoded/
├── master.m3u8 # Master playlist
├── 1080p/
│ ├── playlist.m3u8 # Variant playlist
│ ├── segment_000.ts # Video segments
│ ├── segment_001.ts
│ └── ...
├── 720p/
│ ├── playlist.m3u8
│ └── ...
└── [other resolutions]...Serving HLS Content
After encoding, serve the output directory with any static file server:
# Using npx serve
npx serve ./encoded
# Using Python
python3 -m http.server 8080 -d ./encoded
# Using Node.js http-server
npx http-server ./encoded -p 8080Then play in any HLS-compatible player:
http://localhost:8080/master.m3u8Programmatic API
import { VideoEncoder, DEFAULT_RESOLUTIONS } from '@efinixit/video-encoder';
const encoder = new VideoEncoder({
input: './video.mp4',
outputDir: './output',
resolutions: DEFAULT_RESOLUTIONS.filter(r => r.name !== '240p'),
segmentDuration: 6,
hlsListSize: 0,
preset: 'medium',
codec: 'libx264',
audioCodec: 'aac',
overwrite: false,
});
encoder.encode((progress) => {
console.log(`${progress.resolution}: ${progress.percent}%`);
}).then(result => {
console.log('Complete:', result);
});License
Copyright (c) 2024 EFINIX IT Labs. All rights reserved.
This software is licensed under the MIT License.
See LICENSE file for details.Support
- Website: efinixit.com
- Email: [email protected]
- Issues: GitHub Issues
