Video Encoder Utility
Overview
jelly_coder scans a folder for supported videos (.mkv, .mp4, .wmv, .mwv, .avi, .webm) and re-encodes them with size-aware defaults. It keeps subtitles/metadata, flips containers when MP4 constraints are violated, and preserves a mirrored directory tree when you choose not to overwrite in place.
Key capabilities:
- Automatic encoder selection with hardware-first preference (NVENC → QSV → AMF → x264) and explicit backend override flags.
- Height presets (
auto,1080p,720p,480p,360p) with bitrate scaling so smaller outputs also shrink file size. - Smart audio handling: copies compatible streams, forces stereo when sources are mono or pseudo-mono (e.g., WMV files with only one active channel), and warns about downmixing.
- Hardware fallbacks: if a chosen hardware encoder fails to create a session, the tool transparently repeats the job with
libx264so the batch continues.
Prerequisites
- Windows PowerShell 5.1 (default shell for the repo scripts).
- Python 3.11+ with virtual environment support.
- ffmpeg and ffprobe in
PATH.- Hardware backends require vendor drivers and an ffmpeg build with NVENC/QSV/AMF enabled.
Installation
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install -e .
Usage
# Show CLI help
python -m jelly_coder --help
# Reduce a folder, mirror outputs under ./output/<dir>, auto-select backend
python -m jelly_coder D:\media --quality 720p
# Force Intel QSV, enable overwrite, run at debug verbosity
python -m jelly_coder D:\media --backend qsv --overwrite --log-level debug
# Change the display aspect ratio to 16:9
python -m jelly_coder D:\media --aspect 16:9
# Legacy wrapper remains available
python encode_videos.py D:\media
Key Flags
PATH(positional): Directory scanned recursively for supported video extensions.--backend BACKEND:auto(default),nvenc,x264,qsv, oramf.--codec CODEC: Hinth264orhevc; respected when the backend supports it.--quality PRESET: Downscale preset (auto,1080p,720p,480p,360p).--aspect W:H: Set the output display aspect ratio (e.g.16:9,4:3).--max-workers N: Concurrent encodes (default 1; hardware encoders generally behave best at 1).--overwrite: Replace sources in place. When omitted, outputs land in./output/<input-folder>.--output PATH: Custom output directory root when not overwriting.--log-level LEVEL:info(default),debug,warning, etc.
Output Behavior
- MP4 targets convert SubRip/ASS to
mov_textautomatically; incompatible streams trigger a fallback to MKV. - Attached artwork, metadata, and subtitle tracks are propagated.
- When the output is larger than the input, a warning is emitted so you can review or delete the file.
- Audio streams are copied when safe; otherwise they are re-encoded to AAC 192k stereo, duplicating the dominant channel if the source is effectively mono.
Encoder Backends
- Auto: Queries ffmpeg encoders and picks the best available hardware backend (NVENC → QSV → AMF → x264).
- NVENC/QSV/AMF: Uses vendor hardware. Hardware decode fallbacks are attempted before giving up.
- x264: Software-only; always available.
- If a hardware backend exhausts its attempts (e.g.,
Error creating a MFX session: -9on QSV), the utility logs a warning and re-runs the encode withlibx264automatically.
Audio Handling
- ffprobe insights drive copy-or-transcode decisions.
- WMV inputs and other stereo tracks with severe channel imbalance trigger a sampling step; if only one channel has meaningful signal, the tool duplicates it so the result plays on both speakers.
- Mono and surround sources are converted to stereo with informative log messages about the change.
Development
- Run
python -m pytestandflake8before committing; coverage is enforced at 100%. python -m jelly_coder --helpverifies CLI wiring after refactors.- VS Code launchers in
.vscode/launch.jsonprovide ready-to-run debug sessions.
Troubleshooting
- Validate ffmpeg exposes the expected encoders:
ffmpeg -hide_banner -encoders | Select-String nvenc. - Hardware backends may need up-to-date GPU/Media drivers; keep Windows and vendor packages current.
- Delete partial outputs in
output/if you want to re-run without--overwrite.
Metadata
Release files for jellycoder 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jellycoder-1.2.0.tar.gz | 65.3 kB | Without provenance | Details for jellycoder-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jellycoder-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for jellycoder-1.2.0-py3-none-any.whl |
Total release size: 107.2 kB
Release files / jellycoder-1.2.0.tar.gz
| Download URL | jellycoder-1.2.0.tar.gz |
|---|---|
| Size | 65.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b5b1420686b652bad92b2ee7f4179805dd2c79f8b211cf4b9b661676b54c3db
|
|
BLAKE2b-256 checksum How to use checksums |
1f1dd9d83a17450dababec8af9c25e9cae339eb83c657e27dd25be14c678dc4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / jellycoder-1.2.0-py3-none-any.whl
| Download URL | jellycoder-1.2.0-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d62f54722ef0da3b1998d8281fd61dce88dd8573b63101a9629d372bd5b1970e
|
|
BLAKE2b-256 checksum How to use checksums |
10e8d3ebb02c05161231296b6e40e9b4cdae4feb070fde293f3805d54aa2ad50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for jellycoder 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.