用于在 Plex、Emby、Jellyfin 等中优化媒体文件以便进行直接播放的工具
Utility to optimize media files for Direct Play in Plex, Emby, Jellyfin, etc.
[![Release Status][release-status-shield]][actions-link]
[![Docker Status][docker-status-shield]][actions-link]
[![Last Commit][last-commit-shield]][commits-link]
[![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]
Version: 3.22:
Summary:
System.Diagnostics.Metrics and readable with dotnet-counters.counters wrapper in the Docker image for reading the metrics with a single command.See Release History for complete release notes and older versions.
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/mediawith your actual host media directory path. All examples map the host directory to/mediainside the container.
# 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/SeriesSee Installation for detailed setup instructions and other platforms.
ℹ️ 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:
Constrained Baseline@30 → Re-encode to H.264 High@40 (playback issues).Track Management:
MuxingMode → Re-multiplex to set correct attribute (prevents hangs).Video Quality:
--comb-detect --decomb.Performance & Integrity:
setts.See the process command for detailed workflow and the Common Configuration Examples for quick setup examples.
PlexCleaner is optimized for processing large media libraries efficiently. Key performance features and tips:
⚡ Performance Tips:
- Large libraries: Use
--parallelto process multiple files concurrently.- Testing: Combine
--testsnippetsand--quickscanfor 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
--threadcountif needed.
Sidecar Files:
filename.mkv -> filename.PlexCleaner)Processing Operations:
--parallel option, is useful when a single instance of FFmpeg or HandBrake does not saturate all the available CPU resources.Ctrl-Break, if using sidecar files restarting will skip previously verified files.Docker Considerations:
Choose an installation method based on your platform and requirements:
Docker (Recommended): Easiest and most up-to-date option.
linux/amd64 and linux/arm64 architectures.Windows: Native installation with automatic tool updates.
checkfornewtools command.winget for system-wide tool installation.Linux: Manual installation.
macOS: Limited support.
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.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.
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.
For a simple one-time process operation, see the Getting Started example.
Setup Permissions (if running as non-root user):
# 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/mediaInteractive Shell Access:
# 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)
exitMonitor Command in Screen Session:
# 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/SeriesProcess Command:
For one-time processing, see the Getting Started example or use similar syntax as above, replacing monitor with process.
Prerequisites:
暂无开放 Issues,或尚未同步最近议题。