README.md (7592B)
1 # mpv2oboeru 2 3 mpv2oboeru is a semi-automatic subs2srs helper for mpv. 4 It started as a fork of [mpvacious](https://github.com/Ajatt-Tools/mpvacious). 5 6 ## Table of contents 7 8 * [Requirements](#requirements) 9 * [Installation](#installation) 10 * [Manually](#manually) 11 * [Using git](#using-git) 12 * [Updating with git](#updating-with-git) 13 * [Configuration](#configuration) 14 * [Usage](#usage) 15 * [Global bindings](#global-bindings) 16 * [Menu options](#menu-options) 17 * [Other tools](#other-tools) 18 * [Profiles](#profiles) 19 * [Hacking](#hacking) 20 21 ## Requirements 22 23 * mpv 24 * xclip - when using X11 25 * wl-copy - when using Wayland 26 27 ## Installation 28 29 ### Manually 30 31 Download 32 [the repository](https://github.com/0x766F6964/mpv2oboeru/archive/refs/heads/master.zip) 33 and extract the folder containing 34 [subs2srs.lua](https://raw.githubusercontent.com/0x766F6964/mpv2oboeru/master/subs2srs.lua) 35 to your [mpv scripts](https://github.com/mpv-player/mpv/wiki/User-Scripts) directory: 36 37 ~/.config/mpv/scripts/ 38 39 ### Using git 40 41 If you already have your dotfiles set up similar to 42 [Arch Wiki recommendations](https://wiki.archlinux.org/index.php/Dotfiles#Tracking_dotfiles_directly_with_Git), execute: 43 44 $ git submodule add 'https://github.com/0x766F6964/mpv2oboeru.git' ~/.config/mpv/scripts/mpv2oboeru 45 46 If not, either proceed to Arch Wiki and come back when you're done, or simply clone the repo: 47 48 $ git clone 'https://github.com/0x766F6964/mpv2oboeru.git' ~/.config/mpv/scripts/mpv2oboeru 49 50 ### Updating with git 51 52 Submodules: `$ git submodule update --remote --merge` 53 Plain git: `$ cd ~/.config/mpv/scripts/subs2srs && git pull` 54 55 ## Configuration 56 57 The config file should be created by the user, if needed. 58 59 ~/.config/mpv/script-opts/subs2srs.conf 60 61 If a parameter is not specified 62 in the config file, the default value will be used. 63 mpv doesn't tolerate spaces before and after `=`. 64 65 If no matter what mpv2oboeru fails to create audio clips and/or snapshots, 66 change `use_ffmpeg` to `yes`. 67 By using ffmpeg instead of the encoder built in mpv you can work around most encoder issues. 68 You need to have ffmpeg installed for this to work. 69 70 ### Key bindings 71 72 The user may change some key bindings, though this step is not necessary. 73 See [Usage](#usage) for the explanation of what they do. 74 75 ~/.config/mpv/input.conf 76 77 Default bindings: 78 79 ``` 80 a script-binding mpvacious-menu-open 81 82 Ctrl+n script-binding mpvacious-export-note 83 84 Ctrl+c script-binding mpvacious-copy-sub-to-clipboard 85 Ctrl+t script-binding mpvacious-autocopy-toggle 86 87 H script-binding mpvacious-sub-seek-back 88 L script-binding mpvacious-sub-seek-forward 89 90 Alt+h script-binding mpvacious-sub-seek-back-pause 91 Alt+l script-binding mpvacious-sub-seek-forward-pause 92 93 Ctrl+h script-binding mpvacious-sub-rewind 94 Ctrl+H script-binding mpvacious-sub-replay 95 Ctrl+L script-binding mpvacious-sub-play-up-to-next 96 ``` 97 98 **Note:** A capital letter means that you need to press Shift in order to activate the corresponding binding. 99 For example, `Ctrl+M` actually means `Ctrl+Shift+m`. 100 mpv accepts both variants in `input.conf`. 101 102 ## Usage 103 104 ### Global bindings 105 106 Menu: 107 * `a` - Open `advanced menu`. 108 109 Make a card: 110 * `Ctrl+n` - Export a card with the currently visible subtitle line on the front. 111 Use this when your subs are well-timed, 112 and the target sentence doesn't span multiple subs. 113 114 Clipboard: 115 * `Ctrl+c` - Copy current subtitle string to the system clipboard. 116 * `Ctrl+t` - Toggle automatic copying of subtitles to the clipboard. 117 118 Seeking: 119 * `Shift+h` and `Shift+l` - Seek to the previous or the next subtitle. 120 * `Alt+h` and `Alt+l` - Seek to the previous, or the next subtitle, and pause. 121 * `Ctrl+h` - Seek to the start of the currently visible subtitle. Use it if you missed something. 122 * `Ctrl+Shift+h` - Replay current subtitle line, and pause. 123 * `Ctrl+Shift+l` - Play until the end of the next subtitle, and pause. Useful for beginners who need 124 to look up words in each and every dialogue line. 125 126 ### Menu options 127 128 Let's say your subs are well-timed, 129 but the sentence you want to add is split between multiple subs. 130 We need to combine the lines before making a card. 131 132 Advanced menu has the following options: 133 134 * `c` - Set timings to the current sub and remember the corresponding line. 135 It does nothing if there are no subs on screen. 136 137 Then seek with `Shift+h` and `Shift+l` to the previous/next line that you want to add. 138 Press `n` to make the card. 139 140 * `r` - Forget all previously saved timings and associated dialogs. 141 142 If subs are badly timed, first, you could try to re-time them. 143 [ffsubsync](https://github.com/smacke/ffsubsync) is a program that will do it for you. 144 Another option would be to shift timings using key bindings provided by mpv. 145 146 * `z` and `Shift+z` - Adjust subtitle delay. 147 148 If above fails, you have to manually set timings. 149 * `s` - Set the start time. 150 * `e` - Set the end time. 151 152 Then, as earlier, press `n` to make the card. 153 154 **Tip**: change playback speed by pressing `[` and `]` 155 to precisely mark start and end of the phrase. 156 157 **The process:** 158 159 1. Open `Yomichan Search` by pressing `Alt+Insert` in your web browser. 160 2. Enable `Clipboard autocopy` in mpv2oboeru by pressing `t` in the `advanced menu`. 161 3. Go back to mpv and add the snapshot and the audio clip 162 to the card you've just made by pressing `m` in the `advanced menu`. 163 Pressing `Shift+m` will overwrite any existing data in media fields. 164 165 Don't forget to set the right timings and join lines together 166 if the sentence is split between multiple subs. 167 168 ### Other tools 169 170 If you don't like the default Yomichan Search tool, try: 171 172 * Clipboard Inserter browser add-on 173 ([chrome](https://chrome.google.com/webstore/detail/clipboard-inserter/deahejllghicakhplliloeheabddjajm)) 174 ([firefox](https://addons.mozilla.org/ja/firefox/addon/clipboard-inserter/)) 175 * A html page ([1](https://pastebin.com/zDY6s3NK)) ([2](https://pastebin.com/hZ4sawL4)) 176 to paste the contents of your clipboard to 177 178 You can use any html page as long as it has \<body\>\</body\> in it. 179 180 ## Profiles 181 182 Mpvacious supports config profiles. 183 To make use of them, create a new config file called `subs2srs_profiles.conf` 184 in the same folder as your [subs2srs.conf](#Configuration). 185 Inside the file, define available profile names (without `.conf`) and the name of the active profile: 186 187 ``` 188 profiles=subs2srs,english,german 189 active=subs2srs 190 ``` 191 192 In the example above, I have three profiles. 193 The first one is the default, 194 the second one is for learning English, 195 the third one is for learning German. 196 197 Then in the same folder create config files for each of the defined profiles. 198 For example, below is the contents of my `english.conf` file: 199 200 ``` 201 deck_name=English sentence mining 202 model_name=General 203 sentence_field=Question 204 audio_field=Audio 205 image_field=Extra 206 ``` 207 208 You don't have to redefine all settings in the new profile. 209 Specify only the ones you want to be different from the default. 210 211 To cycle profiles, open the advanced menu by pressing `a` and then press `p`. 212 At any time you can see what profile is active in the menu's status bar. 213 214 ## Hacking 215 216 If you want to modify this script 217 or make an entirely new one from scratch, 218 these links may help. 219 * https://mpv.io/manual/master/#lua-scripting 220 * https://github.com/mpv-player/mpv/blob/master/player/lua/defaults.lua 221 * https://github.com/SenneH/mpv2anki 222 * https://github.com/kelciour/mpv-scripts/blob/master/subs2srs.lua 223 * https://pastebin.com/M2gBksHT 224 * https://pastebin.com/NBudhMUk 225 * https://pastebin.com/W5YV1A9q 226 * https://github.com/ayuryshev/subs2srs 227 * https://github.com/erjiang/subs2srs