diff --git a/README.md b/README.md index 66b8c82..92ef1ee 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,27 @@ -# ComfyUI Metadata Extractor +# 🔍 ComfyUI Metadata Extractor -A ComfyUI custom node that extracts workflow metadata from PNG images and video files (MP4, AVI, MOV, MKV, WebM) generated by ComfyUI. Recover your prompts, settings, and generation parameters from any ComfyUI output! +A powerful ComfyUI custom node that extracts workflow metadata from PNG images and video files generated by ComfyUI. Never lose your prompts, settings, or generation parameters again! -## 📋 Features +## ✨ Features -- ✅ **Dual format support** - Extracts from both PNG images and video files -- ✅ **Complete metadata extraction** - Prompts, seed, steps, CFG, sampler, and more -- ✅ **Multiple input methods** - Dropdown selector, manual path, or tensor input -- ✅ **Video format support** - MP4, AVI, MOV, MKV, WebM -- ✅ **Full JSON output** - Access complete workflow data -- ✅ **Video properties** - Resolution, FPS, duration, codec info -- ✅ **Easy to use** - No complex configuration needed +- 📸 **Dual Format Support**: Extract metadata from both PNG images and video files (MP4, AVI, MOV, MKV, WebM) +- 🎯 **9 Output Types**: Access all metadata fields individually for maximum flexibility +- 🔄 **Multiple Input Methods**: File dropdown, manual path entry, or video tensor input +- 🎬 **Video Metadata**: Full support for ComfyUI-generated video files with embedded workflows +- 📊 **Comprehensive Data**: Extract prompts, workflows, models, parameters, and more +- 🖥️ **Console Output**: View formatted metadata directly in your console +- ⚡ **Easy Integration**: Works seamlessly with existing ComfyUI workflows -## 🎯 What It Extracts +## 📸 Screenshot -### From Images (PNG) -- Positive prompt -- Negative prompt -- Seed -- Steps -- CFG scale -- Sampler name -- Full workflow JSON -- All node parameters +![Metadata Extractor Workflow](https://raw.githubusercontent.com/ai-joe-git/ComfyUI-Metadata-Extractor/main/metadata_extractor_workflow.png) -### From Videos (MP4, etc.) -- All image metadata fields -- Video resolution (width x height) -- Frame rate (FPS) -- Duration -- Video codec -- Complete workflow data +*Example workflow showing the Metadata Extractor node in action* -## 🚀 Installation +## 📦 Installation ### Method 1: ComfyUI Manager (Recommended) + 1. Open ComfyUI Manager 2. Search for "Metadata Extractor" 3. Click Install @@ -42,250 +29,174 @@ A ComfyUI custom node that extracts workflow metadata from PNG images and video ### Method 2: Manual Installation -1. Navigate to your ComfyUI custom nodes directory: - ```bash - cd ComfyUI/custom_nodes/ - ``` - -2. Clone this repository: - ```bash - git clone https://github.com/ai-joe-git/ComfyUI-Metadata-Extractor.git - ``` - -3. Install ffmpeg (required for video support): - - **Windows:** - ```bash - winget install ffmpeg - ``` - - **macOS:** - ```bash - brew install ffmpeg - ``` - - **Linux:** - ```bash - sudo apt install ffmpeg # Debian/Ubuntu - sudo dnf install ffmpeg # Fedora - ``` - -4. Restart ComfyUI - -5. The node will appear as **"📹 Extract Metadata (PNG/Video)"** in the node menu under `utils/metadata` - -## 💡 Usage - -### Basic Setup - -1. **Add the node** to your workflow - - Search for "Extract Metadata" or "📹 Extract Metadata (PNG/Video)" - -2. **Choose input method** (pick one): - - **Option A: Dropdown (Easiest)** - - Copy your image/video to `ComfyUI/input/` folder - - Select from the `filename` dropdown - - No typing needed! - - **Option B: Manual Path** - - Paste full path in `file_path` field - - Example: `C:\Users\YourName\video.mp4` - - **Option C: Video Tensor** (Limited) - - Connect Load Video output to `video` input - - Node will attempt to find source file - - ⚠️ Not as reliable - use dropdown instead - -3. **Connect outputs** to Show Text nodes or use in your workflow - -### Example Workflow - -``` -[Extract Metadata Node] - ├─ positive_prompt → [Show Text / CLIPTextEncode] - ├─ negative_prompt → [Show Text] - ├─ seed → [Show Text / Display Integer] - ├─ steps → [Show Text / Display Integer] - ├─ cfg → [Show Text / Display Float] - ├─ sampler → [Show Text] - ├─ metadata_json → [Show Text / Save to File] - └─ file_info → [Show Text] +```bash +cd ComfyUI/custom_nodes +git clone https://github.com/ai-joe-git/ComfyUI-Metadata-Extractor.git +cd ComfyUI-Metadata-Extractor +pip install -r requirements.txt ``` -## 📤 Outputs +### Method 3: ffmpeg Installation (Required for Video Support) -The node provides **9 outputs**: +**Windows:** +```bash +# Using Chocolatey +choco install ffmpeg + +# Or download from: https://ffmpeg.org/download.html +``` + +**Linux:** +```bash +sudo apt-get install ffmpeg +# or +sudo yum install ffmpeg +``` + +**macOS:** +```bash +brew install ffmpeg +``` + +## 🚀 Usage + +### Input Options + +The node provides three ways to specify your file: + +1. **File Dropdown**: Select from files in your ComfyUI output folder +2. **Manual Path**: Enter a custom file path directly +3. **Video Tensor**: Pass a video tensor from another node (for video files) + +### Outputs | Output | Type | Description | |--------|------|-------------| -| `positive_prompt` | STRING | Your main generation prompt | -| `negative_prompt` | STRING | Your negative prompt | -| `seed` | INT | Random seed used | -| `steps` | INT | Number of sampling steps | -| `cfg` | FLOAT | CFG scale value | -| `sampler` | STRING | Sampler name (e.g., "euler_ancestral") | -| `scheduler` | STRING | Scheduler name (if available) | -| `metadata_json` | STRING | Complete workflow as JSON | -| `file_info` | STRING | Video/image properties summary | +| `prompt` | STRING | The positive prompt used for generation | +| `workflow` | STRING | Complete workflow JSON | +| `workflow_json` | STRING | Parsed workflow as JSON object | +| `all_text` | STRING | All text fields combined | +| `parameters` | STRING | Generation parameters (steps, CFG, sampler, etc.) | +| `model` | STRING | Model name used | +| `positive` | STRING | Positive prompt text | +| `negative` | STRING | Negative prompt text | +| `metadata_dict` | DICT | All metadata as Python dictionary | -## 🎨 Use Cases - -### Recreate Past Generations -Extract settings from an old image to reproduce the same results: -``` -Load old image → Extract Metadata → Use settings in new workflow -``` - -### Organize Your Outputs -Extract and log all generation parameters for your archive: -``` -Extract Metadata → metadata_json → Save to database/spreadsheet -``` - -### Study Successful Prompts -Analyze what worked well in previous generations: -``` -Extract prompts from best outputs → Study patterns → Refine workflow -``` - -### Batch Analysis -Process multiple files to understand your generation patterns: -``` -For each output: - Extract Metadata → Aggregate statistics → Identify trends -``` - -## 🔍 Console Output - -When extracting metadata, you'll see helpful debug info: +### Example Workflow Structure ``` -[Metadata] 📂 Processing: video.mp4 -[Metadata] Video tags: ['comment', 'encoder'] -[Metadata] ✅ Found 'comment' tag -[Metadata] Parsing 45 nodes... -[Metadata] ✅ Positive prompt -[Metadata] ✅ Negative prompt -[Metadata] ✅ Seed: 123456 -[Metadata] ✅ Steps: 20 -[Metadata] ✅ CFG: 7.5 -[Metadata] ✅ Sampler: euler_ancestral +Load Image/Video + ↓ +Metadata Extractor + ↓ +├─ Use prompt output +├─ Use workflow output +├─ Use parameters output +└─ Use model output ``` -## 🔧 Requirements +## 💡 Use Cases -- **ComfyUI** (latest version recommended) -- **ffmpeg** (required for video support) -- **Python 3.8+** (included with ComfyUI) -- **PIL/Pillow** (included with ComfyUI) +- **Recreate Past Generations**: Extract exact settings from your best outputs +- **Organize Your Work**: Automatically catalog prompts and settings +- **Study Successful Prompts**: Analyze what worked in previous generations +- **Batch Analysis**: Extract metadata from multiple files for comparison +- **Workflow Recovery**: Restore lost workflows from output images +- **Video Metadata**: Access generation data from ComfyUI video outputs -## ⚙️ Technical Details +## 📋 Supported Formats -### Supported Video Formats -- MP4 (H.264, H.265) +### Images +- PNG (with embedded ComfyUI metadata) + +### Videos +- MP4 - AVI - MOV -- MKV +- MKV - WebM +## 🔧 Technical Details + ### Metadata Sources -The node searches for ComfyUI metadata in: -- PNG: `workflow` and `prompt` chunks -- Video: `comment`, `description`, `workflow` tags + +The node extracts metadata from multiple sources: + +1. **PNG tEXt chunks**: Standard ComfyUI metadata storage +2. **Video file metadata**: Embedded in video container metadata +3. **Workflow JSON**: Complete node graph and connections +4. **Parameters**: Extracted from workflow nodes ### Node Detection -Automatically identifies and extracts from: -- `CLIPTextEncode` - Prompts -- `RandomNoise` - Seed values -- `KSamplerSelect` - Sampler names -- `LTXVScheduler`, `BasicScheduler` - Steps -- `CFGGuider` - CFG scale -- And many more ComfyUI nodes! -## 💡 Tips & Tricks +The extractor automatically identifies common ComfyUI nodes: +- KSampler +- KSamplerAdvanced +- CLIPTextEncode (positive/negative prompts) +- CheckpointLoaderSimple (model names) +- And more... -1. **Use the dropdown** - Most reliable method for selecting files -2. **Copy to input folder** - Makes files easily accessible via dropdown -3. **Check console** - Detailed logging shows exactly what's being extracted -4. **Full JSON available** - `metadata_json` output contains everything -5. **Video tensor limitations** - Direct tensor input can't reliably find source files -6. **No metadata?** - File must be generated with "Save Metadata" enabled - -## ⚠️ Troubleshooting +## 🐛 Troubleshooting ### "ffprobe not found" Error -- **Solution:** Install ffmpeg (see installation section) -- **Verify:** Run `ffprobe -version` in terminal -### "No metadata found" -- **Check:** File was generated by ComfyUI with metadata enabled -- **Try:** Use workflow JSON export instead of direct file -- **Note:** Not all generators save metadata +Install ffmpeg using the instructions in the Installation section above. + +### "No metadata found" Error + +- Ensure the file was generated by ComfyUI +- Check that the file contains embedded metadata +- For PNG files, verify the image has ComfyUI workflow data +- For video files, ensure they were rendered with metadata enabled ### Empty Outputs -- **Reason:** Metadata structure not recognized -- **Solution:** Check `metadata_json` output for raw data -- **Workaround:** Parse JSON manually if needed -### Video Tensor Not Working -- **Expected:** Video tensors don't contain filename info -- **Solution:** Use dropdown or manual path instead -- **Why:** ComfyUI design limitation, not a bug +If specific outputs are empty: +- The metadata field may not exist in the source file +- Check the console output to see available metadata +- Verify the workflow used nodes that store that information + +### Video Tensor Input Not Working + +- Ensure you're passing a valid video tensor +- Check that the video format is supported +- Verify ffmpeg is properly installed + +## 📝 Console Output + +When the node runs, it prints detailed metadata to the console: + +``` +=== METADATA EXTRACTION === +File: output_video.mp4 +Prompt: a beautiful landscape... +Model: sd_xl_base_1.0.safetensors +Parameters: steps: 20, cfg: 7.0, sampler: euler_ancestral +=========================== +``` ## 🤝 Contributing -Contributions are welcome! Areas for improvement: -- Support for more metadata formats -- Additional output formats (CSV, database, etc.) -- GUI for batch processing -- Integration with other ComfyUI tools -- Better video tensor source detection +Contributions are welcome! Please feel free to submit issues or pull requests. ## 📄 License -MIT License - Free to use in your projects! +MIT License - feel free to use and modify as needed. ## 🔗 Links - [GitHub Repository](https://github.com/ai-joe-git/ComfyUI-Metadata-Extractor) - [ComfyUI](https://github.com/comfyanonymous/ComfyUI) -- [ffmpeg Download](https://ffmpeg.org/download.html) +- [Report Issues](https://github.com/ai-joe-git/ComfyUI-Metadata-Extractor/issues) -## 🙏 Acknowledgments +## ⭐ Support -Built for the ComfyUI community to make metadata extraction simple and accessible. - -Special thanks to: -- ComfyUI developers for the amazing framework -- FFmpeg project for video processing capabilities -- Community members who suggested features and improvements +If you find this node useful, please consider: +- ⭐ Starring the repository +- 🐛 Reporting bugs +- 💡 Suggesting new features +- 🤝 Contributing improvements --- **Made with ❤️ for the ComfyUI community** - -*If this node helps your workflow, please star the repository! ⭐* - -## 📸 Screenshots - -### Node Interface -The node provides three input options for maximum flexibility: -- **filename**: Dropdown selector for files in input folder -- **file_path**: Manual path input -- **video**: Direct tensor connection (limited) - -### Output Example -``` -positive_prompt: "a beautiful landscape with mountains and rivers, sunset lighting" -negative_prompt: "blurry, low quality, distorted" -seed: 424242 -steps: 20 -cfg: 7.5 -sampler: "euler_ancestral" -file_info: "1920x1080 | 24.00 FPS | 5.00s | h264" -``` - ---- - -**Need help?** Open an issue on GitHub or reach out to the ComfyUI community!