Skip to content

Instantly share code, notes, and snippets.

@ManuLinares
Created November 27, 2019 22:32
Show Gist options
  • Save ManuLinares/820240d50f3c6b2fefaf7d86d94e9fc9 to your computer and use it in GitHub Desktop.
Save ManuLinares/820240d50f3c6b2fefaf7d86d94e9fc9 to your computer and use it in GitHub Desktop.
mpv .config
-- default keybinding: s
-- goes in ".config/mpv/scripts/autosub.lua"
-- add the following to your input.conf to change the default keybinding:
-- keyname script_binding auto_load_subs
local utils = require 'mp.utils'
function display_error()
mp.msg.warn("Subtitle download failed: ")
mp.osd_message("Subtitle download failed")
end
function load_sub_fn()
path = mp.get_property("path")
srt_path = string.gsub(path, "%.%w+$", ".srt")
t = { args = { "subliminal", "download", "-s", "-l", "en", path } }
mp.osd_message("Searching subtitle")
res = utils.subprocess(t)
if res.error == nil then
if mp.commandv("sub_add", srt_path) then
mp.msg.warn("Subtitle download succeeded")
mp.osd_message("Subtitle '" .. srt_path .. "' download succeeded")
else
display_error()
end
else
display_error()
end
end
mp.add_key_binding("s", "auto_load_subs", load_sub_fn)
n add audio-delay +0.10
N add audio-delay -0.10
CTRL+n set sub-delay 0
# Numpad
KP0 cycle-values video-rotate 90 180 270 0
KP1 add video-zoom -0.05
KP2 add video-pan-y -0.01
KP3 add video-zoom 0.05
KP4 add video-pan-x 0.01
KP5 set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 ; show-text "Reset zoom/pan"
KP6 add video-pan-x -0.01
KP7 add video-zoom -0.05
KP8 add video-pan-y 0.01
KP9 add video-zoom 0.05
RIGHT seek 5
LEFT seek -5
# ~/.config/mpv/scripts/autosub.lua - Loads English subtitles with "subliminal"
s script_binding auto_load_subs
#Rubberband filters, so I can change "pitch" and no tempo
ALT+t af toggle @rb #toggle on
ALT+4 af-command rb multiply-pitch 0.9438743126816935 #pitch down half note
ALT+5 af-command rb set-pitch 1.0 #reset pitch
ALT+6 af-command rb multiply-pitch 1.059463094352953 #pitch up half-note
#Toggle audio output Mono - Stereo
M af toggle "lavfi=[pan=1c|c0=0.5*c0+0.5*c1]" ; show-text "Audio mix set to Mono"
#Vaporsynth interpolation
#F vf toggle format=yuv420p,vapoursynth=~/scripts/motioninterpolation.vpy:4:4
# this is custom 60fps interpolation (https://gist.github.com/phiresky/4bfcfbbd05b3c2ed8645)
#vf=format=yuv420p,vapoursynth=~/scripts/motioninterpolation.vpy:4:4
ytdl-format=bestvideo[height<=?720][vcodec!=?vp9]+bestaudio/best #use h264 for video acceleratio
af=@rb:!rubberband # "ALT+t" toggle filter, "ALT+4", "ALT+5","ALT+6", change "pitch"
osd-font-size=24
sub-font-size=24
sub-auto=fuzzy
sub-ass-override=strip # try to remove embedded subtitle style
video-align-y=-1 # align video to the top when loaded. (move with numpad
idle=no # close mpv when video ends
volume-max=150
audio-channels=2
no-border # remove border decorations
#hr-seek=yes # for non keyframe skip, fast skip for large files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment