A powerful CLI tool to convert images and videos to web-optimized formats with advanced features and GPU acceleration.
This project is currently in early development (v0.0.1).
Known Limitations:
- Limited format support (WebP, WebM only)
- No recursive folder scanning
- No batch configuration files
- Limited error handling
Planned Features:
- Additional formats (AVIF, HEIC, etc.)
- Recursive folder processing
- Configuration file support
- Better error messages
- Performance optimizations
Contributions and feedback are welcome!
- πΌοΈ Image Conversion: JPG/PNG β WebP/AVIF
- π¬ Video Conversion: MP4/MOV β WebM with GPU acceleration
- π Interactive folder browser starting from root directory
- π― Command line arguments (--help, --version, input-path)
- π Smart file selection (select all or individual files)
- β‘ Parallel processing with CPU usage control
- π GPU acceleration (NVIDIA/AMD auto-detection)
- π Real-time progress tracking (per-file progress for videos)
- βοΈ Advanced mode with custom encoding parameters
- π Back navigation at every step
- β±οΈ Elapsed time tracking
- π‘οΈ Graceful exit handling with file cleanup options
- π Bilingual support (English/Korean)
# Install globally
npm install -g media-to-web
# Use the CLI
npx mtw-cli
# Quick mode (non-interactive)
# Images: provide all options at once
npx media-to-web --quick --type image \
--input ./images --output ./converted \
--quality high --concurrency balanced --select all
# Videos: missing values fall back to defaults (webm/high/balanced)
npx media-to-web --quick --type video \
--input ./videos --output ./converted --select "*.mp4"# Clone the repository
git clone https://github.com/yourusername/media-to-web.git
cd media-to-web
# Install dependencies
npm install
# Run the CLI
npm start
# or
node bin/index.js# Show help
npx mtw-cli --help
# Show version
npx mtw-cli --version
# Convert files in specific folder
npx mtw-cli /path/to/your/media/files
# Interactive mode (browse folders)
npx mtw-cli# Navigate to folder with files to convert
cd /path/to/your/media/files
# Run CLI
npx mtw-clinpm start
### Local development/testing (npm link)
```bash
# 1) Build
npm run build
# 2) Create a global symlink
npm link
# 3) Test from another folder
mtw-cli --help
mtw-cli --version
# 4) Remove global link
npm unlink -g media-to-web
# 5) Optionally unlink in project root
npm unlinkNotes:
- If you hit permission issues, use
sudo npm link/sudo npm unlink -g. - If a global link remains,
npxmay prefer the linked code over the published package.
## π‘ Usage Example
### Interactive Folder Browser
```bash
$ npx mtw-cli
π¨ Media to Web CLI
? How would you like to select the input folder? π Browse folders
π Current directory: /
Found 12 folders
? Select an option: π Users
π Current directory: /Users
Found 2 folders
? Select an option: π butfitseoul
π Current directory: /Users/butfitseoul
Found 18 folders
? Select an option: π Downloads
π Current directory: /Users/butfitseoul/Downloads
Found 6 folders
? Select an option: β
Select this folder
Selected input folder: /Users/butfitseoul/Downloads
? What would you like to convert? π¬ Videos (mp4/mov β webm)
? Select configuration mode: π§ Simple Mode - Use presets
? How would you like to select files? β Select all files
? Select conversion quality: Medium - Recommended
? CPU usage level: βοΈ Balanced - Recommended (cores/2)
? Output folder for converted files: ./converted
Configuration:
Convert type: Images
Mode: Simple
Selected files: 3
Input folder: /Users/username/Photos
Output folder: /Users/username/Photos/converted
CPU usage: balanced (2 concurrent processes)
Quality: medium
β Converting 3 files...
β
Success (3 files):
photo1.jpg β photo1.webp
2.5 MB β 850 KB (66.0% reduction)
photo2.png β photo2.webp
4.1 MB β 1.2 MB (70.7% reduction)
vacation.jpeg β vacation.webp
1.2 MB β 420 KB (65.0% reduction)
Output folder: /Users/username/Photos/converted
Total elapsed time: 2m 34s
- Input:
.jpg,.jpeg,.png - Output:
.webp
- Input:
.mp4,.mov,.avi,.mkv - Output:
.webm
Quick setup with predefined quality presets:
Images:
- High: 90% quality, WebP format
- Medium: 80% quality, WebP format (recommended)
- Low: 60% quality, WebP format
Videos:
- High: CRF 23, Slow preset, VP9 codec
- Medium: CRF 28, Medium preset, VP9 codec (recommended)
- Low: CRF 35, Fast preset, VP9 codec
Custom encoding parameters for power users:
Images:
- Custom quality (0-100)
- Format selection (WebP/AVIF)
- Advanced Sharp options
Videos:
- Custom CRF value (0-51)
- Encoding preset selection
- Codec selection (VP9/H.264/H.265)
- GPU acceleration options
- Maximum: Use all available cores (fastest)
- Balanced: Use half the cores (recommended)
- Light: Use 1-2 processes (gentle on system)
- Custom: Specify exact number of concurrent processes
- NVIDIA GPU: Automatic detection and H.264 NVENC encoding
- AMD GPU: Automatic detection and H.264 AMF encoding
- CPU Fallback: VP9 encoding when no GPU detected
- Quality Preserved: Same CRF values regardless of encoder
- Images: 2-4x faster with parallel processing
- Videos: 2-3x faster with parallel processing
- Smart Batching: Optimal batch sizes for different file types
- Runtime: Node.js (ES Modules)
- Image conversion: Sharp
- Video conversion: FFmpeg (fluent-ffmpeg + ffmpeg-static)
- CLI interface: Inquirer
- UI enhancement: Chalk, Ora
media-convert/
βββ bin/
β βββ index.js # CLI entry point
βββ src/
β βββ prompts.js # User input handling
β βββ imageConverter.js # Image conversion logic
β βββ videoConverter.js # Video conversion logic
βββ package.json
βββ README.md
- Command line options (
--help,--version,--input-path) - Real-time progress display
- Parallel processing support
- Interactive folder browser
- Graceful exit handling
- Recursive subfolder scanning (
--recursive) - Additional format support (HEIC, etc.)
- Resizing/cropping features
- Metadata preservation options
- npm publishing setup
MIT
Issues and PRs are welcome!
- Requires Node.js 18 or higher
- FFmpeg is automatically included (ffmpeg-static)
- Large file conversion may take time
- Original files are not modified (saved to new folder)