direct-play-nice
A CLI utility to convert video files to Direct-Play-compatible (the single best optimization for your home video streaming server) formats.
Purpose
This tool was created to convert video files to formats that satisfy Direct Play requirements for all video files used by your video streaming server and their streaming devices (eg. Chromcast). It is intended to be added to a video-downloading service (ie. with Sonarr or Radarr) as an optimization feature and seamless to the end user (ie. Direct Play selected by default).
Features
- Converts any video file supported by FFmpeg
- Satisfies Direct Play requirements for Plex, Jellyfin, etc.
- Can be used standalone or as a Custom Script Connection with Sonarr, Radarr, etc.
- Allows for achieving Direct Play with all videos in a way seamless to the end user.
- Offers intuitive quality presets (match-source, 360p through 2160p + audio caps) so you can keep output sizes in check for fast starts on Plex and other direct-play servers.
- Targets every supported streaming device by default, or narrow the profile
with
--streaming-devices.
Supported Streaming Devices
| Device Name | Release Year | Video Codecs | Audio Codecs | Resolution Support |
|---|---|---|---|---|
| Chromecast | 2013 | H.264, VP8 | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM) | Up to 1080p |
| Chromecast 2 | 2015 | H.264, VP8 | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM) | Up to 1080p |
| Chromecast Audio | 2015 | N/A | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM), FLAC | N/A |
| Chromecast Ultra | 2016 | H.264, VP8, VP9, HEVC | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM), FLAC | Up to 4K |
| Chromecast 3 | 2018 | H.264, VP8, VP9 | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM) | Up to 1080p |
| Chromecast with Google TV | 2020 | H.264, VP8, VP9, HEVC, Dolby Vision, HDR10, HDR10+ | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM), FLAC, Dolby Digital, Dolby Digital Plus, Dolby Atmos | Up to 4K HDR |
| Chromecast with Google TV (HD) | 2022 | H.264, VP8, VP9, HEVC, HDR10, HDR10+ | HE-AAC, LC-AAC, MP3, Vorbis, WAV (LPCM), FLAC, Dolby Digital, Dolby Digital Plus, Dolby Atmos | Up to 1080p HDR |
Each device above exposes a model identifier (e.g. chromecast_ultra). The CLI
assumes every device by default; supply
--streaming-devices chromecast_ultra,chromecast_1st_gen or
--streaming-devices all to override.
Usage
This program can be run standlone directly on the CLI or as a Custom Script Connection with Sonarr or Radarr.
CLI
<INPUT_FILE> Video
<OUTPUT_FILE> Our
)
)
)
)
||
()
)
||
()
|||)
|)
||||||
()
Notes:
- In probe modes (
--probe-hw,--probe-codecs,--probe-streams), the positional<INPUT_FILE> <OUTPUT_FILE>are not required (except--probe-streams, which requires<INPUT_FILE>). -s allhas the same effect as omitting-s: the tool computes a direct-play profile compatible across all known devices.- Combine
--servarr-output-extensionand--servarr-output-suffixto control how Sonarr/Radarr replacements are named. When run from Sonarr, the CLI defaults to creatingEpisode.fixed.<ext>(with the extension derived from the conversion output). - Use
--delete-sourceif you want the original input removed after a successful conversion (ignored during Sonarr/Radarr runs because the tool already swaps the file in place). - The binary self-throttles: no more than two conversions run at once across all processes. Additional invocations wait until a slot is free.
- Tune concurrency via environment variables: set
DIRECT_PLAY_NICE_MAX_JOBSfor a global cap, orDIRECT_PLAY_NICE_JOBS_PER_GPUto control how many simultaneous encodes run on each detected GPU (default: two per NVIDIA/AMD device; NVIDIA is detected vianvidia-smi, AMD viarocm-smion Linux or PowerShell on Windows). Machines without supported detection fall back to a single shared queue; setDIRECT_PLAY_NICE_MAX_JOBSmanually if you want more parallelism on AMD or CPU-only hosts.
Device model strings for -s
chromecast_1st_genchromecast_2nd_genchromecast_ultra
You can pass multiple, e.g. -s chromecast_1st_gen,chromecast_2nd_gen, or just
use -s all.
Examples
Convert for all devices (same as omitting -s):
Convert for specific devices (intersection of capabilities):
Probe hardware and codec availability (JSON):
Probe input streams (text and JSON):
Sonarr / Radarr
When running via Sonarr, Radarr, etc you can use this program to convert each
downloaded video file to a Direct-Play-compatible format by adding it as a
Custom Script Connection (Settings >> Connect >> Custom Script).
The binary now auto-detects Sonarr/Radarr custom-script invocations:
sonarr_eventtype=Downloadorradarr_eventtype=Downloadtriggers an in-place transcode of the file referenced by the corresponding$sonarr_episodefile_path/$radarr_moviefile_pathenvironment variable.- All other event types (e.g.
Test,Grab,Rename, etc.) exit cleanly without requiring any CLI arguments. - By default the script promotes the converted output to an
.mp4beside the original file (which is removed once the conversion completes). Override this by passing--servarr-output-extension match-inputto keep the original container or any custom extension (e.g.--servarr-output-extension mkv).
Example Sonarr command:
Example Radarr command keeping the source container:
Example Sonarr command that keeps all defaults (resulting in
Episode.fixed.mp4 after conversion):
Tip: Sonarr/Radarr will see the new filename on their next library scan. If you convert to
.mp4, Plex/Jellyfin can immediately direct play the result.

Quality Controls
By default the CLI preserves source quality for both video and audio. To shrink files ahead of Plex / Jellyfin direct play, mix and match:
--video-quality match-source|360p|480p|720p|1080p|1440p|2160papplies intuitive resolution caps and matching H.264 bitrate ceilings. For example,--video-quality 720pclamps to 1280×720 and ~5 Mbps, while--video-quality 2160pscales to 3840×2160 at ~35 Mbps.--audio-quality match-source|320k|256k|224k|192k|160k|128k|96ksets AAC bitrate ceilings to well-known streaming tiers (e.g.--audio-quality 192kfor a "standard" profile).- Familiar aliases such as
--video-quality 4k,--video-quality full-hd, or--audio-quality highmap onto the presets above.
Need something custom? Use --max-video-bitrate and/or --max-audio-bitrate to
override the presets with any value such as 4800k, 6M, or 12.5mbps.
Building
This project relies on FFmpeg and rsmpeg and builds on Mac, Linux and Windows:
After running cargo vcpkg build once, point VCPKG_ROOT at the shared
installation so builds and CI reuse the same FFmpeg toolchain (this repo
defaults to /opt/vcpkg on Unix and C:\\src\\vcpkg on Windows):
The repo defaults to /opt/vcpkg on Unix-like platforms and C:\\src\\vcpkg on
Windows; override this environment variable if your setup differs. Our
Cargo.toml pins vcpkg to commit 21012a516c9e5fa547baf212f2d937cd8d15dcb5
which includes FFmpeg 8—if you reuse an existing checkout, make sure it is
checked out to that revision:
# Windows PowerShell
git -C $env:VCPKG_ROOT fetch https://github.com/cqundefine/vcpkg.git
git -C $env:VCPKG_ROOT checkout 21012a516c9e5fa547baf212f2d937cd8d15dcb5
# macOS/Linux
Tests
# Builds assume `/opt/vcpkg`; override VCPKG_ROOT if you keep vcpkg elsewhere.
# export VCPKG_ROOT=/opt/vcpkg
End‑to‑end conversion tests that synthesize media require the ffmpeg CLI and
are marked #[ignore]. To run them explicitly:
VCPKG_ROOT=/opt/vcpkg
Optional: direnv
If you use direnv, add the following to .envrc so shells pick up the shared
vcpkg install:
Then run direnv allow once in the repo.
Contributions / Support
If you run into any issues while using this software or want to add a feature or bug fix feel free to raise an issue.