ComfyUI Metadata Extractor
A powerful custom node for ComfyUI that extracts metadata from images, videos, and audio files generated by ComfyUI.
Features
✅ Multiple File Format Support:
- Images: PNG, JPEG
- Videos: MP4, AVI, MOV, MKV, WebM
- Audio: FLAC, MP3, WAV, OGG
✅ Comprehensive Metadata Extraction:
- Positive prompt
- Negative prompt
- Seed
- Steps
- CFG scale
- Sampler name
- Scheduler
- Width/Height/Dimensions
- Batch size
- FPS (for videos)
- Full workflow JSON
✅ Two Node Variants:
- MetadataExtractor (File) - Works with file paths
- ImageMetadataExtractor (Image) - Works with IMAGE tensor inputs
Installation
Method 1: Manual Installation
- Navigate to your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes/
- Create a new folder for the node:
mkdir ComfyUI-Metadata-Extractor
cd ComfyUI-Metadata-Extractor
-
Copy these files into the folder:
__init__.pymetadata_extractor_node.py
-
Install required dependencies:
pip install pillow mutagen
- Restart ComfyUI
Method 2: Git Clone (if you create a repo)
cd ComfyUI/custom_nodes/
git clone https://github.com/yourusername/ComfyUI-Metadata-Extractor.git
cd ComfyUI-Metadata-Extractor
pip install -r requirements.txt
Usage
MetadataExtractor (File Path)
- Add the "Extract Metadata (File)" node to your workflow
- Connect a file path string to the
file_pathinput - All metadata outputs will be available as separate connections:
positive_prompt(STRING)negative_prompt(STRING)seed(STRING)steps(STRING)width(INT)height(INT)batch_size(INT)cfg(FLOAT)sampler_name(STRING)scheduler(STRING)full_workflow_json(STRING)
ImageMetadataExtractor (Image Input)
- Add the "Extract Metadata (Image)" node to your workflow
- Connect an IMAGE output to the
imageinput - Optionally provide the source file path for full metadata extraction
- Outputs:
prompt(STRING)negative_prompt(STRING)width(INT)height(INT)metadata_json(STRING)
Example Workflows
Example 1: Extract and Reuse Prompts
Load an image → Extract Metadata (File) → Connect positive_prompt to CLIPTextEncode → Generate similar image
Example 2: Batch Processing
Load multiple images → Extract Metadata → Save prompts to text files → Analyze generation patterns
Example 3: Video Analysis
Load video path → Extract Metadata (File) → Get FPS, dimensions, and generation settings
Technical Details
How It Works
For PNG Images:
- Reads metadata from PNG
infodictionary - Extracts
workflowandpromptJSON data - Parses node structure to find generation parameters
For Videos:
- Uses ffprobe to read video metadata
- Looks for ComfyUI metadata in format tags
- Extracts dimensions and FPS from stream info
For Audio:
- Uses mutagen library to read audio tags
- Searches for JSON metadata in comment/description fields
- Preserves generation parameters
Metadata Structure
ComfyUI stores metadata in a node-based JSON structure. This node intelligently parses:
- KSampler nodes for sampling parameters
- CLIPTextEncode nodes for prompts
- EmptyLatentImage nodes for dimensions
- Custom metadata fields
Dependencies
- Python 3.8+
- PIL/Pillow (image handling)
- mutagen (audio metadata)
- ffprobe (video metadata, optional but recommended)
Troubleshooting
"No metadata found"
- Ensure the file was generated by ComfyUI with metadata saving enabled
- Check that the file hasn't been re-encoded or processed by other tools
Video metadata extraction fails
- Install ffmpeg/ffprobe:
apt-get install ffmpegor download from ffmpeg.org - Ensure ffprobe is in your system PATH
Audio metadata extraction fails
- Install mutagen:
pip install mutagen - Some audio formats may not preserve metadata after encoding
Limitations
- Only extracts metadata that was embedded during generation
- Images downloaded from web sources typically have metadata stripped
- Video metadata preservation depends on the encoder settings
- Some file formats have limited metadata support
Future Enhancements
- Support for more video formats
- Batch processing multiple files
- Export metadata to CSV/JSON files
- Metadata comparison between files
- Automatic prompt reconstruction from partial data
Contributing
Feel free to submit issues, feature requests, or pull requests!
License
MIT License - Free to use and modify
Credits
Created for the ComfyUI community. Special thanks to the ComfyUI developers and the AI art community.