Skip to main content

Jellyfin Codec Analyzer — analyze video codecs in your Jellyfin library

Project description

Jellyfin Codec Analyzer

A small command-line tool to analyze video codecs in a Jellyfin media library. It queries the Jellyfin server, inspects media stream information for movies and episodes, and summarizes codecs, counts, and sizes. The tool also supports an interactive mode to explore and export results.

The primary intended use of this tool is to find your biggest files using inefficient codecs and replace or re-encode them to save space or bandwith.

Key features

  • Analyze video codecs across your Jellyfin library
  • Show counts, total sizes, and percentages per codec
  • List files grouped by codec and optionally filter by codec
  • Save summary or per-file lists to CSV or JSON
  • Interactive TUI-style mode for quick exploration

Requirements

  • Python 3.8+
  • requests (for HTTP requests to Jellyfin)
  • python-dotenv (optional — automatically loads .env file if installed)

Install dependencies (recommended inside a virtualenv):

pip install -r requirements.txt
# Or install packages individually:
# pip install requests python-dotenv

Configuration

The script reads the Jellyfin server URL and API key from environment variables or command-line flags. Create a .env file in the same directory (optional) with the following values:

JELLYFIN_SERVER=http://localhost:8096
JELLYFIN_API_KEY=your_api_key_here

If python-dotenv is available the script will automatically load .env on startup and print a notice to stderr.

Usage

Run the analyzer directly:

python jellycodec.py -s http://your-server:8096 -k YOUR_API_KEY

Common options:

  • -s, --server: Jellyfin server URL (or set JELLYFIN_SERVER env var)
  • -k, --api-key: Jellyfin API key (or set JELLYFIN_API_KEY env var)
  • -i, --interactive: Run in interactive mode (menu-driven)
  • -l, --list-files: List all files grouped by codec
  • -c, --codec: Filter listed files by codec (use with -l)
  • -o, --output: Save codec summary to a file
  • -d, --detailed: Show percentages and detailed output

Examples:

  • Analyze library and print summary:
python jellycodec.py -s http://localhost:8096 -k ABCDEFGHIJK
  • Run interactive mode (recommended for exploring and exporting):
python jellycodec.py -i -s http://localhost:8096 -k ABCDEFGHIJK
  • List files for a specific codec:
python jellycodec.py -l -c "HEVC (H.265)" -s http://localhost:8096 -k ABCDEFGHIJK
  • Save codec summary to codecs.txt:
python jellycodec.py -o codecs.txt -d -s http://localhost:8096 -k ABCDEFGHIJK

Interactive mode

When launched with -i, the script fetches all movie/episode items once and provides a simple menu where you can:

  • View codec statistics (counts, total size)
  • View detailed statistics with percentages
  • List files grouped by codec
  • List files for a selected codec
  • Export file lists (CSV or JSON)

The interactive flow is useful when you want to quickly inspect which files use a particular codec and export results for further analysis.

Output and exports

  • Summary output shows total videos analyzed and aggregated size (human-readable).
  • File lists can be saved in CSV (recommended) or JSON formats.
  • The script attempts to use MediaSources entry to determine file sizes; when size information is missing the size will be reported as Unknown.

Notes & Error Handling

  • The script performs basic HTTP error handling (401/403/404/500 and connection/timeouts) and prints helpful guidance to stderr.
  • Ensure the API key has sufficient permissions to read library items.
  • The tool requests the Items endpoint with Recursive=true and IncludeItemTypes=Movie,Episode to fetch media streams.

Development & Contributing

Contributions and improvements welcome. Open an issue or submit a pull request with fixes or enhancements (e.g., support for additional item types, more robust size detection, or unit tests).

License

This repository does not include a license file. Add a license of choice if you intend to share publicly.


File: jellycodec.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jellycodec-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jellycodec-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file jellycodec-0.1.0.tar.gz.

File metadata

  • Download URL: jellycodec-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for jellycodec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0fd8db3e09b2c252b88e60901d46ef67ac663ff02efc1b67defebb70d2e10ffd
MD5 1cd3e4ba8e64b85bd5157a15b3d0d7b1
BLAKE2b-256 c41fb3773ae964e67d729a5004a52b162c8f68bf86f97c560c0ce06b9d6ce962

See more details on using hashes here.

File details

Details for the file jellycodec-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jellycodec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for jellycodec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fce65c3b082ee9c02de5f0e1de4fb59feff6cdabb8a448a11cd1241582c1ae3b
MD5 61b248c7eb543cfb601c8b49881303e9
BLAKE2b-256 1a4c5ba35df8bb0cea14ef11fc5fdddf12b38d54fd78619c8a34c075ce56956c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page