From 13cf088964a38e79f6fe777bfb645dc9d2c4ad1e Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Tue, 5 Mar 2019 00:52:49 +0100 Subject: [PATCH] Add mpv config --- .config/mpv/input.conf | 5 +++ .config/mpv/mpv.conf | 15 +++++++++ .config/mpv/scripts/autosub.lua | 32 +++++++++++++++++++ .config/mpv/scripts/cycle-video-rotate.lua | 36 ++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 .config/mpv/input.conf create mode 100644 .config/mpv/mpv.conf create mode 100644 .config/mpv/scripts/autosub.lua create mode 100644 .config/mpv/scripts/cycle-video-rotate.lua diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf new file mode 100644 index 0000000..59249d9 --- /dev/null +++ b/.config/mpv/input.conf @@ -0,0 +1,5 @@ +< playlist_next +> playlist_prev +d run rm ${path} +Alt+LEFT script-message Cycle_Video_Rotate -90 +Alt+RIGHT script-message Cycle_Video_Rotate 90 diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf new file mode 100644 index 0000000..9a0d04a --- /dev/null +++ b/.config/mpv/mpv.conf @@ -0,0 +1,15 @@ +profile=gpu-hq +hwdec=vdpau +loop-playlist=inf +image-display-duration=2 +shuffle +no-audio-display + +[noosd] +no-osc +osd-level=2 +term-osd=force +no-osd-bar +osd-border-size=0 +osd-color=0/0/0/0 +hr-seek diff --git a/.config/mpv/scripts/autosub.lua b/.config/mpv/scripts/autosub.lua new file mode 100644 index 0000000..47dfbfe --- /dev/null +++ b/.config/mpv/scripts/autosub.lua @@ -0,0 +1,32 @@ +-- Source: https://github.com/vayan/autosub-mpv/blob/master/autosub.lua + +-- default keybinding: b +-- 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", "-f", "-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("b", "auto_load_subs", load_sub_fn) diff --git a/.config/mpv/scripts/cycle-video-rotate.lua b/.config/mpv/scripts/cycle-video-rotate.lua new file mode 100644 index 0000000..3e56b7b --- /dev/null +++ b/.config/mpv/scripts/cycle-video-rotate.lua @@ -0,0 +1,36 @@ +-- ----------------------------------------------------------- +-- +-- CYCLE-VIDEO-ROTATE.LUA +-- Version: 1.0 +-- Author: VideoPlayerCode +-- URL: https://github.com/VideoPlayerCode/mpv-tools +-- +-- Description: +-- +-- Allows you to perform video rotation which perfectly +-- cycles through all 360 degrees without any glitches. +-- +-- ----------------------------------------------------------- + +function cycle_video_rotate(amt) + -- Ensure that amount is a base 10 integer. + amt = tonumber(amt, 10) + if amt == nil then + mp.osd_message("Rotate: Invalid rotation amount") + return nil -- abort + end + + -- Calculate what the next rotation value should be, + -- and wrap value to correct range (0 (aka 360) to 359). + local newrotate = mp.get_property_number("video-rotate") + newrotate = ( newrotate + amt ) % 360 + + -- Change rotation and tell the user. + mp.set_property_number("video-rotate", newrotate) + mp.osd_message("Rotate: " .. newrotate) +end + +-- Bind this via input.conf. Example: +-- Alt+LEFT script-message Cycle_Video_Rotate -90 +-- Alt+RIGHT script-message Cycle_Video_Rotate 90 +mp.register_script_message("Cycle_Video_Rotate", cycle_video_rotate)