Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few improvements #27

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
dbfeef6
move scripts to a separate folder for better org
eugenesvk Jan 18, 2023
c4a664a
:beetle: make all functions local to avoid conflicts
eugenesvk Jan 18, 2023
7e012a0
fix conf file names
eugenesvk Jan 18, 2023
4cdde17
reformat slightly
eugenesvk Jan 18, 2023
d39da2c
rename to mpvi
eugenesvk Jan 20, 2023
5e6f946
rename detect image to have the last index
eugenesvk Jan 20, 2023
3c63d68
std: add OSD dimension checker to std
eugenesvk Jan 20, 2023
ebb99db
replace OSD dimension checker with a more robust function from std
eugenesvk Jan 20, 2023
f22279f
reformat script path var comments
eugenesvk Jan 20, 2023
e802c03
image pos: remove test function
eugenesvk Jan 20, 2023
7933d6d
image pos: reformat
eugenesvk Jan 20, 2023
0738ed2
replace OSD dimension checker with a more robust function from std
eugenesvk Jan 20, 2023
e47936e
ruler: reformat
eugenesvk Jan 20, 2023
8823a1f
minimap: replace legacy API with OSD overlay
eugenesvk Jan 20, 2023
328a986
minimap: reformat
eugenesvk Jan 20, 2023
4c0d331
minimap: reformat
eugenesvk Jan 20, 2023
7bee83a
status_line: replace legacy API with OSD overlay
eugenesvk Jan 20, 2023
32ab7c6
status_line: reformat
eugenesvk Jan 20, 2023
671cb13
ruler: replace legacy API with OSD overlay
eugenesvk Jan 20, 2023
e78dc02
ruler: reformat
eugenesvk Jan 20, 2023
9335066
detect image: remove debug prints
eugenesvk Jan 20, 2023
fa77f3b
load detect_image last
eugenesvk Jan 20, 2023
1e3d7bb
image position: fix typo
eugenesvk Jan 20, 2023
4af0d14
fix typo in detect image config
eugenesvk Jan 20, 2023
edff8d9
image pos: add a reminder that -3/3 limits are from MPV
eugenesvk Jan 21, 2023
c517171
image pos: track OSD settings to ensure alignment is set on launch
eugenesvk Jan 21, 2023
baba243
image pos: reformat
eugenesvk Jan 21, 2023
c954576
change border alignment to more 'natural' directions
eugenesvk Jan 21, 2023
fd6364c
image pos: fix missing mw/mh
eugenesvk Jan 21, 2023
e5a14aa
image position: fix off-by-one error
eugenesvk Jan 21, 2023
7baa3e2
image pos: add timeout in addition to count limit
eugenesvk Jan 21, 2023
03fe81b
image pos: reformat
eugenesvk Jan 21, 2023
b538a99
add observe_print to std
eugenesvk Jan 21, 2023
a0b65e3
image position: replace pan with align in align function
eugenesvk Jan 21, 2023
976b0e1
image position: reformat
eugenesvk Jan 21, 2023
d39d7f2
image pos: make vertical scale to +↑ and −↓
eugenesvk Jan 22, 2023
7972daf
image pos: don't move the picture if it's fully outside
eugenesvk Jan 22, 2023
410ee55
image pos: update input config with more 'natural' panning directions
eugenesvk Jan 22, 2023
7ef0cec
image pos: reformat
eugenesvk Jan 22, 2023
e5bcbcc
image pos: fix non-working margins
eugenesvk Jan 22, 2023
41e0ace
image pos: partial fix for overshoots
eugenesvk Jan 22, 2023
61fdec0
std: escape magic chars in string match patterns
eugenesvk Jan 24, 2023
a945de7
std: add simple table print function
eugenesvk Jan 24, 2023
1258cae
std: add table length function
eugenesvk Jan 24, 2023
8965f48
std: add Math round function
eugenesvk Jan 24, 2023
b3f8526
std: import MPV options,msg
eugenesvk Jan 24, 2023
c8da077
std: add YAML config importer
eugenesvk Jan 24, 2023
46c881d
lib: add YAML parser
eugenesvk Jan 24, 2023
2413c36
detect img: allow tables in run_maybe
eugenesvk Jan 24, 2023
533bfca
detect img: use YAML config
eugenesvk Jan 24, 2023
f9af0e5
detect img: rename config
eugenesvk Jan 24, 2023
3ca2e08
detect img: replace config with YAML
eugenesvk Jan 24, 2023
636723e
detect img: remove index from file name
eugenesvk Jan 24, 2023
97198c9
config: replace with YAML
eugenesvk Jan 24, 2023
6e5ed6d
remove index from names and load YAML as config
eugenesvk Jan 24, 2023
547e12f
std: convert cli args to numbers when needed
eugenesvk Jan 24, 2023
55e3bb2
main: remove index from names
eugenesvk Jan 24, 2023
1c411a7
fix: stop() called before being declared
eugenesvk Jan 24, 2023
d70e472
rule: fix local functions being invisible due to their order
eugenesvk Jan 24, 2023
d41652c
std: add split and splitflex
eugenesvk Jan 24, 2023
7a71b0e
lib: add color conversion functions
eugenesvk Jan 24, 2023
3b2e298
ruler: change to better color space
eugenesvk Jan 24, 2023
f337ea4
minimap: change to better color space
eugenesvk Jan 24, 2023
94b5526
minimap: change to flexible splits
eugenesvk Jan 24, 2023
fb42227
ruler: change to flexible splits
eugenesvk Jan 24, 2023
14dc67b
minimap: update config with flexible splits and better color space
eugenesvk Jan 24, 2023
80fb2c0
ruler: update config with flexible splits and better color space
eugenesvk Jan 24, 2023
6a57f85
lib: color: add various normalization and conversion helper functions
eugenesvk Jan 25, 2023
a93e370
status line: add OSD text/border color/opacity
eugenesvk Jan 25, 2023
45335ed
color: add hsv and okhsv
eugenesvk Jan 26, 2023
ca291d1
color: fix order bug in rgb2norm
eugenesvk Jan 26, 2023
9639884
color: add alpha to convert2rgba
eugenesvk Jan 26, 2023
4fabda9
rename convert2mpv to convert2ass
eugenesvk Jan 26, 2023
f89d0ae
add okhsv/hsv to config comments
eugenesvk Jan 26, 2023
e9a846b
color: add convert2hex
eugenesvk Jan 26, 2023
4e0abe3
color: add license
eugenesvk Jan 26, 2023
aadf34e
status line: fix OSD color order default override
eugenesvk Jan 26, 2023
5f010de
status line: update config
eugenesvk Jan 26, 2023
ccdbc8e
add explicit profile to mpv.conf and reformat to tabular view
eugenesvk Jan 26, 2023
191cbc2
add profile to input.conf for conditional loading
eugenesvk Jan 26, 2023
3f4c548
minimap: fix the view configured to be invisible
eugenesvk Jan 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 98 additions & 91 deletions input.conf
Original file line number Diff line number Diff line change
@@ -1,105 +1,112 @@
1 change-list script-opts append image_positioning-drag_to_pan_margin=200
2 change-list script-opts append ruler-exit_bindings=8
3 change-list script-opts append ruler-line_color=FF
4 change-list script-opts append ruler-scale=25
5 change-list script-opts append ruler-max_size=20,20

SPACE repeatable playlist-next
alt+SPACE repeatable playlist-prev

UP ignore
DOWN ignore
LEFT repeatable playlist-prev
RIGHT repeatable playlist-next

# simple reminder of default bindings
#1 add contrast -1
#2 add contrast 1
#3 add brightness -1
#4 add brightness 1
#5 add gamma -1
#6 add gamma 1
#7 add saturation -1
#8 add saturation 1
#↓ enable to allow explicitly toggling MPVI input section
#w enable-section "mpvi"; print-text "mpvi ON" # test
#————— Input Section: MVImage —————#
#w {mpvi} disable-section "mpvi"; print-text "mpvi OFF" # test

# |default|
1 {mpvi} change-list script-opts append image_positioning-drag_to_pan_margin=200 #|add contrast -1|
2 {mpvi} change-list script-opts append ruler-exit_bindings=8 #|add contrast 1|
3 {mpvi} change-list script-opts append ruler-line_color=FF #|add brightness -1|
4 {mpvi} change-list script-opts append ruler-scale=25 #|add brightness 1|
5 {mpvi} change-list script-opts append ruler-max_size=20,20 #|add gamma -1|
#6 #|add gamma 1|
#7 #|add saturation -1|
#8 #|add saturation 1|

SPACE {mpvi} repeatable playlist-next #
alt+SPACE {mpvi} repeatable playlist-prev #

UP {mpvi} ignore #
DOWN {mpvi} ignore #
#LEFT {mpvi} repeatable playlist-prev #
#RIGHT {mpvi} repeatable playlist-next #

# mouse-centric bindings
MBTN_RIGHT script-binding drag-to-pan
MBTN_LEFT script-binding pan-follows-cursor
MBTN_LEFT_DBL ignore
WHEEL_UP script-message cursor-centric-zoom 0.1
WHEEL_DOWN script-message cursor-centric-zoom -0.1
MBTN_LEFT {mpvi} script-binding pan-follows-cursor #
MBTN_RIGHT {mpvi} script-binding drag-to-pan #
MBTN_LEFT_DBL {mpvi} ignore #
WHEEL_UP {mpvi} script-message cursor-centric-zoom 0.1 #
WHEEL_DOWN {mpvi} script-message cursor-centric-zoom -0.1 #

# panning with the keyboard:
# pan-image takes the following arguments
# pan-image AXIS AMOUNT ZOOM_INVARIANT IMAGE_CONSTRAINED
# ^ ^ ^
# x or y | |
# | |
# if yes, will pan by the same if yes, stops panning if the image
# amount regardless of zoom would go outside of the window

ctrl+down repeatable script-message pan-image y -0.1 yes yes
ctrl+up repeatable script-message pan-image y +0.1 yes yes
ctrl+right repeatable script-message pan-image x -0.1 yes yes
ctrl+left repeatable script-message pan-image x +0.1 yes yes

# now with more precision
alt+down repeatable script-message pan-image y -0.01 yes yes
alt+up repeatable script-message pan-image y +0.01 yes yes
alt+right repeatable script-message pan-image x -0.01 yes yes
alt+left repeatable script-message pan-image x +0.01 yes yes

# replace at will with h,j,k,l if you prefer vim-style bindings

# on a trackpad you may want to use these
#WHEEL_UP repeatable script-message pan-image y -0.02 yes yes
#WHEEL_DOWN repeatable script-message pan-image y +0.02 yes yes
#WHEEL_LEFT repeatable script-message pan-image x -0.02 yes yes
#WHEEL_RIGHT repeatable script-message pan-image x +0.02 yes yes

# align the border of the image to the border of the window
# align-border takes the following arguments:
# align-border ALIGN_X ALIGN_Y
# pan-image AXIS AMOUNT ZOOM_INVARIANT IMAGE_CONSTRAINED # panning with the keyboard
# ↑x/y ↑if yes, pan by the same amount regardless of zoom
# ↑if yes, stops panning if the image would go outside of the window
left {mpvi} repeatable script-message pan-image x -0.1 yes yes #
right {mpvi} repeatable script-message pan-image x +0.1 yes yes #
up {mpvi} repeatable script-message pan-image y +0.1 yes yes #
down {mpvi} repeatable script-message pan-image y -0.1 yes yes #
# ↑ with more precision #
alt+left {mpvi} repeatable script-message pan-image x -0.01 yes yes #
alt+right {mpvi} repeatable script-message pan-image x +0.01 yes yes #
alt+up {mpvi} repeatable script-message pan-image y +0.01 yes yes #
alt+down {mpvi} repeatable script-message pan-image y -0.01 yes yes #
# ↑ with less precision #
ctrl+left {mpvi} repeatable script-message pan-image x -0.25 yes yes #
ctrl+right {mpvi} repeatable script-message pan-image x +0.25 yes yes #
ctrl+up {mpvi} repeatable script-message pan-image y +0.25 yes yes #
ctrl+down {mpvi} repeatable script-message pan-image y -0.25 yes yes #
# Unconstrained #
Shift+left {mpvi} repeatable script-message pan-image x -0.1 yes no #
Shift+right {mpvi} repeatable script-message pan-image x +0.1 yes no #
Shift+up {mpvi} repeatable script-message pan-image y +0.1 yes no #
Shift+down {mpvi} repeatable script-message pan-image y -0.1 yes no #
# ↑ with more precision #
Shift+alt+left {mpvi} repeatable script-message pan-image x -0.01 yes no #
Shift+alt+right {mpvi} repeatable script-message pan-image x +0.01 yes no #
Shift+alt+up {mpvi} repeatable script-message pan-image y +0.01 yes no #
Shift+alt+down {mpvi} repeatable script-message pan-image y -0.01 yes no #
# ↑ with less precision #
Shift+ctrl+left {mpvi} repeatable script-message pan-image x -0.25 yes no #
Shift+ctrl+right {mpvi} repeatable script-message pan-image x +0.25 yes no #
Shift+ctrl+up {mpvi} repeatable script-message pan-image y +0.25 yes no #
Shift+ctrl+down {mpvi} repeatable script-message pan-image y -0.25 yes no #
# trackpad may want to use these #
WHEEL_LEFT {mpvi} repeatable script-message pan-image x -0.25 yes yes #
WHEEL_RIGHT {mpvi} repeatable script-message pan-image x +0.25 yes yes #
WHEEL_UP {mpvi} repeatable script-message pan-image y -0.25 yes yes #
WHEEL_DOWN {mpvi} repeatable script-message pan-image y +0.25 yes yes #
# ↑ no limit (Mac-bugged) NOT working with modifiers #
Shift+WHEEL_LEFT {mpvi} repeatable script-message pan-image x -0.25 yes no #
Shift+WHEEL_RIGHT {mpvi} repeatable script-message pan-image x +0.25 yes no #
Shift+WHEEL_UP {mpvi} repeatable script-message pan-image y -0.25 yes no #
Shift+WHEEL_DOWN {mpvi} repeatable script-message pan-image y +0.25 yes no #


# align-border ALIGN_X ALIGN_Y # align the border of the image to the border of the window
# any value for ALIGN_* is accepted, -1 and 1 map to the border of the window
ctrl+shift+right script-message align-border -1 ""
ctrl+shift+left script-message align-border 1 ""
ctrl+shift+down script-message align-border "" -1
ctrl+shift+up script-message align-border "" 1
ctrl+shift+r {mpvi} script-message align-border 0 0 # reset
ctrl+shift+left {mpvi} script-message align-border -1 '' #
ctrl+shift+right {mpvi} script-message align-border 1 '' #
ctrl+shift+up {mpvi} script-message align-border '' 1 #
ctrl+shift+down {mpvi} script-message align-border '' -1 #
#ctrl+shift+left {mpvi} script-message align-border -0.5 "" #
#ctrl+shift+right {mpvi} script-message align-border 0.5 "" #
#ctrl+shift+up {mpvi} script-message align-border "" 0.5 #
#ctrl+shift+down {mpvi} script-message align-border "" -0.5 #

# reset the image
ctrl+0 no-osd set video-pan-x 0; no-osd set video-pan-y 0; no-osd set video-zoom 0
ctrl+0 {mpvi} no-osd set video-pan-x 0; no-osd set video-pan-y 0; no-osd set video-zoom 0 # reset the image

+ add video-zoom 0.5
- add video-zoom -0.5; script-message reset-pan-if-visible
= no-osd set video-zoom 0; script-message reset-pan-if-visible
+ {mpvi} add video-zoom 0.5 #
- {mpvi} add video-zoom -0.5 ; script-message reset-pan-if-visible #
= {mpvi} no-osd set video-zoom 0 ; script-message reset-pan-if-visible #

e script-message equalizer-toggle
alt+e script-message equalizer-reset
e {mpvi} script-message equalizer-toggle
alt+e {mpvi} script-message equalizer-reset

h no-osd vf toggle hflip; show-text "Horizontal flip"
v no-osd vf toggle vflip; show-text "Vertical flip"
h {mpvi} no-osd vf toggle hflip; show-text "Horizontal flip"
v {mpvi} no-osd vf toggle vflip; show-text "Vertical flip"

r script-message rotate-video 90; show-text "Clockwise rotation"
R script-message rotate-video -90; show-text "Counter-clockwise rotation"
alt+r no-osd set video-rotate 0; show-text "Reset rotation"
r {mpvi} script-message rotate-video 90; show-text "Clockwise rotation" #
R {mpvi} script-message rotate-video -90; show-text "Counter-clockwise rotation" #
alt+r {mpvi} no-osd set video-rotate 0; show-text "Reset rotation" #

d script-message ruler
d {mpvi} script-message ruler

# Toggling between pixel-exact reproduction and interpolation
a cycle-values scale nearest ewa_lanczossharp
a {mpvi} cycle-values scale nearest ewa_lanczossharp # Toggling between pixel-exact reproduction and interpolation
c {mpvi} cycle icc-profile-auto # Toggle color management on or off
S {mpvi} screenshot window # Screenshot of the window output

# Toggle color management on or off
c cycle icc-profile-auto
A {mpvi} cycle-values video-aspect-override "-1" "no" # Toggle aspect ratio information on and off

# Screenshot of the window output
S screenshot window

# Toggle aspect ratio information on and off
A cycle-values video-aspect-override "-1" "no"

p script-message force-print-filename

# ADVANCED: you can define bindings that belong to a "section" (named "image-viewer" here) like so:
#alt+SPACE {image-viewer} repeatable playlist-prev
#SPACE {image-viewer} repeatable playlist-next
# to load them conditionally with a command. See scripts-opts/image_viewer.conf for how you can do this
p {mpvi} script-message force-print-filename
83 changes: 35 additions & 48 deletions mpv.conf
Original file line number Diff line number Diff line change
@@ -1,48 +1,35 @@
## IMAGE
# classic opengl-hq parameter, change at will
scale=spline36
cscale=spline36
dscale=mitchell
dither-depth=auto
correct-downscaling
sigmoid-upscaling
# debanding seems rarely useful with images
#deband
# dark grey background instead of pure black
background=0.2

## MISC
mute=yes
# the osc is mostly useful for videos
osc=no
# don't try to autoload subtitles or audio files
sub-auto=no
audio-file-auto=no
# get rid of the useless V: 00:00:00 / 00:00:00 line
term-status-msg=

# replace mpv with mvi in the window title
title="${?media-title:${media-title}}${!media-title:No file} - mvi"

# don't slideshow by default
image-display-duration=inf
# loop files in case of webms or gifs
loop-file=inf
# and loop the whole playlist
loop-playlist=inf

# you need this if you plan to use drag-to-pan or pan-follows-cursor with MOUSE_LEFT
window-dragging=no

#according to haasn, aspect ratio info for PNG and JPG is "universally bust"
[extension.png]
video-aspect-override=no

[extension.jpg]
video-aspect-override=no

[extension.jpeg]
profile=extension.jpg

[silent]
msg-level=all=no
[mpvi] # MVImage viewer Profile
profile-restore = copy # on load backup values of all profile options to allow restore
# classic opengl-hq parameter # change at will
scale = spline36 #
cscale = spline36 #
dscale = mitchell #
dither-depth = auto #
correct-downscaling #
sigmoid-upscaling #
#deband # debanding seems rarely useful with images
background = 0.2 # dark grey background instead of pure black

# Misc
mute = yes #
osc = no # the osc is mostly useful for videos
sub-auto = no # don't try to autoload subtitles or audio files
audio-file-auto = no #
term-status-msg = # get rid of the useless V: 00:00:00 / 00:00:00 line

title = "${?media-title:${media-title}}${!media-title:No file} - mvi" # replace mpv with mvi in the window title

image-display-duration = inf # don't slideshow by default
loop-file = inf # loop files in case of webms or gifs
loop-playlist = inf # and loop the whole playlist

window-dragging = no # if you plan to use drag-to-pan or pan-follows-cursor with MOUSE_LEFT

[extension.png] #
video-aspect-override = no # @haasn, aspect ratio info for PNG and JPG is "universally bust"
[extension.jpg] #
video-aspect-override = no #
[extension.jpeg] #
profile = extension.jpg #
[silent] #
msg-level = all=no #
17 changes: 0 additions & 17 deletions script-opts/detect_image.conf

This file was deleted.

14 changes: 0 additions & 14 deletions script-opts/image_positioning.conf

This file was deleted.

19 changes: 0 additions & 19 deletions script-opts/minimap.conf

This file was deleted.

18 changes: 18 additions & 0 deletions script-opts/mpvi/detect_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# commands to execute when a file detected as an image (1 frame, no audio) is loaded or unloaded
# these "hooks" let you change bindings, profiles, reset properties... mpv.io/manual/master/#list-of-input-commands for general command information
# CAN'T "unload a profile", to emulate this you must create an opposite profile and load that
# ↓ "quote commands" to avoid lua libyaml parser bug that includes #comments
on_load_image_first : # current file: image, previous: non-image or none
- "apply-profile mpvi" # enable config profile [mpvi]
- "enable-section mpvi" # enable key bindings with {mpvi} named input section
- "script-message status-line-enable" # enable status line (command set in status_line.lua)
on_load_image : # current file: image, previous: any
# - "script-message align-border '' 1" # align image to the top
- "no-osd set video-pan-x 0" # reset x pan
on_unload_image : # current file: non-image, previous: image
- "apply-profile mpvi restore" # try to restore previous config profile
- "disable-section mpvi" # disable key bindings with {mpvi}
- "no-osd set video-pan-x 0" # reset pan/zoom
- "no-osd set video-pan-y 0" # ...
- "no-osd set video-zoom 0" # ...
- "script-message status-line-disable" # disable status line (command set in status_line.lua)
6 changes: 6 additions & 0 deletions script-opts/mpvi/image_positioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
drag_to_pan_margin : 50 #
drag_to_pan_move_if_full_view : false # size of the margins with drag-to-pan
pan_follows_cursor_margin : 50 # size of the margins with pan-follows-cursor
cursor_centric_zoom_margin : 50 # size of the margins with cursor-centric-zoom
cursor_centric_zoom_auto_center : true # if the borders would show up, move the image this makes it not exactly cursor-centric in some cases
cursor_centric_zoom_dezoom_if_full_view : false # allow zooming out if the image can already fully fit in the window
12 changes: 12 additions & 0 deletions script-opts/mpvi/minimap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ↓ "quote text" to avoid lua libyaml parser bug that includes #comments
enabled : true # whether to show by default
center : "92 92" # the position of the center of the minimap, in percentage of the window (x, y)
scale : 12 # the scale of the minimap (i.e. the view rectangle is scale / 100 times the size of the window)
max_size : "16 16" # the cutoff size of the minimap (i.e. the image rectangle is clipped if it falls outside of the this zone)
color_space : "okhsl" # "okhsl","okhsv", "hsl","hsv" or "hex" bottosson.github.io/misc/colorpicker
image_opacity : "50" # opacity of the "image" (from 0=opaque to 100=transparent)
image_color : "0 0 75" # color of the "image"
view_opacity : "75" # opacity of the "view"
view_color : "0 0 15" # color of the "view"
view_above_image : true # whether the view should be drawn above the image
hide_when_full_image_in_view : true # whether to show the minimap if the current image is fully visible
Loading