Skip to content

[FEAT] Intro + Credits Detection.. [HELP NEEDED] #157

@stevezau

Description

@stevezau

Feature: Add Intro, Credits, and Outro Detection

Summary

Add intro, credits, and outro detection to plex_generate_vid_previews using FFmpeg chromaprint audio fingerprinting (intros) and blackdetect/silencedetect filters (credits), then write markers to the Plex database's taggings table.


Research Findings

How Plex Does Detection Internally

Plex uses three detection methods (confirmed by the intro-skipper project wiki and Plex blog):

  1. Chromaprint audio fingerprinting — an FFmpeg extension that compares audio across episodes in a season to find recurring segments (intro themes). This is the primary method for intro detection.
  2. Black frame detection — FFmpeg's blackdetect filter identifies black/near-black frames marking transitions (credits start).
  3. Silence detection — FFmpeg's silencedetect filter finds extended periods of silence that often precede credits.

Detection Parameters

  • Intros: 15s–2min long, located within the first 25% of episode or first 10 minutes (whichever is smaller)
  • Credits: 15s–5min long, located near the end of the video (typically last 25%)

How Plex Stores Markers

Plex stores markers in its SQLite database in the taggings table (confirmed by MarkerEditorForPlex source code). Key fields:

Field Description
metadata_item_id Plex episode/movie rating key
tag_id Marker tag type (tag_type=12 in the tags table)
index Ordering index for multiple markers
text Marker type: 'intro', 'credits', or 'commercial'
time_offset Start time in milliseconds
end_time_offset End time in milliseconds
created_at Timestamp
extra_data JSON (PMS >=1.40) or legacy string with version and final flag

There is no public Plex HTTP API for creating markers. Both MarkerEditorForPlex and the now-EOL plex-credits-detect project write directly to the SQLite database. python-plexapi only has read-only Marker objects but no addMarker() method.

The project already has PLEX_CONFIG_FOLDER access, so the Plex database at PLEX_CONFIG_FOLDER/Plug-in Support/Databases/com.plexapp.plugins.library.db is accessible.


Architecture

flowchart TB
    subgraph detection [Detection Phase]
        A[Enumerate Library] --> B{Media Type?}
        B -->|TV Episode| C[Group by Season]
        B -->|Movie| D[Single File Analysis]
        C --> E["Chromaprint Fingerprint each episode"]
        E --> F["Compare Fingerprints across season"]
        F --> G["Identify Common Audio Segments"]
        G --> H[Intro Markers]
        C --> I["BlackDetect + SilenceDetect near end of each episode"]
        D --> I
        I --> J[Credits Markers]
    end
    subgraph writing [Marker Write Phase]
        H --> K["Write to Plex SQLite taggings table"]
        J --> K
        K --> L["Verify via python-plexapi read"]
    end
Loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions