2026-01-18 12:18:01 +01:00
2026-01-18 12:18:01 +01:00
2026-01-18 12:18:01 +01:00
2026-01-18 12:18:01 +01:00
2026-01-18 12:18:01 +01:00

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:

  1. MetadataExtractor (File) - Works with file paths
  2. ImageMetadataExtractor (Image) - Works with IMAGE tensor inputs

Installation

Method 1: Manual Installation

  1. Navigate to your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes/
  1. Create a new folder for the node:
mkdir ComfyUI-Metadata-Extractor
cd ComfyUI-Metadata-Extractor
  1. Copy these files into the folder:

    • __init__.py
    • metadata_extractor_node.py
  2. Install required dependencies:

pip install pillow mutagen
  1. 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)

  1. Add the "Extract Metadata (File)" node to your workflow
  2. Connect a file path string to the file_path input
  3. 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)

  1. Add the "Extract Metadata (Image)" node to your workflow
  2. Connect an IMAGE output to the image input
  3. Optionally provide the source file path for full metadata extraction
  4. 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 info dictionary
  • Extracts workflow and prompt JSON 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 ffmpeg or 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.

S
Description
No description provided
Readme
898 KiB
Languages
Python 100%