This commit is contained in:
TylerCG 2026-01-01 15:48:31 -05:00
parent 02a51c7473
commit 7323029edb
3 changed files with 240 additions and 0 deletions

166
README.md Normal file
View File

@ -0,0 +1,166 @@
# AV1 Batch Video Transcoder
A high-performance batch video transcoding tool using NVIDIA's **AV1 NVENC** codec with intelligent audio/subtitle handling and automatic quality optimization.
## ✨ Key Features
- **10-bit AV1 Encoding** - NVIDIA GPU acceleration (p010le, preset p1)
- **Smart Audio Processing** - Auto-detects bitrate, downmixes, re-encodes only when needed
- **Subtitle Embedding** - Auto-detects and embeds subtitles (.vtt, .srt, .ass, .ssa, .sub)
- **Smart Resolution** - Scales 4K→1080p, preserves lower resolutions
- **Two-Phase Encoding** - CQ mode first, automatic Bitrate fallback if size threshold exceeded
- **Automatic Cleanup** - Deletes originals + subtitles after successful encoding
- **Test Mode** - Encode one file, check compression ratio before batch processing
- **Optional Language Tagging** - Tag audio streams with language codes
- **CSV Tracking** - Detailed conversion logs with compression ratios
## 🚀 Quick Start
### Requirements
- **Python 3.8+**
- **FFmpeg** with libfdk-aac support
- **NVIDIA GPU** (GeForce RTX 2060+, Quadro, or newer)
- **NVIDIA CUDA Toolkit** (for av1_nvenc support)
### Installation
```bash
# Clone repository
git clone https://github.com/yourusername/conversion_project.git
cd conversion_project
# Install Python dependencies (if any needed in future)
# pip install -r requirements.txt
```
### Basic Usage
```bash
# Encode a TV folder (smart mode)
python main.py "P:\tv\Show Name"
# Test single file before batch processing
python main.py "P:\tv\Show Name" --test
# Force specific quality (CQ 30)
python main.py "P:\movies\Movie" --cq 30
# Force bitrate mode
python main.py "P:\tv\Show" --m bitrate
# Specific resolution
python main.py "P:\movies" --r 720
# Tag audio with language
python main.py "P:\tv\Show" --language eng
```
## 📖 Documentation
- **[Full Usage Guide](README_RESTRUCTURE.md)** - Detailed commands, features, troubleshooting
- **[Technical Architecture](PROJECT_STRUCTURE.md)** - Module breakdown, workflow, config reference
## ⚙️ Configuration
Edit `config.xml` to customize:
```xml
<!-- CQ quality per content type -->
<cq>
<tv_1080>28</tv_1080>
<tv_720>32</tv_720>
<movie_1080>32</movie_1080>
<movie_720>34</movie_720>
</cq>
<!-- Audio bitrate buckets -->
<audio>
<stereo>
<high>192000</high>
<medium>160000</medium>
</stereo>
<multi_channel>
<medium>448000</medium>
<low>384000</low>
</multi_channel>
</audio>
<!-- Subtitle auto-detection -->
<subtitles>
<enabled>true</enabled>
<extensions>.vtt,.srt,.ass,.ssa,.sub</extensions>
</subtitles>
```
## 📊 Example Output
**Input:**
```
Show.S01E01.mkv (1.5GB)
Show.S01E01.en.vtt (subtitle)
```
**Output:**
```
Show.S01E01 - [EHX].mkv (450MB, subtitle embedded, audio tagged)
```
**Compression:** 1.5GB → 450MB (30% ratio, 70% reduction)
## 🔧 Encoding Specs
| Setting | Value |
|---------|-------|
| Video Codec | AV1 (av1_nvenc) |
| Bit Depth | 10-bit (p010le) |
| GPU Preset | p1 (high quality) |
| Audio Codec | AAC |
| Audio Mode | Smart (copy or re-encode) |
| Container | MKV |
| Subtitles | Embedded SRT |
## 🎯 Workflow
1. **Scan** folder for video files
2. **Detect** subtitles, audio streams, resolution
3. **Encode** with AV1 codec (Phase 1: CQ)
4. **Check** size threshold (default 75%)
5. **Retry** with Bitrate mode if needed (Phase 2)
6. **Move** encoded file to original location
7. **Cleanup** original + subtitles + temp files
8. **Log** results to CSV tracker
## 📋 Requirements
- Windows 10/11 or Linux
- NVIDIA GPU with NVENC support
- NVIDIA CUDA Toolkit 11.0+
- FFmpeg compiled with av1_nvenc support
- Python 3.8+
## 🛠️ Troubleshooting
**Files not moving?**
- Check `reduction_ratio_threshold` in config.xml (default 0.75)
- Run with `--test` to see compression ratio
**Subtitles not embedding?**
- Verify filename: `video.en.vtt` or `video.vtt`
- Check config.xml `<subtitles><enabled>true</enabled>`
**Wrong audio quality?**
- Adjust CQ values in config.xml per content type
- Use `--cq` override: `python main.py folder --cq 30`
See [Full Guide](README_RESTRUCTURE.md) for more help.
## 📄 License
MIT
## 📞 Support
For detailed usage, see [README_RESTRUCTURE.md](README_RESTRUCTURE.md)
For technical architecture, see [PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md)

View File

@ -447,3 +447,4 @@ tv,Supernatural,Supernatural - S06E21 - Let It Bleed x265 AC3 Bluray-1080p HiQVE
tv,Supernatural,Supernatural - S06E22 - The Man Who Knew Too Much x265 AC3 Bluray-1080p HiQVE - [EHX].mkv,1257.75,561.37,44.6,1920x1080,1920x1080,1,34,CQ
tv,Supernatural,Supernatural - S05E01 - Sympathy for the Devil x265 AC3 Bluray-1080p HiQVE - [EHX].mkv,1286.7,512.54,39.8,1920x1080,1920x1080,1,34,CQ
tv,Supernatural,"Supernatural - S05E02 - Good God, Y'All! x265 AC3 Bluray-1080p HiQVE - [EHX].mkv",1290.8,640.05,49.6,1920x1080,1920x1080,1,34,CQ
tv,Supernatural,Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE - [EHX].mkv,1224.68,489.8,40.0,1920x1080,1920x1080,1,34,CQ

Can't render this file because it has a wrong number of fields in line 14.

View File

@ -18857,3 +18857,76 @@
{"timestamp": "2026-01-01T20:36:43Z", "level": "INFO", "message": " - Stream #1: 6ch→6ch | Lang: und | Detected: 256kbps | Action: COPY (preserve) | Target: 256kbps", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 60}
{"timestamp": "2026-01-01T20:36:43Z", "level": "INFO", "message": "Multi-channel audio 256kbps < 384k minimum - copying original to avoid artifical inflation", "module": "audio_handler", "funcName": "choose_audio_bitrate", "line": 212}
{"timestamp": "2026-01-01T20:36:43Z", "level": "INFO", "message": "Running CQ encode: Supernatural - S05E03 - Free to Be You and Me x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 124}
{"timestamp": "2026-01-01T20:38:49Z", "level": "INFO", "message": "\n📊 ENCODE RESULTS:", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 133}
{"timestamp": "2026-01-01T20:38:49Z", "level": "INFO", "message": " Original Size: 1235.03 MB", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 134}
{"timestamp": "2026-01-01T20:38:49Z", "level": "INFO", "message": " Encoded Size: 507.06 MB", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 135}
{"timestamp": "2026-01-01T20:38:49Z", "level": "INFO", "message": " Reduction: 41.1% of original (58.9% saved)", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 136}
{"timestamp": "2026-01-01T20:38:49Z", "level": "INFO", "message": " Resolution: 1920x1080 → 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 137}
{"timestamp": "2026-01-01T20:38:49Z", "level": "INFO", "message": " Audio Streams: 1 streams processed", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 138}
{"timestamp": "2026-01-01T20:38:53Z", "level": "INFO", "message": "Moved Supernatural - S05E03 - Free to Be You and Me x265 AC3 Bluray-1080p HiQVE - [EHX].mkv → Supernatural - S05E03 - Free to Be You and Me x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 417}
{"timestamp": "2026-01-01T20:38:55Z", "level": "INFO", "message": "\n✅ CONVERSION COMPLETE: Supernatural - S05E03 - Free to Be You and Me x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 457}
{"timestamp": "2026-01-01T20:38:55Z", "level": "INFO", "message": " Type: TV | Show: Supernatural", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 458}
{"timestamp": "2026-01-01T20:38:55Z", "level": "INFO", "message": " Size: 1235.03MB → 507.06MB (41.1% of original, 58.9% reduction)", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 459}
{"timestamp": "2026-01-01T20:38:55Z", "level": "INFO", "message": " Method: CQ | Status: SUCCESS", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 460}
{"timestamp": "2026-01-01T20:38:55Z", "level": "INFO", "message": "Deleted original and processing copy for Supernatural - S05E03 - Free to Be You and Me x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 466}
{"timestamp": "2026-01-01T20:38:55Z", "level": "INFO", "message": "Processing: Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "process_folder", "line": 110}
{"timestamp": "2026-01-01T20:39:06Z", "level": "INFO", "message": "Copied Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE.mkv → Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "process_folder", "line": 115}
{"timestamp": "2026-01-01T20:39:06Z", "level": "INFO", "message": "Source resolution detected: 1920x1080", "module": "video_handler", "funcName": "get_source_resolution", "line": 29}
{"timestamp": "2026-01-01T20:39:06Z", "level": "INFO", "message": "Source 1920x1080 (<=1080p). Preserving source resolution.", "module": "video_handler", "funcName": "determine_target_resolution", "line": 68}
{"timestamp": "2026-01-01T20:39:06Z", "level": "INFO", "message": "Source 1920x1080 (<=1080p). Preserving source resolution.", "module": "process_manager", "funcName": "process_folder", "line": 169}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": "\n🧩 ENCODE SETTINGS", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 25}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " Video:", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 28}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " • Source Resolution: 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 29}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " • Target Resolution: 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 30}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " • Encoder: av1_nvenc (preset p1, pix_fmt p010le)", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 31}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " • Scale Filter: bicubic", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 32}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " • Encode Method: CQ", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 33}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " • CQ Value: 34", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 35}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " Audio Streams (1 detected):", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 42}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": "Multi-channel audio 257kbps < 384k minimum - copying original to avoid artifical inflation", "module": "audio_handler", "funcName": "choose_audio_bitrate", "line": 212}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": " - Stream #1: 6ch→6ch | Lang: und | Detected: 257kbps | Action: COPY (preserve) | Target: 257kbps", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 60}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": "Multi-channel audio 257kbps < 384k minimum - copying original to avoid artifical inflation", "module": "audio_handler", "funcName": "choose_audio_bitrate", "line": 212}
{"timestamp": "2026-01-01T20:39:08Z", "level": "INFO", "message": "Running CQ encode: Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 124}
{"timestamp": "2026-01-01T20:41:19Z", "level": "INFO", "message": "\n📊 ENCODE RESULTS:", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 133}
{"timestamp": "2026-01-01T20:41:19Z", "level": "INFO", "message": " Original Size: 1225.90 MB", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 134}
{"timestamp": "2026-01-01T20:41:19Z", "level": "INFO", "message": " Encoded Size: 468.06 MB", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 135}
{"timestamp": "2026-01-01T20:41:19Z", "level": "INFO", "message": " Reduction: 38.2% of original (61.8% saved)", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 136}
{"timestamp": "2026-01-01T20:41:19Z", "level": "INFO", "message": " Resolution: 1920x1080 → 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 137}
{"timestamp": "2026-01-01T20:41:19Z", "level": "INFO", "message": " Audio Streams: 1 streams processed", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 138}
{"timestamp": "2026-01-01T20:41:23Z", "level": "INFO", "message": "Moved Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE - [EHX].mkv → Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 417}
{"timestamp": "2026-01-01T20:41:25Z", "level": "INFO", "message": "\n✅ CONVERSION COMPLETE: Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 457}
{"timestamp": "2026-01-01T20:41:25Z", "level": "INFO", "message": " Type: TV | Show: Supernatural", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 458}
{"timestamp": "2026-01-01T20:41:25Z", "level": "INFO", "message": " Size: 1225.9MB → 468.06MB (38.2% of original, 61.8% reduction)", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 459}
{"timestamp": "2026-01-01T20:41:25Z", "level": "INFO", "message": " Method: CQ | Status: SUCCESS", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 460}
{"timestamp": "2026-01-01T20:41:25Z", "level": "INFO", "message": "Deleted original and processing copy for Supernatural - S05E04 - The End x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 466}
{"timestamp": "2026-01-01T20:41:25Z", "level": "INFO", "message": "Processing: Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "process_folder", "line": 110}
{"timestamp": "2026-01-01T20:41:36Z", "level": "INFO", "message": "Copied Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE.mkv → Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "process_folder", "line": 115}
{"timestamp": "2026-01-01T20:41:36Z", "level": "INFO", "message": "Source resolution detected: 1920x1080", "module": "video_handler", "funcName": "get_source_resolution", "line": 29}
{"timestamp": "2026-01-01T20:41:36Z", "level": "INFO", "message": "Source 1920x1080 (<=1080p). Preserving source resolution.", "module": "video_handler", "funcName": "determine_target_resolution", "line": 68}
{"timestamp": "2026-01-01T20:41:36Z", "level": "INFO", "message": "Source 1920x1080 (<=1080p). Preserving source resolution.", "module": "process_manager", "funcName": "process_folder", "line": 169}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": "\n🧩 ENCODE SETTINGS", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 25}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " Video:", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 28}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " • Source Resolution: 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 29}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " • Target Resolution: 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 30}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " • Encoder: av1_nvenc (preset p1, pix_fmt p010le)", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 31}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " • Scale Filter: bicubic", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 32}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " • Encode Method: CQ", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 33}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " • CQ Value: 34", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 35}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " Audio Streams (1 detected):", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 42}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": "Multi-channel audio 255kbps < 384k minimum - copying original to avoid artifical inflation", "module": "audio_handler", "funcName": "choose_audio_bitrate", "line": 212}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": " - Stream #1: 6ch→6ch | Lang: und | Detected: 255kbps | Action: COPY (preserve) | Target: 255kbps", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 60}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": "Multi-channel audio 255kbps < 384k minimum - copying original to avoid artifical inflation", "module": "audio_handler", "funcName": "choose_audio_bitrate", "line": 212}
{"timestamp": "2026-01-01T20:41:38Z", "level": "INFO", "message": "Running CQ encode: Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 124}
{"timestamp": "2026-01-01T20:43:50Z", "level": "INFO", "message": "\n📊 ENCODE RESULTS:", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 133}
{"timestamp": "2026-01-01T20:43:50Z", "level": "INFO", "message": " Original Size: 1224.68 MB", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 134}
{"timestamp": "2026-01-01T20:43:50Z", "level": "INFO", "message": " Encoded Size: 489.80 MB", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 135}
{"timestamp": "2026-01-01T20:43:50Z", "level": "INFO", "message": " Reduction: 40.0% of original (60.0% saved)", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 136}
{"timestamp": "2026-01-01T20:43:50Z", "level": "INFO", "message": " Resolution: 1920x1080 → 1920x1080", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 137}
{"timestamp": "2026-01-01T20:43:50Z", "level": "INFO", "message": " Audio Streams: 1 streams processed", "module": "encode_engine", "funcName": "run_ffmpeg", "line": 138}
{"timestamp": "2026-01-01T20:43:54Z", "level": "INFO", "message": "Moved Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE - [EHX].mkv → Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 417}
{"timestamp": "2026-01-01T20:43:55Z", "level": "INFO", "message": "\n✅ CONVERSION COMPLETE: Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE - [EHX].mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 457}
{"timestamp": "2026-01-01T20:43:55Z", "level": "INFO", "message": " Type: TV | Show: Supernatural", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 458}
{"timestamp": "2026-01-01T20:43:55Z", "level": "INFO", "message": " Size: 1224.68MB → 489.8MB (40.0% of original, 60.0% reduction)", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 459}
{"timestamp": "2026-01-01T20:43:55Z", "level": "INFO", "message": " Method: CQ | Status: SUCCESS", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 460}
{"timestamp": "2026-01-01T20:43:56Z", "level": "INFO", "message": "Deleted original and processing copy for Supernatural - S05E05 - Fallen Idols x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "_save_successful_encoding", "line": 466}
{"timestamp": "2026-01-01T20:43:56Z", "level": "INFO", "message": "Processing: Supernatural - S05E06 - I Believe the Children Are Our Future x265 AC3 Bluray-1080p HiQVE.mkv", "module": "process_manager", "funcName": "process_folder", "line": 110}