-
Notifications
You must be signed in to change notification settings - Fork 1
CLI Interface
⚠️ Note: The CLI interface is currently not up to date and may not work properly. It will be updated once the Java desktop application reaches version 1.0. For now, please use the desktop GUI for the best experience.
The Command-Line Interface (CLI) provides automation capabilities for batch processing, scripting, and server deployments.
CLI mode provides:
- ✅ Three operation modes (encoder, subtitle, renamer)
- ✅ Batch processing
- ✅ Progress callbacks
- ✅ Configurable settings
- ✅ Script-friendly output
The CLI interface exists but is outdated and may contain bugs or missing features. Development focus is currently on the desktop GUI application.
# Basic usage
python encodeforge_cli.py <mode> <input_files>
# Examples
python encodeforge_cli.py encoder /path/to/videos
python encodeforge_cli.py subtitle /path/to/videos --enable-subtitle-generation
python encodeforge_cli.py renamer /path/to/videos --tmdb-api-key YOUR_KEYgit clone https://github.com/yourusername/encodeforge.git
cd encodeforge
pip install -r requirements.txt
cd EncodeForge/src/main/resources/python
python encodeforge_cli.py --help- Python 3.8+
- FFmpeg installed
- Required Python packages (see requirements.txt)
python encodeforge_cli.py encoder <input> [options]Basic Options:
--output-dir DIR Output directory
--output-format FORMAT Output format (mp4, mkv, avi, mov)
--recursive Scan directories recursively
--dry-run Show what would be doneHardware Acceleration:
--use-nvenc Use NVIDIA NVENC
--use-amf Use AMD AMF
--use-qsv Use Intel Quick Sync
--nvenc-preset PRESET NVENC preset (p1-p7)
--nvenc-cq VALUE NVENC quality (0-51)Example:
python encodeforge_cli.py encoder /videos --use-nvenc --nvenc-cq 23 --output-format mp4python encodeforge_cli.py subtitle <input> [options]Options:
--enable-subtitle-generation Generate with Whisper AI
--enable-subtitle-download Download from providers
--subtitle-languages LANGS Comma-separated codes (eng,spa,fra)
--whisper-model MODEL Whisper model (tiny,base,small,medium,large)
--opensubtitles-api-key KEY OpenSubtitles API keyExample:
python encodeforge_cli.py subtitle /videos \
--enable-subtitle-generation \
--subtitle-languages eng,spa \
--whisper-model basepython encodeforge_cli.py renamer <input> [options]Options:
--pattern-tv PATTERN TV show naming pattern
--pattern-movie PATTERN Movie naming pattern
--tmdb-api-key KEY TMDB API key
--preview-only Show preview without renamingExample:
python encodeforge_cli.py renamer /videos \
--tmdb-api-key YOUR_KEY \
--pattern-tv "{title} - S{season}E{episode}" \
--preview-only# Encode entire directory with NVENC
python encodeforge_cli.py encoder /media/movies \
--use-nvenc \
--nvenc-preset p4 \
--nvenc-cq 23 \
--output-format mp4 \
--recursive \
--output-dir /media/output# Generate English and Spanish subtitles
python encodeforge_cli.py subtitle /media/tv-shows \
--enable-subtitle-generation \
--subtitle-languages eng,spa \
--whisper-model small \
--recursive# Rename TV shows with custom pattern
python encodeforge_cli.py renamer /media/tv-shows \
--tmdb-api-key YOUR_KEY \
--pattern-tv "{title} - S{season:02d}E{episode:02d} - {episodeTitle}" \
--preview-only # Preview first!# Encode + Add Subtitles + Rename
python encodeforge_cli.py encoder /media/input \
--use-nvenc \
--enable-subtitle-generation \
--subtitle-languages eng \
--enable-renaming \
--tmdb-api-key YOUR_KEY \
--pattern-tv "{title} - S{season}E{episode}"#!/bin/bash
# Batch encode videos in current directory
python encodeforge_cli.py encoder . \
--use-nvenc \
--nvenc-cq 23 \
--output-format mp4 \
--delete-original
echo "Encoding complete!"#!/usr/bin/env python3
import subprocess
import sys
def encode_videos(input_dir, output_dir):
cmd = [
"python", "encodeforge_cli.py", "encoder",
input_dir,
"--use-nvenc",
"--nvenc-cq", "23",
"--output-dir", output_dir,
"--recursive"
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
print("Encoding successful!")
print(result.stdout)
else:
print("Encoding failed!")
print(result.stderr)
sys.exit(1)
if __name__ == "__main__":
encode_videos("/videos/input", "/videos/output")#!/usr/bin/env python3
import os
import subprocess
from pathlib import Path
def process_directory(dir_path):
"""Process all videos in directory"""
# Check for FFmpeg
result = subprocess.run(
["python", "encodeforge_cli.py", "encoder", "--help"],
capture_output=True
)
if result.returncode != 0:
print("CLI not available")
return
# Process directory
cmd = [
"python", "encodeforge_cli.py", "encoder",
str(dir_path),
"--use-nvenc",
"--recursive"
]
subprocess.run(cmd)
if __name__ == "__main__":
watch_dir = Path("/media/watch")
# Monitor directory for new files
while True:
for file in watch_dir.rglob("*.mkv"):
print(f"Processing: {file}")
process_directory(file.parent)
# Add logic to move or delete processed files
time.sleep(60) # Check every minute🎬 Starting conversion of 10 files...
Settings: NVENC=True, Quality=23
Converting file1.mkv: 45.2%
Converting file2.mkv: 23.1%
...
================================================================================
CONVERSION RESULTS
================================================================================
✅ Successfully converted 10 files
✅ file1.mkv → file1.mp4
✅ file2.mkv → file2.mp4
...
# Verbose logging
python encodeforge_cli.py encoder /videos --verbose
# Save logs to file
python encodeforge_cli.py encoder /videos > log.txt 2>&1# Set API keys
export TMDB_API_KEY="your_key"
export OPENSUBTITLES_API_KEY="your_key"
# Set paths
export FFMPEG_PATH="/usr/bin/ffmpeg"
export OUTPUT_DIR="/media/output"Create ~/.encodeforge/config.json:
{
"tmdb_api_key": "your_key",
"opensubtitles_api_key": "your_key",
"default_output_dir": "/media/output",
"default_quality": 23,
"default_preset": "p4"
}Issue: "Command not found"
- Solution: Use full path to Python script
Issue: "FFmpeg not found"
-
Solution: Install FFmpeg or set
--ffmpeg-path
Issue: "Import error"
-
Solution: Install requirements:
pip install -r requirements.txt
Issue: "Permission denied"
- Solution: Check file permissions, run with appropriate user
# Enable debug logging
python encodeforge_cli.py encoder /videos --debug
# Check FFmpeg
python encodeforge_cli.py encoder /videos --check-ffmpeg# Edit crontab
crontab -e
# Run every night at 2 AM
0 2 * * * /path/to/encodeforge_cli.py encoder /videos/input --recursiveCreate /etc/systemd/system/encodeforge.service:
[Unit]
Description=EncodeForge Batch Processor
After=network.target
[Service]
Type=simple
User=media
ExecStart=/usr/bin/python /opt/encodeforge/cli.py encoder /media/input
Restart=on-failure
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable encodeforge
sudo systemctl start encodeforge- Use Hardware Acceleration - Much faster than software encoding
- Batch Processing - Process multiple files efficiently
- Dry Run First - Test commands before actual processing
- Monitor Resources - Watch CPU/GPU/disk usage
- Parallel Processing - Run multiple instances for different folders
Need automation? The CLI is perfect for scripting and batch processing!