diff --git a/README.md b/README.md new file mode 100644 index 0000000..2bfd75f --- /dev/null +++ b/README.md @@ -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 + + + 28 + 32 + 32 + 34 + + + + + + + + true + .vtt,.srt,.ass,.ssa,.sub + +``` + +## πŸ“Š 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 `true` + +**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) diff --git a/conversion_tracker.csv b/conversion_tracker.csv index 2ec8662..8cce3ae 100644 --- a/conversion_tracker.csv +++ b/conversion_tracker.csv @@ -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 diff --git a/logs/conversion.log b/logs/conversion.log index 17ef682..c54defa 100644 --- a/logs/conversion.log +++ b/logs/conversion.log @@ -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}