first commit
This commit is contained in:
commit
0cd6d549dc
|
@ -0,0 +1,12 @@
|
|||
# My mpv config directory
|
||||
Only the parts I actually use. I use mpv just to watch, clip, and listen to live streams, downloaded idol music and concerts, and videos from any site yt-dlp can handle.
|
||||
|
||||
## Pro tip: use mpv to stream albums from Youtube Music ad-free
|
||||
### Example:
|
||||
1. Go to an album's page. It should be of the form "/playlist?list=<playlist id>"
|
||||
https://music.youtube.com/playlist?list=OLAK5uy_nscRtcc2KZcydiVY7q0feukzm177h8yyw
|
||||
2. Run mpv with the quoted URL
|
||||
```bash
|
||||
mpv 'https://music.youtube.com/playlist?list=OLAK5uy_nscRtcc2KZcydiVY7q0feukzm177h8yyw'
|
||||
```
|
||||
You can even skip songs forwards and backwards like you can with local files using the < and > keys.
|
|
@ -0,0 +1,226 @@
|
|||
# mpv keybindings
|
||||
#
|
||||
# Location of user-defined bindings: ~/.config/mpv/input.conf
|
||||
#
|
||||
# Lines starting with # are comments. Use SHARP to assign the # key.
|
||||
# Copy this file and uncomment and edit the bindings you want to change.
|
||||
#
|
||||
# List of commands and further details: DOCS/man/input.rst
|
||||
# List of special keys: --input-keylist
|
||||
# Keybindings testing mode: mpv --input-test --force-window --idle
|
||||
#
|
||||
# Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore').
|
||||
#
|
||||
# Strings need to be quoted and escaped:
|
||||
# KEY show-text "This is a single backslash: \\ and a quote: \" !"
|
||||
#
|
||||
# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with
|
||||
# the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal).
|
||||
#
|
||||
# The default keybindings are hardcoded into the mpv binary.
|
||||
# You can disable them completely with: --no-input-default-bindings
|
||||
|
||||
# Developer note:
|
||||
# On compilation, this file is baked into the mpv binary, and all lines are
|
||||
# uncommented (unless '#' is followed by a space) - thus this file defines the
|
||||
# default key bindings.
|
||||
|
||||
# If this is enabled, treat all the following bindings as default.
|
||||
#default-bindings start
|
||||
|
||||
#MBTN_LEFT ignore # don't do anything
|
||||
#MBTN_LEFT_DBL cycle fullscreen # toggle fullscreen on/off
|
||||
#MBTN_RIGHT cycle pause # toggle pause on/off
|
||||
#MBTN_BACK playlist-prev
|
||||
#MBTN_FORWARD playlist-next
|
||||
|
||||
# Mouse wheels, touchpad or other input devices that have axes
|
||||
# if the input devices supports precise scrolling it will also scale the
|
||||
# numeric value accordingly
|
||||
#WHEEL_UP seek 10
|
||||
#WHEEL_DOWN seek -10
|
||||
#WHEEL_LEFT add volume -2
|
||||
#WHEEL_RIGHT add volume 2
|
||||
|
||||
## Seek units are in seconds, but note that these are limited by keyframes
|
||||
RIGHT seek 2
|
||||
LEFT seek -2
|
||||
#UP seek 60
|
||||
#DOWN seek -60
|
||||
# Do smaller, always exact (non-keyframe-limited), seeks with shift.
|
||||
# Don't show them on the OSD (no-osd).
|
||||
#Shift+RIGHT no-osd seek 1 exact
|
||||
#Shift+LEFT no-osd seek -1 exact
|
||||
#Shift+UP no-osd seek 5 exact
|
||||
#Shift+DOWN no-osd seek -5 exact
|
||||
# Skip to previous/next subtitle (subject to some restrictions; see manpage)
|
||||
#Ctrl+LEFT no-osd sub-seek -1
|
||||
#Ctrl+RIGHT no-osd sub-seek 1
|
||||
# Adjust timing to previous/next subtitle
|
||||
#Ctrl+Shift+LEFT sub-step -1
|
||||
#Ctrl+Shift+RIGHT sub-step 1
|
||||
# Move video rectangle
|
||||
Alt+left add video-pan-x 0.01
|
||||
Alt+right add video-pan-x -0.01
|
||||
Alt+up add video-pan-y 0.01
|
||||
Alt+down add video-pan-y -0.01
|
||||
# Zoom/unzoom video
|
||||
Alt++ add video-zoom 0.01
|
||||
Alt+- add video-zoom -0.01
|
||||
# Reset video zoom/pan settings
|
||||
#Alt+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0
|
||||
#PGUP add chapter 1 # skip to next chapter
|
||||
#PGDWN add chapter -1 # skip to previous chapter
|
||||
#Shift+PGUP seek 600
|
||||
#Shift+PGDWN seek -600
|
||||
#[ multiply speed 1/1.1 # scale playback speed
|
||||
#] multiply speed 1.1
|
||||
#{ multiply speed 0.5
|
||||
#} multiply speed 2.0
|
||||
#BS set speed 1.0 # reset speed to normal
|
||||
#Shift+BS revert-seek # undo previous (or marked) seek
|
||||
#Shift+Ctrl+BS revert-seek mark # mark position for revert-seek
|
||||
#q quit
|
||||
#Q quit-watch-later
|
||||
#q {encode} quit 4
|
||||
#ESC set fullscreen no
|
||||
#ESC {encode} quit 4
|
||||
#p cycle pause # toggle pause/playback mode
|
||||
#. frame-step # advance one frame and pause
|
||||
#, frame-back-step # go back by one frame and pause
|
||||
#SPACE cycle pause
|
||||
#> playlist-next # skip to next file
|
||||
#ENTER playlist-next # skip to next file
|
||||
#< playlist-prev # skip to previous file
|
||||
#O no-osd cycle-values osd-level 3 1 # cycle through OSD mode
|
||||
#o show-progress
|
||||
#P show-progress
|
||||
#i script-binding stats/display-stats
|
||||
#I script-binding stats/display-stats-toggle
|
||||
#` script-binding console/enable
|
||||
#z add sub-delay -0.1 # subtract 100 ms delay from subs
|
||||
#Z add sub-delay +0.1 # add
|
||||
#x add sub-delay +0.1 # same as previous binding (discouraged)
|
||||
#ctrl++ add audio-delay 0.100 # this changes audio/video sync
|
||||
#ctrl+- add audio-delay -0.100
|
||||
#Shift+g add sub-scale +0.1 # increase subtitle font size
|
||||
#Shift+f add sub-scale -0.1 # decrease subtitle font size
|
||||
#9 add volume -2
|
||||
#/ add volume -2
|
||||
#0 add volume 2
|
||||
#* add volume 2
|
||||
#m cycle mute
|
||||
#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
|
||||
#Alt+0 set window-scale 0.5
|
||||
#Alt+1 set window-scale 1.0
|
||||
#Alt+2 set window-scale 2.0
|
||||
# toggle deinterlacer (automatically inserts or removes required filter)
|
||||
#d cycle deinterlace
|
||||
#r add sub-pos -1 # move subtitles up
|
||||
#R add sub-pos +1 # down
|
||||
#t add sub-pos +1 # same as previous binding (discouraged)
|
||||
#v cycle sub-visibility
|
||||
# stretch SSA/ASS subtitles with anamorphic videos to match historical
|
||||
#V cycle sub-ass-vsfilter-aspect-compat
|
||||
# switch between applying no style overrides to SSA/ASS subtitles, and
|
||||
# overriding them almost completely with the normal subtitle style
|
||||
#u cycle-values sub-ass-override "force" "no"
|
||||
#j cycle sub # cycle through subtitles
|
||||
#J cycle sub down # ...backwards
|
||||
#SHARP cycle audio # switch audio streams
|
||||
#_ cycle video
|
||||
#T cycle ontop # toggle video window ontop of other windows
|
||||
#f cycle fullscreen # toggle fullscreen
|
||||
#s screenshot # take a screenshot
|
||||
#S screenshot video # ...without subtitles
|
||||
#Ctrl+s screenshot window # ...with subtitles and OSD, and scaled
|
||||
#Alt+s screenshot each-frame # automatically screenshot every frame
|
||||
#w add panscan -0.1 # zoom out with -panscan 0 -fs
|
||||
#W add panscan +0.1 # in
|
||||
#e add panscan +0.1 # same as previous binding (discouraged)
|
||||
# cycle video aspect ratios; "-1" is the container aspect
|
||||
#A cycle-values video-aspect-override "16:9" "4:3" "2.35:1" "-1"
|
||||
#POWER quit
|
||||
#PLAY cycle pause
|
||||
#PAUSE cycle pause
|
||||
#PLAYPAUSE cycle pause
|
||||
#PLAYONLY set pause no
|
||||
#PAUSEONLY set pause yes
|
||||
#STOP quit
|
||||
#FORWARD seek 60
|
||||
#REWIND seek -60
|
||||
#NEXT playlist-next
|
||||
#PREV playlist-prev
|
||||
#VOLUME_UP add volume 2
|
||||
#VOLUME_DOWN add volume -2
|
||||
#MUTE cycle mute
|
||||
#CLOSE_WIN quit
|
||||
#CLOSE_WIN {encode} quit 4
|
||||
#ctrl+w quit
|
||||
#E cycle edition # next edition
|
||||
#l ab-loop # Set/clear A-B loop points
|
||||
#L cycle-values loop-file "inf" "no" # toggle infinite looping
|
||||
#ctrl+c quit 4
|
||||
#DEL script-binding osc/visibility # cycle OSC display
|
||||
#ctrl+h cycle-values hwdec "auto" "no" # cycle hardware decoding
|
||||
#F8 show_text ${playlist} # show playlist
|
||||
#F9 show_text ${track-list} # show list of audio/sub streams
|
||||
|
||||
#
|
||||
# Legacy bindings (may or may not be removed in the future)
|
||||
#
|
||||
#! add chapter -1 # skip to previous chapter
|
||||
#@ add chapter 1 # next
|
||||
|
||||
#
|
||||
# Not assigned by default
|
||||
# (not an exhaustive list of unbound commands)
|
||||
#
|
||||
|
||||
# ? cycle angle # switch DVD/Bluray angle
|
||||
# ? cycle sub-forced-only # toggle DVD forced subs
|
||||
# ? cycle program # cycle transport stream programs
|
||||
# ? stop # stop playback (quit or enter idle mode)
|
||||
|
||||
# imported from mpv-scripts git repo
|
||||
# crop.lua
|
||||
# ==========
|
||||
# start cropping
|
||||
#c script-message-to crop start-crop hard
|
||||
#alt+c script-message-to crop start-crop soft
|
||||
# delogo mode can be used like so
|
||||
#l script-message-to crop start-crop delogo
|
||||
# remove the crop
|
||||
d vf del -1
|
||||
|
||||
# or use the ready-made "toggle" binding
|
||||
#C script-message-to crop toggle-crop hard
|
||||
|
||||
# remove the soft zoom
|
||||
#0 set video-pan-x 0; set video-pan-y 0; set video-zoom 0
|
||||
|
||||
# encode.lua
|
||||
# ============
|
||||
# use default profile (makes vp8 webms)
|
||||
# e script-message-to encode set-timestamp
|
||||
|
||||
# # use custom webm profile, the argument name must correspond to an existing .conf file (see script-opts/)
|
||||
# alt+e script-message-to encode set-timestamp encode_webm
|
||||
|
||||
# # use custom profile
|
||||
# E script-message-to encode set-timestamp encode_slice
|
||||
|
||||
# # blur-edges.lua
|
||||
# # ================
|
||||
# b script-message-to blur_edges toggle-blur
|
||||
|
||||
# # seek-to.lua
|
||||
# # =============
|
||||
# t script-message-to seek_to toggle-seeker
|
|
@ -0,0 +1,56 @@
|
|||
# taken from https://github.com/mpv-player/mpv/issues/3428
|
||||
# mouse position added to ease getting coordinates for overlay filters in ffmpeg
|
||||
osd-status-msg=${playback-time/full} / ${duration} (${percent-pos}%)\nframe: ${estimated-frame-number} / ${estimated-frame-count} / ${mouse-pos}
|
||||
vo=gpu
|
||||
ao=alsa
|
||||
screenshot-template="~/ダウンロード/%F%P%#n"
|
||||
cache=yes
|
||||
demuxer-max-bytes=128M
|
||||
force-window=yes
|
||||
keep-open=yes
|
||||
volume=60
|
||||
#reset-on-next-file=volume
|
||||
#osd-level=0
|
||||
ytdl-format="bestvideo[ext=webm][height<=1080]+bestaudio[ext=webm]/best[ext=webm]/best"
|
||||
#script-opts=ytdl_hook-ytdl_path=/usr/bin/yt-dlp
|
||||
volume-max=170
|
||||
#msg-level=all=no
|
||||
#scripts=~/.config/mpv/mpv-scripts/scripts/crop.lua:~/.config/mpv/mpv-scripts/scripts/encode.lua
|
||||
#script-opts=~/.config/mpv/mpv-scripts/script-opts/crop.conf
|
||||
#script-opts=~/.config/mpv/mpv-scripts/script-opts/encode_webm.conf
|
||||
|
||||
[pulse]
|
||||
profile-cond=os.getenv("HOSTNAME") == "cb"
|
||||
ao=pulse
|
||||
|
||||
# this does 720p60 video + best opus audio
|
||||
[mid]
|
||||
ytdl-format=302+251
|
||||
|
||||
[worst]
|
||||
ytdl-format=worstvideo+worstaudio
|
||||
|
||||
# youtube, I don't remember what videos I used this profile for
|
||||
[yt]
|
||||
ytdl-format=136+140/mp4/bestaudio
|
||||
|
||||
# twitch clips
|
||||
[tw]
|
||||
ytdl-format=720
|
||||
|
||||
# for laggy twitch live streams
|
||||
[live]
|
||||
#cache-pause=no
|
||||
#demuxer-lavf-o-add=fflags=+nobuffer
|
||||
#demuxer-lavf-probe-info=nostreams
|
||||
#demuxer-lavf-analyzeduration=0.1
|
||||
#video-sync=audio
|
||||
#interpolation=no
|
||||
#video-latency-hacks=yes
|
||||
#stream-buffer-size=4k
|
||||
ytdl-format=720p60/720p/720p__source_/1080p__source_/best
|
||||
#ytdl-raw-options=ignore-config=
|
||||
#framedrop=vo
|
||||
|
||||
#[protocol.https]
|
||||
#demuxer-max-bytes=1256M
|
|
@ -0,0 +1,158 @@
|
|||
-- TL;DR
|
||||
-- Ctrl-a to dump ab-loop. Intended for network streams.
|
||||
-- Ctrl-c to get ffplay command for terminal. Works only on files
|
||||
-- But first change the cache dumps directory to your preferred directory
|
||||
|
||||
-- Dumps the contents of the demuxer cache that's inside your selected ab-loop to a file
|
||||
-- in a configured directory. No reason to use this on local files since ffmpeg can
|
||||
-- operate on those.
|
||||
--
|
||||
-- I have "demuxer-max-bytes=128M" in my mpv.conf, which usually keeps the last 3-15
|
||||
-- minutes of the stream in memory, depending on the bitrate, so I have that much time to
|
||||
-- rewind the streams and clip something. I'm sure the clip channels on youtube use a larger
|
||||
-- cache setting or even save the whole stream to a file for editing and uploading
|
||||
-- quickly. Their workflow is likely more efficient.
|
||||
--
|
||||
-- The key to set the ab-loop is by default set to "l". Be careful when dumping. If you
|
||||
-- have the a-point but not the b-point set, it will continuously dump the entire cache up
|
||||
-- to the present and I haven't found out how to stop it besides closing mpv. Look up
|
||||
-- "ab-loop" in the mpv man page for further information.
|
||||
function dumploop()
|
||||
mp.command("ab-loop-align-cache")
|
||||
mp.command("ab-loop-dump-cache "
|
||||
-- the following 2 lines won't work on Windows, I think.
|
||||
.. os.getenv("HOME")
|
||||
.. "/動画/切り抜き/" -- my cache dumps directory. Adjust to your system.
|
||||
-- spaces in filenames replaced with an underscore (or any non-space char),
|
||||
-- needed because lua splits filenames on spaces
|
||||
.. string.gsub(mp.get_property("filename"), "%s", "_")
|
||||
.. os.date("%y%m%d%X%S")
|
||||
.. ".mkv");
|
||||
end
|
||||
mp.add_key_binding("ctrl+a", dumploop)
|
||||
|
||||
-- All code below copied from https://github.com/Arieleg/mpv-copyTime and modified
|
||||
-- Copies the ffplay command for the selected ab-loop to the clipboard. Use on local video
|
||||
-- files, not on network streams
|
||||
--
|
||||
-- This script puts a string like this into your clipboard, so just paste into a terminal
|
||||
-- and adjust crop parameters as needed, run it to preview the crop, then when ready to
|
||||
-- encode, replace "ffplay" with "ffmpeg" and add a filename at the end of the
|
||||
-- line. Optionally add bitrate/crf/other ffmpeg options as needed.
|
||||
-- ffplay -t 23.647000 -i 'file:/home/anon/動画/切り抜き/watch?v=aYAH0IlTMXQ23072509:29:1515.mkv' -ss 21.980000 -vf crop=900:ih-119:400:0
|
||||
--
|
||||
-- If you set only the a-point, the copied command won't have the "-t" (duration) setting,
|
||||
-- so the result webm will start from the a-point and end at end-of-file. And if you don't
|
||||
-- set the loop at all, the command will transcode the entire clip
|
||||
-- Tip: pause and use the , and . keys to skip frames to the exact loop points you want for
|
||||
-- the webm, then hit "l" to set the loop point.
|
||||
--
|
||||
-- TODO: copy the code to set start and end points separately at any time from
|
||||
-- https://github.com/ekisu/mpv-webm/releases/download/latest/webm.lua or
|
||||
-- https://github.com/occivink/mpv-scripts/blob/master/scripts/encode.lua
|
||||
-- Yes, I know these scripts are more convenient overall, but webm.lua doesn't work on one
|
||||
-- of my machines for some reason. And I prefer encoding on the command line anyways,
|
||||
-- where I can use bash's line editing and history navigation.
|
||||
|
||||
require 'mp'
|
||||
require 'mp.msg'
|
||||
|
||||
WINDOWS = 2
|
||||
UNIX = 3
|
||||
|
||||
local function platform_type()
|
||||
local utils = require 'mp.utils'
|
||||
local workdir = utils.to_string(mp.get_property_native("working-directory"))
|
||||
if string.find(workdir, "\\") then
|
||||
return WINDOWS
|
||||
else
|
||||
return UNIX
|
||||
end
|
||||
end
|
||||
|
||||
local function command_exists(cmd)
|
||||
local pipe = io.popen("type " .. cmd .. " > /dev/null 2> /dev/null; printf \"$?\"", "r")
|
||||
exists = pipe:read() == "0"
|
||||
pipe:close()
|
||||
return exists
|
||||
end
|
||||
|
||||
local function get_clipboard_cmd()
|
||||
if command_exists("xclip") then
|
||||
return "xclip -silent -in -selection clipboard"
|
||||
elseif command_exists("wl-copy") then
|
||||
return "wl-copy"
|
||||
elseif command_exists("pbcopy") then
|
||||
return "pbcopy"
|
||||
else
|
||||
mp.msg.error("No supported clipboard command found")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Not used anywhere
|
||||
-- local function divmod(a, b)
|
||||
-- return a / b, a % b
|
||||
-- end
|
||||
|
||||
local function set_clipboard(text)
|
||||
if platform == WINDOWS then
|
||||
mp.commandv("run", "powershell", "set-clipboard", text)
|
||||
return true
|
||||
elseif (platform == UNIX and clipboard_cmd) then
|
||||
local pipe = io.popen(clipboard_cmd, "w")
|
||||
pipe:write(text)
|
||||
pipe:close()
|
||||
return true
|
||||
else
|
||||
mp.msg.error("Set_clipboard error")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function ist(x)
|
||||
if x == "no"
|
||||
then return ""
|
||||
else return " -t " .. x
|
||||
end
|
||||
end
|
||||
|
||||
local function isss(x)
|
||||
if x == "no"
|
||||
then return ""
|
||||
else return " -ss " .. x
|
||||
end
|
||||
end
|
||||
|
||||
local function copyffplay()
|
||||
local a = mp.get_property("ab-loop-a")
|
||||
local b = mp.get_property("ab-loop-b")
|
||||
-- default crops setting to start with (puts the crop at about the center of the screen).
|
||||
-- Subtracting 119 from the input height is just enough to crop the ticker off the
|
||||
-- bottom of the weathernews stream
|
||||
local c = "crop=900:ih-119:400:0"
|
||||
-- I usually run mpv from Dired in emacs, using the "openwith" package, which calls mpv
|
||||
-- with the full path to the video, so the copied ffplay command can find the file from
|
||||
-- any working-directory. Running mpv from the shell sets the mpv's "path" property to
|
||||
-- whatever path you used on the command line.
|
||||
local f = mp.get_property("path")
|
||||
local cmd = "ffplay " .. ist(b) .. " -i " .. "'file:" .. f .. "'" .. isss(a) .. " -vf " .. c
|
||||
if set_clipboard(cmd) then
|
||||
mp.osd_message(string.format("Copied to Clipboard: %s", cmd))
|
||||
else
|
||||
mp.osd_message("Failed to copy command to clipboard")
|
||||
end
|
||||
end
|
||||
|
||||
platform = platform_type()
|
||||
if platform == UNIX then
|
||||
clipboard_cmd = get_clipboard_cmd()
|
||||
end
|
||||
|
||||
mp.add_key_binding("Ctrl+c", "copyffplay", copyffplay)
|
||||
|
||||
-- Extra: This example command includes options to cover the ticker with solid
|
||||
-- white. Sometimes used when I want to preserve the very bottom of the clip and crop the
|
||||
-- sides at the same time (Covering the ticker saves file size since encoding movement
|
||||
-- uses more data than static pixels)
|
||||
-- ffmpeg -an -i "watch?v=fEVgqziY5RM23062707:28:3333.mkv" -f lavfi -i "color=white:s=1698x102" -filter_complex "overlay=33:961,crop=650:ih:1100:0" /tmp/a.webm
|
|
@ -0,0 +1,15 @@
|
|||
# sourced from ~/.shellaliases.sh, which is in turn sourced by ~/.bashrc
|
||||
# ~/.shellaliases.sh is where I keep functions, aliases, and variables not specific to
|
||||
# bash, in case I want to source them from another shell
|
||||
#
|
||||
# I'll eventually integrate my entire shell config into my Nix home-manager config
|
||||
alias tbs='mpv https://tbs3.mov3.co/hls/tbs.m3u8' \
|
||||
ntv='mpv https://ntv4.mov3.co/hls/ntv.m3u8' \
|
||||
fujitv='mpv https://fujitv4.mov3.co/hls/fujitv.m3u8'
|
||||
|
||||
alias ffmpeg="ffmpeg -benchmark "
|
||||
|
||||
# How I take screenshots. Change the output directory suit your system.
|
||||
# Documented under "INPUT DEVICES" > "x11grab" in ffmpeg-all man page
|
||||
alias sc='ffmpeg -y -f x11grab -video_size 1920x1080 -select_region 1 -i $DISPLAY \
|
||||
-vframes 1 ~/写真/スクショ/$(date +"%g%m%d_%R:%S").jpg'
|
Loading…
Reference in New Issue