Compare commits
3 Commits
9d0c7dcd96
...
4261c11cb9
Author | SHA1 | Date |
---|---|---|
pta | 4261c11cb9 | |
pta | a98452df95 | |
pta | 502d73b7a1 |
4
mpv.conf
4
mpv.conf
|
@ -1,6 +1,6 @@
|
|||
# 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}
|
||||
osd-status-msg=${playback-time/full} / ${duration} (${percent-pos}%)\nframe: ${estimated-frame-number} / ${estimated-frame-count} / ${mouse-pos} / ${vf}
|
||||
vo=gpu
|
||||
ao=alsa
|
||||
screenshot-template="~/ダウンロード/%F%P%#n"
|
||||
|
@ -9,6 +9,8 @@ demuxer-max-bytes=128M
|
|||
force-window=yes
|
||||
keep-open=yes
|
||||
volume=60
|
||||
sub-auto=fuzzy
|
||||
ytdl-raw-options=ignore-config=,sub-format=ja,write-sub=
|
||||
#reset-on-next-file=volume
|
||||
#osd-level=0
|
||||
#ytdl-format="bestvideo[ext=webm][height<=1080]+bestaudio[ext=webm]/best[ext=webm]/best"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
-- TL;DR
|
||||
-- Ctrl-a to dump ab-loop. Intended for network streams.
|
||||
-- Ctrl-c to get ffplay command for terminal. Works only on files
|
||||
-- Ctrl-c to get ffmpeg command for terminal. Works only on files
|
||||
-- Ctrl-t: like Ctrl-c but covers the ticker on 1080p WNI clips
|
||||
-- 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
|
||||
|
@ -32,18 +33,17 @@ 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
|
||||
-- Copies the ffmpeg 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
|
||||
-- and run it. Add "-an" before the first "-i" to not include audio. Adjust other
|
||||
-- parameters if needed, like the output file, which is /tmp/a.webm by default.
|
||||
-- ffmpeg -i 'file:/home/anon/動画/切り抜き/watch?v=El1YV9tTRAw23080409:45:1717.mkv' -f lavfi -i color=white:s=1698x102 -filter_complex overlay=33:961, -crf 32 -b:v 2200k -ss 2.747000 -to 4.647000 /tmp/a.webm
|
||||
--
|
||||
-- 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
|
||||
-- If you set only the a-point, the copied command won't have the "-to" 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.
|
||||
--
|
||||
|
@ -52,7 +52,7 @@ mp.add_key_binding("ctrl+a", dumploop)
|
|||
-- 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.
|
||||
-- where I can use bash's line editing and history navigation, and see ffmpeg's output.
|
||||
|
||||
require 'mp'
|
||||
require 'mp.msg'
|
||||
|
@ -110,10 +110,10 @@ local function set_clipboard(text)
|
|||
end
|
||||
end
|
||||
|
||||
local function ist(x)
|
||||
local function isto(x)
|
||||
if x == "no"
|
||||
then return ""
|
||||
else return " -t " .. x
|
||||
else return " -to " .. x
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -124,21 +124,45 @@ local function isss(x)
|
|||
end
|
||||
end
|
||||
|
||||
local function copyffplay()
|
||||
local function copyff(x)
|
||||
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:500:0"
|
||||
local vft = mp.get_property_native("vf")
|
||||
local crop_was_set = (#vft > 0)
|
||||
-- added following crop condition check because when manually cropping, placing the
|
||||
-- mouse at the very bottom or right of the fullscreened video doesn't select the last
|
||||
-- row or column of pixels. So this automatically updates the crop to include the
|
||||
-- unselected pixels when within 2 pixels of the bottom or right edge
|
||||
if crop_was_set
|
||||
then
|
||||
local w = mp.get_property_native("width")
|
||||
print(w .. " - (" .. vft[1].params.y .. " + " .. vft[1].params.w .. ")")
|
||||
local wdiff = w - (vft[1].params.x + vft[1].params.w)
|
||||
print("wdiff: " .. wdiff)
|
||||
if wdiff < 3
|
||||
then vft[1].params.w = vft[1].params.w + wdiff
|
||||
end
|
||||
|
||||
local h = mp.get_property_native("height")
|
||||
print(h .. " - (" .. vft[1].params.x .. " + " .. vft[1].params.h .. ")")
|
||||
local hdiff = h - (vft[1].params.y + vft[1].params.h)
|
||||
print("hdiff: " .. hdiff)
|
||||
if hdiff < 3
|
||||
then vft[1].params.h = vft[1].params.h + hdiff
|
||||
end
|
||||
end
|
||||
local c = crop_was_set and ("crop=" .. vft[1].params.w .. ":" .. vft[1].params.h .. ":"
|
||||
.. vft[1].params.x .. ":" .. vft[1].params.y) or ""
|
||||
local vf = not x and crop_was_set and " -vf " .. c or ""
|
||||
local fc = x and " -f lavfi -i color=white:s=1698x102 -filter_complex overlay=33:961," .. c or ""
|
||||
-- constrained quality https://trac.ffmpeg.org/wiki/Encode/VP9#constrainedq
|
||||
local cq = " -crf 32 -b:v 2200k "
|
||||
-- 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
|
||||
-- with the full path to the video, so the copied ffmpeg 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) .. cq .. " -vf " .. c
|
||||
local cmd = "ffmpeg " .. " -i " .. "'file:" .. f .. "'" .. vf .. fc .. cq .. isss(a) .. isto(b) .. " /tmp/a.webm"
|
||||
if set_clipboard(cmd) then
|
||||
mp.osd_message(string.format("Copied to Clipboard: %s", cmd))
|
||||
else
|
||||
|
@ -151,7 +175,11 @@ if platform == UNIX then
|
|||
clipboard_cmd = get_clipboard_cmd()
|
||||
end
|
||||
|
||||
mp.add_key_binding("Ctrl+c", "copyffplay", copyffplay)
|
||||
function copyffn() copyff(nil) end
|
||||
function copyfft() copyff(true) end
|
||||
|
||||
mp.add_key_binding("Ctrl+c", "copyffn", copyffn) -- doesn't include overlay for ticker
|
||||
mp.add_key_binding("Ctrl+t", "copyfft", copyfft) -- "t" for ticker; includes overlay for ticker
|
||||
|
||||
-- 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
|
||||
|
|
Loading…
Reference in New Issue