Library Structure
Jellyfin organizes media into a hierarchical structure:1
Root Folder
The
AggregateFolder serves as the root container for all libraries. It aggregates all virtual folders configured by the administrator.2
Virtual Folders
Each library is represented as a virtual folder with a specific collection type (Movies, TV Shows, Music, Books, etc.).
3
Physical Paths
Virtual folders map to one or more physical paths on disk where media files are stored.
4
Media Items
Individual files are resolved into typed items (Movie, Episode, Audio, etc.) with associated metadata.
Collection Types
Jellyfin supports several collection types, each with specialized handling:- Movies
- TV Shows
- Music
- Books
- Individual movie files
- Movie folders with multiple versions/editions
- Extras (trailers, behind-the-scenes, deleted scenes)
- Multiple video formats
Library Manager
TheLibraryManager is the central service for managing media libraries:
Emby.Server.Implementations/Library/LibraryManager.cs
The LibraryManager uses an LRU cache to improve performance when accessing frequently requested items, reducing database queries.
Media Scanning Process
When Jellyfin scans a library, it follows a multi-stage process:1
File Discovery
The file system is traversed to discover media files based on naming conventions and file extensions.
2
Item Resolution
Resolvers determine the type of each media item (Movie, Episode, Audio, etc.).Jellyfin includes specialized resolvers:
MovieResolver- Identifies movie filesSeriesResolver- Identifies TV series foldersEpisodeResolver- Parses episode information from filenamesAudioResolver- Identifies audio tracks
3
Metadata Extraction
Metadata is extracted from:
- Embedded tags (ID3, MP4, MKV metadata)
- File naming patterns (episode numbers, years, etc.)
- NFO files (Kodi-compatible XML metadata)
4
Provider Fetching
External metadata providers are queried:
- TMDb (movies and TV shows)
- MusicBrainz (music)
- Open Subtitles (subtitles)
- Local metadata providers
5
Database Persistence
Items and their metadata are saved to the database.
6
Post-Scan Tasks
Additional processing tasks run after the scan:
- Image extraction and processing
- Chapter image generation
- People/actor validation
Naming Conventions
Jellyfin uses theEmby.Naming library to parse media files:
TV Show Naming
Movie Naming
Music Naming
Library Options
Each library can be configured with specific options:MediaBrowser.Model/Configuration/LibraryOptions.cs
Real-Time Monitoring
Jellyfin can monitor libraries for changes in real-time:MediaBrowser.Controller/Library/ILibraryMonitor.cs
- File system watchers detect new, modified, or deleted files
- Changes are debounced to avoid excessive scanning
- Only affected items are refreshed
Item Resolution
The resolution process uses a priority-based system of resolvers:MediaBrowser.Controller/Library/ItemResolveArgs.cs
Metadata Providers
Metadata is fetched from multiple sources:- Local Providers
- Remote Providers
- Plugin Providers
- NFO files: Kodi-compatible XML metadata
- Embedded metadata: Tags in media files
- Image files: poster.jpg, fanart.jpg, etc.
Image Processing
Jellyfin processes and caches images for optimal delivery:- Primary images: Posters, covers
- Backdrops: Background artwork
- Logos: Transparent overlays
- Thumbnails: Chapter images, episode stills
Images are automatically resized and cached based on client requirements to optimize bandwidth and loading times.
Library Events
The LibraryManager emits events for library changes:Next Steps
Architecture
Understand Jellyfin’s overall architecture
Users & Authentication
Learn about user management
Plugins
Extend library functionality with plugins
API Reference
Access library data via the API