aboutsummaryrefslogtreecommitdiffstats
path: root/mpv
diff options
context:
space:
mode:
authorErik Sandström <erik@kyriasis.com>2015-01-05 23:10:09 +0100
committerErik Sandström <erik@kyriasis.com>2015-01-05 23:10:09 +0100
commit41de2acd4376f201bee9467c94c65ec0cfdc6648 (patch)
tree61031f21ca42ce2643a404abb661bacffaf5356c /mpv
parent07ea0ae2cb3bd14b67e47b0381ba1937acd0c68d (diff)
downloaddotfiles-41de2acd4376f201bee9467c94c65ec0cfdc6648.tar.xz
updated mpv configs
Diffstat (limited to 'mpv')
-rw-r--r--mpv/config14
-rw-r--r--mpv/input.conf5
-rw-r--r--mpv/lua/convert_script.lua319
-rwxr-xr-xmpv/mvtools.vpy15
4 files changed, 350 insertions, 3 deletions
diff --git a/mpv/config b/mpv/config
index 851482f..c68c008 100644
--- a/mpv/config
+++ b/mpv/config
@@ -1,8 +1,14 @@
# misc settings
no-osc
hwdec=vaapi
-vo=vaapi
-framedrop=no
+vo=opengl-hq:srgb:approx-gamma
+#vo=opengl-hq:lscale=lanczos:cscale=lanczos:lradius=8.0:cradius=4.0:dither-depth=auto:temporal-dither:scaler-resizes-only:fancy-downscaling:pbo:fbo-format=rgba32f:srgb:approx-gamma
+#vf=format=yuv420p,vapoursynth=/home/zephcom/.mpv/mvtools.vpy:2:4
+framedrop=vo
+cache=262144
+geometry=50%:50%
+autofit=1152x648
+save-position-on-quit=yes
# Pretty srt font!
osd-font="Liberation Sans"
@@ -11,13 +17,15 @@ sub-text-font-size=64
sub-text-margin-y=36
sub-text-color="#ffffffff"
sub-text-border-color="#ff000000"
-sub-text-border-size=3.5
+sub-text-border-size=5.5
sub-text-shadow-offset=1
sub-text-shadow-color="#00000000"
sub-text-spacing=-0.2
# screenshots
screenshot-format="png"
+screenshot-png-filter=0
+screenshot-png-compression=4
# loop weebums
[extension.webm]
diff --git a/mpv/input.conf b/mpv/input.conf
new file mode 100644
index 0000000..502d7ff
--- /dev/null
+++ b/mpv/input.conf
@@ -0,0 +1,5 @@
+F1 set aspect 1.3333
+F2 set aspect 1.6
+F3 set aspect 1.7777
+F4 set aspect 1.85
+F5 set aspect 0
diff --git a/mpv/lua/convert_script.lua b/mpv/lua/convert_script.lua
new file mode 100644
index 0000000..04fa508
--- /dev/null
+++ b/mpv/lua/convert_script.lua
@@ -0,0 +1,319 @@
+-- README:
+-- original version by Zehkul https://gist.github.com/Zehkul/25ea7ae77b30af959be0
+-- needs: yad, libnotify (and --ytdl if you want to encode from streams)
+-- press any of alt + w, g or x to set the start frame
+-- press again to set the end frame and use
+-- alt + w to make a webm
+-- alt + g to make a gif
+-- alt + x to make a x264 encoded mkv
+
+-- Note: encoding a webm to a specific filesize will only work if audio is disabled
+-- and including subs will make them lose their styling
+
+local msg = require 'mp.msg'
+local opt = require 'mp.options'
+local mputils = require 'mp.utils'
+
+-- default options, convert_script.conf is read
+local options = {
+ bitrate_multiplier = 0.975, -- to make sure the file won’t go over the target file size, set it to 1 if you don’t care
+}
+
+read_options(options, "convert_script_webm")
+read_options(options, "convert_script_gif")
+read_options(options, "convert_script_x264")
+
+-----------------
+-- Main script --
+-----------------
+
+function set_timepos(func)
+
+ if timepos1 then
+
+ timepos2 = mp.get_property("time-pos")
+ timepos2_humanreadable = mp.get_property_osd("time-pos")
+
+ if tonumber(timepos1) > tonumber(timepos2) then
+
+ length = timepos1-timepos2
+ start = timepos2
+ start_humanreadable = timepos2_humanreadable
+ end_humanreadable = timepos1_humanreadable
+ msg.info("End frame set")
+
+ elseif tonumber(timepos2) > tonumber(timepos1) then
+
+ length = timepos2-timepos1
+ start = timepos1
+ start_humanreadable = timepos1_humanreadable
+ end_humanreadable = timepos2_humanreadable
+ msg.info("End frame set")
+
+ else
+
+ msg.error("Both frames are the same, ignoring the second one")
+ mp.osd_message("Both frames are the same, ignoring the second one")
+ timepos2 = nil
+ return
+
+ end
+
+ timepos1 = nil
+ func.call_gui()
+
+ else
+
+ timepos1 = mp.get_property("time-pos")
+ timepos1_humanreadable = mp.get_property_osd("time-pos")
+ msg.info("Start frame set")
+ mp.osd_message("Start frame set")
+
+ end
+
+end
+
+function convert_script_hotkey_call_webm ()
+
+ func = {
+ call_gui = call_gui_webm
+ }
+
+ set_timepos(func)
+
+end
+
+function convert_script_hotkey_call_gif ()
+
+ func = {
+ call_gui = call_gui_gif
+ }
+
+ set_timepos(func)
+
+end
+
+function convert_script_hotkey_call_x264 ()
+
+ func = {
+ call_gui = call_gui_x264
+ }
+
+ set_timepos(func)
+
+end
+
+------------
+-- Encode --
+------------
+
+function generate_filenames(ext)
+
+ local filename_ext = mp.get_property_osd("filename")
+ filename_ext = string.gsub(filename_ext, "'", "'\\''")
+ local filename = string.gsub(filename_ext, "%....$","")
+
+ if string.len(filename) > 230 then
+
+ filename = mp.get_property("options/title")
+ if filename == 'mpv - ${media-title}' or string.len(filename) > 230 then
+ filename = 'output'
+ end
+
+ end
+
+ local path = mp.get_property("path", "")
+ local dir, fil = mputils.split_path(path)
+
+ file_in = dir .. fil
+ file_out = dir .. filename .. "-out." .. ext
+
+ file_in = string.gsub(file_in, "'", "'\\''")
+ file_out = string.gsub(file_out, "'", "'\\''")
+
+ if string.sub(file_in,1,string.len("http")) == "http" then
+
+ file_in = mp.get_property("stream-open-filename")
+ file_out = os.getenv("HOME") .. "/" .. mp.get_property("media-title") .. "-out." .. ext
+ file_out = string.gsub(file_out, "'", "'\\''")
+
+ end
+
+end
+
+function encode_webm ()
+
+ generate_filenames("webm")
+
+ local full_command = '(ffmpeg -ss ' .. start .. ' -i \'' .. file_in .. '\' -t ' .. length .. ' -b:v ' .. bitrate .. bitsize .. ' -vf scale=' .. scale .. ':-1 -quality good -cpu-used 0 -pass 1 ' .. audio .. ' ' .. subs .. ' -f webm /dev/null -y'
+
+ full_command = full_command .. ' && ffmpeg -ss ' .. start .. ' -i \'' .. file_in .. '\' -t ' .. length .. ' -b:v ' .. bitrate .. bitsize .. ' -vf scale=' .. scale .. ':-1 -quality good -cpu-used 0 -pass 2 ' .. audio .. ' ' .. subs .. ' -f webm \'' .. file_out .. '\' -y'
+
+ full_command = full_command .. ') && notify-send "Encode done!"'
+
+ msg.info(full_command)
+ os.execute(full_command)
+
+end
+
+function encode_gif ()
+
+ generate_filenames("gif")
+
+ local full_command = '(ffmpeg -ss ' .. start .. ' -i \'' .. file_in .. '\' -t ' .. length .. ' -vf scale=' .. scale .. ':-1 -r ' .. fps .. ' \'' .. file_out .. '\' -y'
+
+ full_command = full_command .. ') && notify-send "Encode done!"'
+
+ msg.info(full_command)
+ os.execute(full_command)
+
+end
+
+function encode_x264 ()
+
+ generate_filenames("mkv")
+
+ local full_command = '(ffmpeg -ss ' .. start .. ' -i \'' .. file_in .. '\' -t ' .. length .. ' -c:v libx264 -vf scale=' .. sheight .. ':' .. swidth .. ' -preset slow -qp ' .. quality .. ' -c:a copy -c:s copy -map 0 \'' .. file_out .. '\' -y'
+
+ full_command = full_command .. ') && notify-send "Encode done! (' .. quality .. ')"'
+
+ msg.info(full_command)
+ os.execute(full_command)
+
+end
+
+---------
+-- GUI --
+---------
+
+function call_gui_webm ()
+
+ mp.resume_all()
+ local handle = io.popen('yad --title="Convert Script" --center --form --separator="\n" --field="Resize to:NUM" "720" --field="Don’t resize at all:CHK" "false" --field="Include audio:CHK" "false" --field="Include subs:CHK" "false" --field="Bitrate/Filesize (M):NUM" "3" --field="Filesize > Bitrate:CHK" "true" --button="gtk-cancel:2" --button="gtk-ok:0" && echo "$?"')
+ local yad = handle:read("*a")
+ handle:close()
+
+ if yad == "" then
+ return
+ end
+
+ local yad_table = {}
+
+ local i = 0
+ for k in string.gmatch(yad, "[%a%d]+") do
+ yad_table[i] = k
+ i = i + 1
+ end
+
+ if (yad_table[2] == "FALSE") then
+ scale = yad_table[0]
+ else
+ scale = "-1"
+ end
+
+ if yad_table[3] == "FALSE" then
+ audio = '-an'
+ else
+ audio = ""
+ end
+
+ if yad_table[4] == "FALSE" then
+ subs = '-sn'
+ else
+ subs = ""
+ end
+
+ if yad_table[7] == "TRUE" then
+ bitrate = math.floor(yad_table[5]*1024*8/length*options.bitrate_multiplier)
+ bitsize = "K"
+ else
+ bitrate = yad_table[5]
+ bitsize = "M"
+ end
+
+ if yad_table[8] == "0" then
+ encode_webm()
+ end
+
+end
+
+function call_gui_gif ()
+
+ mp.resume_all()
+ local handle = io.popen('yad --title="Convert Script" --center --form --separator="\n" --field="Resize to:NUM" "320" --field="Don’t resize at all:CHK" "false" --field="FPS:NUM" "24" --button="gtk-cancel:2" --button="gtk-ok:0" && echo "$?"')
+ local yad = handle:read("*a")
+ handle:close()
+
+ if yad == "" then
+ return
+ end
+
+ local yad_table = {}
+
+ local i = 0
+ for k in string.gmatch(yad, "[%a%d]+") do
+ yad_table[i] = k
+ i = i + 1
+ end
+
+ if (yad_table[2] == "FALSE") then
+ scale = yad_table[0]
+ else
+ scale = "-1"
+ end
+
+ fps = yad_table[3]
+
+ if yad_table[5] == "0" then
+ encode_gif()
+ end
+
+end
+
+function call_gui_x264 ()
+
+ mp.resume_all()
+ local handle = io.popen('yad --title="Convert Script" --center --form --separator="\n" --field="Resize height:NUM" "720" --field="Resize width:NUM" "480" --field="Don’t resize at all:CHK" "true" --field="Quality (0-51):NUM" "18" --button="gtk-cancel:2" --button="gtk-ok:0" && echo "$?"')
+ local yad = handle:read("*a")
+ handle:close()
+
+ if yad == "" then
+ return
+ end
+
+ local yad_table = {}
+
+ local i = 0
+ for k in string.gmatch(yad, "[%a%d]+") do
+ yad_table[i] = k
+ i = i + 1
+ end
+
+ if (yad_table[4] == "FALSE") then
+ sheight = yad_table[0]
+ else
+ sheight = "-1"
+ end
+
+ if (yad_table[4] == "FALSE") then
+ swidth = yad_table[2]
+ else
+ swidth = "-1"
+ end
+
+ if ((sheight ~= "-1" and swidth ~= "-1") and (tonumber(sheight)%2 ~= 0 or tonumber(swidth)%2 ~= 0)) then
+ os.execute('notify-send "' .. sheight ..':' .. swidth .. '"')
+ return
+ end
+
+ quality = yad_table[5];
+
+ if yad_table[7] == "0" then
+ encode_x264()
+ end
+
+end
+
+mp.add_key_binding("alt+w", "convert_script_webm", convert_script_hotkey_call_webm)
+mp.add_key_binding("alt+g", "convert_script_gif", convert_script_hotkey_call_gif)
+mp.add_key_binding("alt+x", "convert_script_x264", convert_script_hotkey_call_x264)
diff --git a/mpv/mvtools.vpy b/mpv/mvtools.vpy
new file mode 100755
index 0000000..8fe5c5a
--- /dev/null
+++ b/mpv/mvtools.vpy
@@ -0,0 +1,15 @@
+import vapoursynth as vs
+core = vs.get_core()
+
+clip = video_in
+
+if clip.width > 1920 or clip.height > 1080:
+ # Skip interpolation due to performance
+ clip.set_output()
+else:
+ sup = core.mv.Super(clip, pel=2, hpad=0, vpad=0)
+ bvec = core.mv.Analyse(sup, blksize=16, isb=True , chroma=True, search=5, searchparam=1)
+ fvec = core.mv.Analyse(sup, blksize=16, isb=False, chroma=True, search=5, searchparam=1)
+# clip = core.mv.BlockFPS(clip, sup, bvec, fvec, num=60, den=1, mode=3, thscd2=13)
+
+ clip.set_output()