Giter Site home page Giter Site logo

mpv-scripts's Introduction

mpv-scripts

This is a collection of my own mpv scripts. Valuable contributions have been made by:

  • @zaza42: Linux implementation of boss-key.lua
  • @microraptor: Bug fixes, streamlining, and features to skiptosilence.lua and histogram.lua
  • @vikas5914: macOS implementation of boss-key.lua

boss-key.lua (updated 2023-06-28)

Instantly pauses and minimises the screen at the push of a button (by default b). Called like that because you'd want to hide whatever you're watching when your boss (or mom) walks in.

Supports Windows, macOS, and Linux (X11 only, see requirements).

The default keybind is b. You can change this by adding the following line to your input.conf:

KEY script-binding boss-key

Requirements:

  • Linux users: xdotool. Wayland is currently unsupported. PRs welcome!

skiptosilence.lua (updated 2022-02-27)

This script skips to the next silence in the file. The intended use for this is to skip until the end of an opening or ending sequence, at which point there's often a short period of silence.

The default keybind is F3. You can change this by adding the following line to your input.conf:

KEY script-binding skip-to-silence

In order to tweak the script parameters, you can place the text below in a new file at script-opts/skiptosilence.conf in mpv's user folder. The parameters will be automatically loaded on start.

# Maximum amount of noise to trigger, in terms of dB.
# The default is -30 (yes, negative). -60 is very sensitive,
# -10 is more tolerant to noise.
quietness = -30

# Minimum duration of silence to trigger.
duration = 0.1

# The fast-forwarded audio can sound jarring. Set to 'yes'
# to mute it while skipping.
mutewhileskipping = no

histogram.lua (updated 2022-02-27)

This script exposes a configurable way to overlay ffmpeg histograms in mpv.
There is a substantial amount of config available, but this script does not support config files, because of the nested options. Please edit the options in the opts array in the script itself.

There are three default keybinds:

  • h: Toggle the histogram on/off
  • H (Shift+h): Cycle between the pixel formats available
  • Alt+h: Toggle between linear and logarithmic levels

These keybinds can be changed by placing the following lines in your input.conf:

KEY script-binding toggle-histogram
KEY script-binding cycle-histogram-pixel-format
KEY script-binding cycle-histogram-levels-mode

A note on hardware decoding

The histogram filter is not compatible with hardware decoding. As a result, the default behaviour is to automatically disable any hardware decoding while the filter is on. This behaviour can be changed in the aforementioned opts array.

Waveform version

A version of this script adapted by @MikelSotomonte for displaying waveforms instead can be found at his repo.

Shamelessly stolen example from ffmpeg's wiki

mpv-scripts's People

Contributors

detuur avatar microraptor avatar vikas5914 avatar zaza42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpv-scripts's Issues

The native way of the boss key

Hi! The boss key functionality can be implemented with three consecutive commands in input.conf:
b set pause yes; set fullscreen no; set window-minimized yes

Will Pause, But Won't Minimise

OS: ubuntu 18.04
MPV: mpv git-2019-04-25-71ad1e2

"b" will pause but won't minimise the player; fullscreen and normalscreen.
if you need any more information.

Tips, tricks, and Q&A

Admin edit: This issue thread is not an issue/bug/question per se, but also not something I want to close and put out of sight of new users. A wiki is overkill for this project, so I figured a single pinned thread is a nice, low-barrier-of-entry, and visible approach for simple tricks, tips, and questions. Feel free to share ideas and converse about the project here.

--@detuur

original post:

Nifty way to use Boss-Key.lua with AutoHotKey

This is not an issue thread. I Just thought I'd share something.

I'm using your Boss-Key.lua script with an Autohotkey software combination.

Just in case if you didn't know, AutoHotkey is a free program aimed at providing easy keyboard shortcuts, hotkeys and fast macro-creation.

https://en.wikipedia.org/wiki/AutoHotkey

So the way I'm using your script in conjunction with AutoHotKey is like this:

Whenever the escape button is pressed on my keyboard First the AutoHotKey script that I've set up intercepts that input, modifies it and then sends it in whatever combination you wish/prefer.

So the way I've set it up is that when the escape button is pressed it sends in the Escape Button Command which pauses and minimizes MPV and after that it sends in another command which initiates a second script that removes the window from the windows taskbar effectively hiding whatever you were watching from prying eyes.

Source for the hide window script:
https://www.computoredge.com/AutoHotkey/Downloads/HideWindow.ahk

My AutoHotkey Escape Button Script:

Esc::
sleep 1
Send {Esc}
sleep 3
Send #h
return

skiptosilence.lua causing black screens on videos permanantly

From time to time when I use skiptosilence (f3), it will continue to speed through the video, and mess up the video (make the screen black). I assume this is because it doesn't find an area without sound for some reason so it continues to go without stopping, doing something to the video while its at it. After video is reloaded the video persists to be invisible due to some kind of settting applied by skiptofade script.

Opening a file affected by this issue will spread to other files you open in the same window and make them unwatchable too, and it is really messed up if the user doesn't know what to do, and it has honestly troubled me alot today. (I eventually found a work around by renaming my files to something else)

I currently have a few videos I can't watch anymore because the screen is black (subtitles show, and audio is working) each time I open them they continue to use whatever settings the script did to the video...

Could you resolve this problem? Or help me get my videos working again? I think I need to delete the cache containing details per-video about what settings to use.. and I have no idea where to find that.

Ability to continued skip the silent parts of video

Like the "skip silence" browser extension or Just player, it would be awesome if the script have the ability to skip the silence part of video. In many online class videos, the silent parts are totally waste of time.
The silent skip function of newpie and justpalyer is very powerful, but unfortunately they only available on Android. After a lot of searching it seems that only your script can provide this feature to mpv. Please consider upgrade the script with this feature, it would be very useful !!

Slow startup when using boss-key.lua

There's a noticeable startup delay when using boss-key.lua. If I remove it, player starts instantly. Please do fix it. Other than than that, fantastic.

Histogram doesn't show

Pressing h does nothing and pressing Shift+h or Ctrl+h gives the corresponding OSD messages, but no histogram is displayed.

MPV is loaded with no config or other scripts:
mpv --no-config --load-scripts=no -player-operation-mode=pseudo-gui --log-file=log.txt --script=histogram.lua test.mp4

I am running Ubuntu 20.04 and tried it with multiple video files.

[   0.003][v][cplayer] mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[   0.003][v][cplayer]  built on UNKNOWN
[   0.003][v][cplayer] ffmpeg library versions:
[   0.003][v][cplayer]    libavutil       56.31.100
[   0.003][v][cplayer]    libavcodec      58.54.100
[   0.003][v][cplayer]    libavformat     58.29.100
[   0.003][v][cplayer]    libswscale      5.5.100
[   0.003][v][cplayer]    libavfilter     7.57.100
[   0.003][v][cplayer]    libswresample   3.5.100
[   0.003][v][cplayer] ffmpeg version: 4.2.4-1ubuntu0.1

I added some debug messages:

function toggleFilter()
    local vf_table = mp.get_property_native("vf")
    msg.debug("histdebug 1")
    if #vf_table > 0 then
        msg.debug("2")
        for i = #vf_table, 1, -1 do
            msg.debug("3")
            if vf_table[i].label == "histogram" then
                msg.debug("4")
                for j = i, #vf_table-1 do
                    msg.debug("5")
                    vf_table[j] = vf_table[j+1]
                end
                vf_table[#vf_table] = nil
            else
                msg.debug("6")
                vf_table[#vf_table + 1] = {
                    label="histogram",
                    name="lavfi",
                    params= {
                        graph = buildGraph()
                    }
                }
            end
            mp.set_property_native("vf", vf_table)
            msg.debug("7")
            return
        end
        msg.debug("8")
    end
    msg.debug("9")
end

The log output:

[   3.435][d][cplayer] Run command: script-binding, flags=73, args=["histogram/toggle-histogram"]
[   3.435][d][histogram] histdebug 1 
[   3.436][d][histogram] 9 

#vf_table > 0 returns false apparently and the problem seems to be with the vf_table.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.