Ashyni / mpv-scripts

dynamic-crop.lua script for mpv player/lib.
MIT License
90 stars 6 forks source link
aspect-ratio crop cropping mpv

dynamic-crop.lua

Script to "cropping" dynamically, hard-coded black bars detected with lavfi-cropdetect filter for Ultra Wide Screen or any screen (Smartphone/Tablet).

Status

It's now really stable, but can probably be improved to handle more case.

Usage

Save dynamic-crop.lua in ~/.config/.mpv/scripts/ (Linux/macOS) or %AppData%\mpv\scripts\ (Windows).

Or edit your mpv.conf file to add script=<custom path to the script>, use absolute path and don't add it if you already put it in directory scripts:

## Example
# Linux/macOS:
script=/home/<username>/<any custom path you choose>/dynamic-crop.lua
# Windows:
script=C:\Users\<username>\<any custom path you choose>\dynamic-crop.lua
# Android mpv-android:
script=/storage/emulated/0/<any custom path you choose>/dynamic-crop.lua

Features

Shortcut

SHIFT+C do:

Cycle between ENABLE / DISABLE_WITH_CROP / DISABLE

To-Do

Troubleshooting

To collect the log, add to mpv.conf, log-file=<any path you can find easily>

If the script doesn't work, make sure mpv is build with the libavfilter crop and cropdetect by starting mpv with ./mpv --vf=help or by adding at the #1 line in mpv.conf vf=help and check the log for Available libavfilter filters:.

Make sure mpv option hwdec= is no(default) or any *-copy (doc), otherwise the script will fail.

Performance issue with mpv client or specific gpu-api (solved with patch):

Download on phone

Use the Desktop mode with a navigator on this page to access the button Code > Download Zip.
Or transfer it from a computer or any other device.