Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

PlexCleaner

> 开发工具
Open source

Utility to optimize media files for Direct Play in Plex, Emby, Jellyfin, etc.

339 stars0 likes2 views
WebsiteGitHub

About

Utility to optimize media files for Direct Play in Plex, Emby, Jellyfin, etc.

PlexCleaner

Utility to optimize media files for Direct Play in Plex, Emby, Jellyfin, etc.

Build and Distribution

  • Source Code: [GitHub][github-link] - Full source code, issues, and CI/CD pipelines.
  • Binary Releases: [GitHub Releases][releases-link] - Pre-compiled executables for Windows, Linux, and macOS.
  • Docker Images: [Docker Hub][docker-hub-link] - Container images with all tools pre-installed.

Build Status

[![Release Status][release-status-shield]][actions-link]
[![Docker Status][docker-status-shield]][actions-link]
[![Last Commit][last-commit-shield]][commits-link]

Releases

[![GitHub Release][release-version-shield]][releases-link]
[![GitHub Pre-Release][pre-release-version-shield]][releases-link]
[![Docker Latest][docker-latest-version-shield]][docker-hub-link]
[![Docker Develop][docker-develop-version-shield]][docker-hub-link]

Release Notes

Version: 3.22:

Summary:

  • Added always-on runtime metrics with operation-weighted progress, published via System.Diagnostics.Metrics and readable with dotnet-counters.
  • Bundled a counters wrapper in the Docker image for reading the metrics with a single command.

See Release History for complete release notes and older versions.

Getting Started

Get started with PlexCleaner in three easy steps using Docker (recommended):

⚠️ Important: PlexCleaner modifies media files in place. Always maintain backups of your media library before processing. Consider testing on sample files first.

ℹ️ Note: Replace /data/media with your actual host media directory path. All examples map the host directory to /media inside the container.

bash
# 1. Create a default settings file
docker run --rm --volume /data/media:/media:rw docker.io/ptr727/plexcleaner \
  /PlexCleaner/PlexCleaner defaultsettings --settingsfile /media/PlexCleaner/PlexCleaner.json

# 2. Edit /data/media/PlexCleaner/PlexCleaner.json to suit your needs

# 3. Process your media files
docker run --rm --volume /data/media:/media:rw docker.io/ptr727/plexcleaner \
  /PlexCleaner/PlexCleaner --logfile /media/PlexCleaner/PlexCleaner.log \
  process --settingsfile /media/PlexCleaner/PlexCleaner.json \
  --mediafiles /media/Movies --mediafiles /media/Series

See Installation for detailed setup instructions and other platforms.

Table of Contents

  • Build and Distribution
    • Build Status
    • Releases
    • Release Notes
  • Getting Started
  • Table of Contents
  • Overview
  • Performance Considerations
  • Installation
    • Docker
    • Windows
    • Linux
    • macOS
    • AOT
  • Configuration
    • Default Settings
    • Common Configuration Examples
    • IETF Language Matching
    • EIA-608 and CTA-708 Closed Captions
    • Custom FFmpeg and Handbrake Encoding Settings
  • Usage
    • Common Commands Quick Reference
    • Global Options
    • Process Command
    • Monitor Command
    • Other Commands
  • Runtime Metrics
  • Custom Plugins
  • Questions or Issues
  • Testing
    • Unit Testing
    • Docker Testing
    • Regression Testing
  • Development Tooling
  • Feature Ideas
  • 3rd Party Tools
  • Sample Media Files
  • License

Overview

ℹ️ TL;DR: Direct Play means your media server (Plex/Emby/Jellyfin) sends the file directly to your player without transcoding on the server or the client. This saves server CPU, reduces power consumption, preserves quality, and enables playback on low-power devices. The objective of PlexCleaner is to modify media content such that it will always Direct Play in [Plex][plex-directplay-link], [Emby][emby-directplay-link], [Jellyfin][jellyfin-playmethod-link], etc.

Common examples of issues resolved by the process command:

Container & Codec Issues:

  • Non-MKV containers → Re-multiplex to MKV (player compatibility).
  • MPEG-2 video → Re-encode to H.264 (licensing prevents hardware decoding).
  • MPEG-4 or VC-1 video → Re-encode to H.264 (playback issues).
  • H.264 Constrained Baseline@30 → Re-encode to H.264 High@40 (playback issues).
  • Vorbis or WMAPro audio → Re-encode to AC3 (platform compatibility).

Track Management:

  • Missing language tags → Set language for unknown tracks (enables automatic selection).
  • Invalid or unmappable IETF/BCP-47 language tags → Set to a valid tag in place.
  • Duplicate audio/subtitle tracks → Remove duplicates, keep best quality.
  • VOBsub subtitles without MuxingMode → Re-multiplex to set correct attribute (prevents hangs).

Video Quality:

  • Interlaced video → Deinterlace using HandBrake --comb-detect --decomb.
  • Embedded closed captions (EIA-608/CTA-708) → Remove from video streams (can't be managed by player).
  • Dolby Vision profile 5 → Warn when not profile 7 (DV/HDR10 compatibility).

Performance & Integrity:

  • Corrupt media streams → Verify integrity and attempt automatic repair.
  • Non-monotonic DTS timestamps → Losslessly rewrite the packet timestamps using setts.
  • Matroska files that fail player Direct Play despite passing tool checks → Detect an unusable seek index (SeekHead/Cues) and re-multiplex.
  • High bitrate content → Warn when exceeding network capacity (WiFi/100Mbps Ethernet).

See the process command for detailed workflow and the Common Configuration Examples for quick setup examples.

Performance Considerations

PlexCleaner is optimized for processing large media libraries efficiently. Key performance features and tips:

⚡ Performance Tips:

  • Large libraries: Use --parallel to process multiple files concurrently.
  • Testing: Combine --testsnippets and --quickscan for faster test iterations.
  • Network storage: Process files locally when possible to avoid network bottlenecks.
  • Docker logging: Configure [log rotation][docker-logging-link] to prevent large log files.
  • Thread count: Default is half of CPU cores (max 4); adjust with --threadcount if needed.

Sidecar Files:

  • To improve processing performance of large media collections, the media file attributes and processing state is cached in sidecar files. (filename.mkv -> filename.PlexCleaner)
  • Sidecar files allow re-processing of the same files to be very fast as the state will be read from the sidecar vs. re-computed from the media file.
  • The sidecar maintains a hash of small parts of the media file (timestamps are unreliable), and the media file will be reprocessed when a change in the media file is detected.

Processing Operations:

  • Re-multiplexing is an IO intensive operation and re-encoding is a CPU intensive operation.
  • Parallel processing, using the --parallel option, is useful when a single instance of FFmpeg or HandBrake does not saturate all the available CPU resources.
  • Processing can be interrupted using Ctrl-Break, if using sidecar files restarting will skip previously verified files.

Docker Considerations:

  • Processing very large media collections on docker may result in a very large docker log file, set appropriate [docker logging][docker-logging-link] options.

Installation

Choose an installation method based on your platform and requirements:

  • Docker (Recommended): Easiest and most up-to-date option.

    • ✅ All tools pre-installed and automatically updated.
    • ✅ Consistent experience across platforms.
    • ✅ Supports linux/amd64 and linux/arm64 architectures.
    • Best for: Linux, NAS devices, servers, cross-platform deployments.
  • Windows: Native installation with automatic tool updates.

    • ✅ Automatic tool downloads and updates via checkfornewtools command.
    • ✅ Or use winget for system-wide tool installation.
    • Best for: Windows desktops and servers.
  • Linux: Manual installation.

    • ⚠️ Requires manual tool installation via package manager.
    • ⚠️ No automatic tool updates.
    • Best for: Users who prefer native binaries over Docker.
  • macOS: Limited support.

    • ⚠️ Binaries built but not tested in CI.
    • ⚠️ Manual tool installation required.

Docker

  • Builds are published on [Docker Hub][docker-hub-link].
  • See the [Docker README][docker-hub-link] for current distribution and media tool versions.
  • ptr727/plexcleaner:latest is based on [Ubuntu][ubuntu-hub-link] (ubuntu:rolling) built from the main branch.
  • ptr727/plexcleaner:develop is based on [Ubuntu][ubuntu-hub-link] (ubuntu:rolling) built from the develop branch.
  • Docker images and GitHub Releases for both branches are published on a weekly schedule (and on demand), each refreshed with the latest upstream and base-image updates. Pull requests are smoke-tested only and do not publish.
  • The container has all the prerequisite 3rd party tools pre-installed.

Path Mapping Convention: All examples use /data/media as the host path mapped to /media inside the container. Replace /data/media with your actual host media location.

Docker Compose (Recommended for Monitor Mode)

For continuous monitoring of media folders, use Docker Compose.

…

On stop (docker stop, or Compose shutdown), PlexCleaner handles the termination signal, stops processing gracefully, and logs the run summary and exit code before exiting. Because it aborts the in-flight file rather than killing it mid-write, allow enough grace for a long re-encode to unwind: set stop_grace_period (Compose) or --stop-timeout / docker stop --time 30 (Docker run). Without enough grace the container is force-killed (SIGKILL) and the summary is lost.

Docker Run Examples

For a simple one-time process operation, see the Getting Started example.

Setup Permissions (if running as non-root user):

bash
# Create nonroot user and set media directory permissions
sudo adduser --no-create-home --shell /bin/false --disabled-password --system --group users nonroot
sudo chown -R nonroot:users /data/media
sudo chmod -R ug=rwx,o=rx /data/media

Interactive Shell Access:

bash
# Replace /data/media with your actual media directory
# Replace the 1001:100 with your nonroot:users
docker run \
  -it --rm --pull always \
  --name PlexCleaner \
  --user 1001:100 \
  --volume /data/media:/media:rw \
  docker.io/ptr727/plexcleaner \
  /bin/bash

# Inside the container, run PlexCleaner commands (see Quick Start)
exit

Monitor Command in Screen Session:

bash
# Start or attach to screen session
screen
# Or: screen -rd

# Run monitor (adjust paths as needed)
docker run -it --rm --pull always \
  --log-driver json-file --log-opt max-size=10m \
  --name PlexCleaner --env TZ=America/Los_Angeles \
  --volume /data/media:/media:rw \
  docker.io/ptr727/plexcleaner \
  /PlexCleaner/PlexCleaner --logfile /media/PlexCleaner/PlexCleaner.log --loglevel Warning --logelevate \
  monitor --settingsfile /media/PlexCleaner/PlexCleaner.json --parallel \
  --mediafiles /media/Movies --mediafiles /media/Series

Process Command:

For one-time processing, see the Getting Started example or use similar syntax as above, replacing monitor with process.

Windows

Prerequisites:

  • For pre-compiled binaries: Install [.NET Runtime][dotnet-install-windows-link] (smal

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#7zipcsharpdotnetemby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具