Coder Social home page Coder Social logo

ajatt-tools / mpvacious Goto Github PK

View Code? Open in Web Editor NEW
531.0 9.0 51.0 469 KB

🍜 Adds mpv keybindings to create Anki cards from movies and TV shows.

Home Page: https://tatsumoto-ren.github.io/blog/mining-from-movies-and-tv-shows.html

License: GNU General Public License v3.0

Lua 98.95% Makefile 0.92% Shell 0.13%
anki mpv subs2srs language-learning spaced-repetition subtitles flashcards mpv-script anki-cards yomichan

mpvacious's Introduction

mpvacious

AUR Chat GitHub Patreon

mpvacious is your semi-automatic subs2srs for mpv. It supports multiple workflows and allows you to quickly create Anki cards while watching your favorite TV show. Video demonstration.

Requirements

GNU/Linux Windows 10+ macOS Comments
mpv mpv mpv v0.32.0 or newer.
Anki Anki
AnkiConnect Install from AnkiWeb.
curl curl Installed by default on all platforms except Windows 7.
xclip or wl-copy pbcopy To copy subtitle text to clipboard.

Install all dependencies at once (on Arch-based distros):

$ sudo pacman -Syu mpv anki curl xclip --needed

Prerequisites

  • A guide on how to set up Anki can be found on our site.

  • If you're on a Windows or a Windows-like machine, a mpv build by shinchiro is recommended.

  • macOS users are advised to use homebrew or manually add mpv to PATH.

  • Note that it is not recommended to use FlatPak or similar containers. If you still want to, read this.

  • Make sure that your build of mpv supports encoding of audio and images. This shell command can be used to test it.

    $ mpv 'test_video.mkv' --loop-file=no --frames=1 -o='test_image.jpg'
    

    If the command fails, find a compatible build on the mpv website or instead install FFmpeg and enable FFmpeg support in mpvacious's config file.

  • Most problems with adding audio or images to Anki cards can be fixed by installing FFmpeg and enabling it settings.

Installation

There are multiple ways you can install mpvacious. I recommend installing with git so that you can easily update on demand.

mpvacious is a user-script for mpv, so it has to be installed in the directory mpv reads its user-scripts from.

OS Location
GNU/Linux ~/.config/mpv/scripts/
Windows C:/Users/Username/AppData/Roaming/mpv/scripts/

Windows is not recommended, but we acknowledge that some people haven't switched to GNU/Linux yet.

Using git

Clone the repo to the scripts directory.

mkdir -p ~/.config/mpv/scripts/
git clone 'https://github.com/Ajatt-Tools/mpvacious.git' ~/.config/mpv/scripts/subs2srs

To update, run the following command.

cd ~/.config/mpv/scripts/subs2srs && git pull

From the AUR

mpvacious can be installed with the mpv-mpvacious package.

Manually

This way is not recommended because it's easy to make a mistake during the process and end up with a broken install.

Download the repository or the latest release and extract the folder containing subs2srs.lua to your mpv scripts directory.

Expected directory tree
~/.config/mpv/scripts
|-- other script 1
|-- other script 2
|-- subs2srs
|   |-- main.lua
|   |-- subs2srs.lua
|   `-- other files
`-- other script 3
A note for mpv v0.32 and older

Older versions of mpv don't know how to handle user-scripts in subdirectories. You need to tell mpv where to look for mpvacious.

Open or create ~/.config/mpv/scripts/modules.lua and add these lines:

local mpv_scripts_dir_path = os.getenv("HOME") ..  "/.config/mpv/scripts/"
package.path = package.path .. ';' .. os.getenv("HOME") .. '/.config/mpv/scripts/subs2srs/?.lua'
function load(relative_path) dofile(mpv_scripts_dir_path .. relative_path) end
load("subs2srs/subs2srs.lua")

Note: in Celluloid user scripts are installed in /.config/celluloid/scripts/. When following the instructions above, replace .config/mpv with .config/celluloid and optionally subs2srs with the name of the folder mpvacious is cloned into.

Configuration

The config file should be created by the user, if needed.

OS Config location
GNU/Linux ~/.config/mpv/script-opts/subs2srs.conf
Windows C:/Users/Username/AppData/Roaming/mpv/script-opts/subs2srs.conf
Windows (portable) mpv.exeフォルダ/portable_config/script-opts/subs2srs.conf

If a parameter is not specified in the config file, the default value will be used. mpv doesn't tolerate spaces before and after =.

Example configuration file

Sentence field should be first in the note type settings. Otherwise, Anki won't allow mpvacious to add new notes.

Tip: Try our official note type if you don't want to configure note fields yourself. Alternatively, we have a collection of user-created note types, which you can browse here.

If you are having problems playing media files on older mobile devices, set audio_format to mp3 and/or snapshot_format to jpg. Otherwise, I recommend sticking with opus for audio, and avif or webp for images, as they greatly reduce the size of the generated files.

If you still use AnkiMobile (the proprietary Anki app), set audio_format to caf for compatibility. The resulting files will use Opus as the coding format and Apple's Core Audio format as the container format, but will still have the .ogg extension to make it easier to open in media players because the .caf extension is not commonly recognized.

If no matter what mpvacious fails to create audio clips and/or snapshots, change use_ffmpeg to yes. By using ffmpeg instead of the encoder built in mpv you can work around most encoder issues. You need to have ffmpeg installed for this to work.

Key bindings

The user may change some global key bindings, though this step is not necessary. See Usage for the explanation of what they do.

OS Config location
GNU/Linux ~/.config/mpv/input.conf
Windows C:/Users/Username/AppData/Roaming/mpv/input.conf

Default bindings:

a            script-binding mpvacious-menu-open

Ctrl+g       script-binding mpvacious-animated-snapshot-toggle

Ctrl+n       script-binding mpvacious-export-note

Ctrl+m       script-binding mpvacious-update-last-note
Ctrl+M       script-binding mpvacious-overwrite-last-note

Ctrl+c       script-binding mpvacious-copy-primary-sub-to-clipboard
Ctrl+C       script-binding mpvacious-copy-secondary-sub-to-clipboard
Ctrl+t       script-binding mpvacious-autocopy-toggle

H            script-binding mpvacious-sub-seek-back
L            script-binding mpvacious-sub-seek-forward

Alt+h        script-binding mpvacious-sub-seek-back-pause
Alt+l        script-binding mpvacious-sub-seek-forward-pause

Ctrl+h       script-binding mpvacious-sub-rewind
Ctrl+H       script-binding mpvacious-sub-replay
Ctrl+L       script-binding mpvacious-sub-play-up-to-next

Ctrl+v       script-binding mpvacious-secondary-sid-toggle
Ctrl+k       script-binding mpvacious-secondary-sid-prev
Ctrl+j       script-binding mpvacious-secondary-sid-next

Note: A capital letter means that you need to press Shift in order to activate the corresponding binding. For example, Ctrl+M actually means Ctrl+Shift+m. mpv accepts both variants in input.conf.

Usage

Global bindings

Menu:

  • a - Open advanced menu.

Enable\Disable animation:

  • Ctrl+g - If animation is enabled, animated snapshots will be generated instead of static images. Animated snapshot are like GIFs (just in a different format) and will capture the video from the start to the end times selected.

Make a card:

  • Ctrl+n - Export a card with the currently visible subtitle line on the front. Use this when your subs are well-timed, and the target sentence doesn't span multiple subs.

Update the last card:

  • Ctrl+m - Append to the media fields of the newly added Anki card.
  • Ctrl+Shift+m - Overwrite media fields of the newly added Anki card.

Clipboard:

  • Ctrl+c - Copy current subtitle string to the system clipboard.
  • Ctrl+t - Toggle automatic copying of subtitles to the clipboard.

Seeking:

  • Shift+h and Shift+l - Seek to the previous or the next subtitle.
  • Alt+h and Alt+l - Seek to the previous, or the next subtitle, and pause.
  • Ctrl+h - Seek to the start of the currently visible subtitle. Use it if you missed something.
  • Ctrl+Shift+h - Replay current subtitle line, and pause.
  • Ctrl+Shift+l - Play until the end of the next subtitle, and pause. Useful for beginners who need to look up words in each and every dialogue line.

Secondary subtitles:

  • Ctrl+v - Toggle visibility.
  • Ctrl+k - Switch to the previous subtitle if it's not already selected.
  • Ctrl+j - Switch to the next subtitle if it's not already selected.

Menu options

Advanced menu has the following options:

  • c - Interactive subtitle selection. The range of the currently displayed subtitle line is selected. The selection then grows both ways based on the following displayed lines. It does nothing if there are no subs on screen.

  • shift+s - Set the start time to the current sub. The selection then grows forward based on the following displayed lines. The default selection spans across the range of the currently displayed subtitle line.

  • shift+e - Set the end time to the current sub. The selection then grows backward based on the following displayed lines. The default selection spans across the range of the currently displayed subtitle line.

Then seek with Shift+h and Shift+l to the previous/next line that you want to add. Press n to make the card.

  • r - Forget all previously saved timings and associated dialogs.

  • z and Shift+z - Adjust subtitle delay.

If above fails, you have to manually set timings.

  • s - Set the start time. The selection then grows forward based on the following displayed lines. The default selection spans across the selected start point and the end of the subtitle line.
  • e - Set the end time. The selection then grows backward based on the following displayed lines. The default selection spans across the selected end point and the start of the subtitle line.

Then, as earlier, press n to make the card.

Tip: change playback speed by pressing [ and ] to precisely mark start and end of the phrase.

My subtitles are not in sync

If subs are badly timed, first, you could try to re-time them. Read Retiming subtitles. Or shift timings using key bindings provided by mpv (usually z and Shift+z).

Example sentence card

With the addon you can make cards like this in just a few seconds.

card-example

Audio cards

It is possible to make a card with just audio, and a picture when subtitles for the show you are watching aren't available, for example. mpv by default allows you to do a 1 second exact seek by pressing Shift+LEFT and Shift+RIGHT. Open the mpvacious menu by pressing a, seek to the position you need, and set the timings. Then press g to invoke the Add Cards dialog. Here's a video demonstration.

If the show is hard-subbed, you can use transformers-ocr to recognize and add text to the card.

Secondary subtitles

If you want to add a translation to your cards, and you have the subtitles in that language, you can add them as secondary subtitles if you run mpv with --secondary-sid=<sid> parameter, sid being the track identifier for the subtitle.

You also need to specify secondary_field in the config file if it is different from the default.

If you want to load secondary subtitles automatically, don't modify the run parameters and instead set the desired languages in the config file (secondary_sub_lang option).

Secondary subtitles will be visible when hovering over the top part of the mpv window.

screencast.mp4

By pressing Ctrl+v you can control secondary sid visibility without using the mouse.

Other tools

If you don't like the default Rikaitan Search tool, try:

  • Clipboard Inserter browser add-on (chrome) (firefox)
  • A html page (1) (2) to paste the contents of your clipboard to

You can use any html page as long as it has <body></body> in it.

Additional mpv key bindings

I recommend adding these lines to your input.conf for smoother experience.

# vim-like seeking
l seek 5
h seek -5
j seek -60
k seek 60

# Cycle between subtitle files
K cycle sub
J cycle sub down

# Add/subtract 50 ms delay from subs
Z add sub-delay +0.05
z add sub-delay -0.05

# Adjust timing to previous/next subtitle
X sub-step 1
x sub-step -1

Profiles

Mpvacious supports config profiles. To make use of them, create a new config file called subs2srs_profiles.conf in the same folder as your subs2srs.conf. Inside the file, define available profile names (without .conf) and the name of the active profile:

profiles=subs2srs,english,german
active=subs2srs

In the example above, I have three profiles. The first one is the default, the second one is for learning English, the third one is for learning German.

Then in the same folder create config files for each of the defined profiles. For example, below is the contents of my english.conf file:

deck_name=English sentence mining
model_name=General
sentence_field=Question
audio_field=Audio
image_field=Extra

You don't have to redefine all settings in the new profile. Specify only the ones you want to be different from the default.

To cycle profiles, open the advanced menu by pressing a and then press p. At any time you can see what profile is active in the menu's status bar.

Hacking

If you want to modify this script or make an entirely new one from scratch, these links may help.

mpvacious's People

Contributors

abdnh avatar adem avatar ale18v avatar aquafina-water-bottle avatar archiif avatar artjomsr avatar crescentkohana avatar cyphar avatar daja177 avatar epistularum avatar eshrh avatar handlerug avatar harbdrain avatar holyparzival avatar kolpav avatar kuator avatar lionslancer avatar luukuton avatar microchipq avatar nihil-admirari avatar pinntokuru avatar ryu1845 avatar seth-js avatar shin-ra avatar tatsumoto-ren avatar true-zero avatar udoprog 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  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  avatar  avatar

mpvacious's Issues

Unable to find note type from MPVacious

  1. OS name Windows 10 Pro
  2. OS version 20H2
  3. mpv version 0.33.0 (10/17/2021.7z unofficial zip file)
  4. Logs
  5. Screenshots, if applicable

Describe the bug
A description of what the bug is.

Note type is not found when pressing 'n' and exporting from MPVacious

To Reproduce
Steps to reproduce the behavior:

  1. Load up a video in MPV
  2. Add subtitle file
  3. Add timings with c
  4. turn on clipboard autocopy with t
  5. export note with n
  6. see error 'unable to find notetype'

Expected behavior
A description of what you expected to happen.

Expected to export note correctly when pressing n.

Additional commentary

I noticed in a prior run through tutorial video here around the 15:56 mark that the anki_user config was set in his subs2srs.lua file. However around mid december of last year that config was removed from the script and all references to the collection itself was removed. I'm clearly missing something here. Any guidance is appreciated!

subs2srs.conf
deck_name="日本語::文章"
model_name="文章"
snapshot_quality=100
audio_bitrate="32k"
note_tag="subs2srs %n %t"
use_forvo="yes"

(This issue happened when I had the default name of "Japanese sentences" used as well)

Error: 'Couldn't store file'

Manjaro 21.2.6
mpv 0.34.1

Log:
Screenshot_2022-05-30_00-40-36

Exported images and audio clips do not function. Errors occur regardless of whether ffmpeg is set on in the config file.

Tried installing mpvacious manually and through AUR, but both did not work.

mpvacious breaks input-ipc-server

Environment:

  • OS: Arch Linux
  • Linux 5.11.5-arch1-1
  • mpv 0.33.0-dirty

Describe the bug
I rely on mpv's input-ipc-server option for some personal scripts, but it seems that using mpvacious breaks this functionality. As far as I know mpvacious doesn't use the ipc server at all so I have no idea why it breaks, but somehow it does.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure the ipc server works under normal circumstances by disabling mpvacious (subs2srs.lua.disable)
  2. add "input-ipc-server=/tmp/mpv.socket" to mpv.conf
  3. start mpv and run the following in a terminal (make sure you have socat installed)
    echo '{"command":["show-text","This is a message"]}' | socat - /tmp/mpv.socket
  4. if everything is working you should get "This is a message" in the mpv window.
  5. Now enable mpvacious again
  6. start mpv and run the command above once again
  7. You will get the following output
    socat[98709] E connect(5, AF=1 "/tmp/mpv.socket", 17): Connection refused

Expected behavior
"This is a message" in the mpv window

Attempt to index a boolean value on Windows

io.open(curl_tmpfile_path, "w"):write(request_json):close()

On Windows 10, using mpv 0.32.0 portable, I was hitting a Lua error here during create_deck, and after I commented that out, when trying to make a card using Ctrl + e.

I was able to fix it by changing the line to:
local file = io.open(curl_tmpfile_path, "w")
file:write(request_json)
file:close()

Posting this as an issue in case others encounter the same thing; I'm not sure if I'm somehow using the wrong Lua version or something like that. Everything else seems to work fine for me after making that change.

Bind for creating cards with AlreadyKnown tag (for Morphman)

It would be useful to have a bind to automatically create cards with the "AlreadyKnown" tag for those who use Morphman. For example, an user is just starting to create his word bank, but he understands some sentences and manually creating cards from these sentences is rather boring. Nevertheless, with such a bind, it would be possible to add sentences to your word bank whose meaning is clear, and Morphman would not include them in the learning schedule. However, cluttering up your main bank is not a good idea, so I suggest splitting the banks: one for unknown phrases and one for AlreadyKnown.

Audio not playing in anki (tried with both windows and linux)

Basically everything seems to be set up correctly with the mpvacious folder placed in the scripts folder (~/.config/mpv/scripts and %appdata% mpv respectively). mpvacious works like normal -- the clipboard functions, it exports the flashcards to anki just fine, etc.. the only thing is the audio files don't play. There doesn't seem to be anything wrong with anything else so I can't figure out why this issue is happening. I set it up on both ubuntu 21.10 and windows 11 and had the same problem both times.

I've got mpvacious on windows 10 and ubuntu 20.04 on my desktop and laptop and those work fine. So I'm kind of confused about the cause of this.

Corrupted Audio (windows 10)

Describe the bug
All the audio exported to anki does not play for me (and also won't open up in foobar)
I've tried both opus and mp3

I should note I don't have "curl" installed, but from reading the github page of mpvacious, it just seems like an installer?
(if I'm wrong, and I need curl to get the working audio export please let me know)

image
image

(as a closing note, great work man)

mpvacious note type PRs?

I've made some changes to the mpvacious note type that I think could be quite helpful:

  • I made it so the pitch accent colouring isn't shown on the front -- instead the target word has a faint border added. This is nice because it means you can try to recall the pitch accent rather than having it told to you immediately.
  • I added a separate VocabDefMonolingual field which is useful for folks starting the monolingual transition. If the field is used, the bilingual VocabDef field is displayed using {{hint:...}} which means you can focus on trying to read the monolingual definition before you see the bilingual one.

Unfortunately it seems the mpvacious note type source code is only available through AnkiWeb where I can't send a PR -- I'd be happy to send a PR with these changes (if you're interested) but it seems there's nowhere for me to send it. It is possible to have the source available in this repo so folks can contribute to it (and you can then push to AnkiWeb at whatever interval suits you best)? Thanks.

For reference this is what my new notes look like:

Front

2021-04-20-014651_772x93_scrot

Back

2021-04-20-014712_1123x642_scrot

Image appears in very low quality in flashcard

Environment:

  • OS: Manjaro KDE
  • OS: 20.2
  • mpv version
    mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
    built on UNKNOWN
    ffmpeg library versions:
    libavutil 56.31.100 (runtime 56.51.100)
    libavcodec 58.54.100 (runtime 58.91.100)
    libavformat 58.29.100 (runtime 58.45.100)
    libswscale 5.5.100 (runtime 5.7.100)
    libavfilter 7.57.100 (runtime 7.85.100)
    libswresample 3.5.100 (runtime 3.7.100)
    ffmpeg version: n4.3.1

Title says it all. The original video file is in 1080p.

Here's how it looks

Unable to pull audio & screenshot from funimation

Environment:
OS: Windows 10
Update: Latest windows 10
Latest mpv version - 0.33.0 (2-28-21)

Describe the bug
Using a chrome browser extension "watch with MPV," Mpvacious doesn't seem to be able to extract audio while being played through MPV. The site from which I am watching from is Funimation. I can watch it completely fine, it just doesn't grab onto the audio & image being played.

To Reproduce

  1. Open video using "watch with MPV" extension
  2. Select word from clipboard monitor
  3. Create and update Anki card using "c" and "m"
  4. Open anki card
  5. Preview anki card

Expected behavior
A playthrough of the audio and a screenshot of the image to be in the preview

Screenshots

image
image

If I try to watch directly through cmd, this is what I get so I use the chrome extension instead.

C:\Users\jarod>mpv https://www.funimation.com/shows/log-horizon/the-apocalypse/?qid=undefined
C:\Users\jarod\AppData\Roaming/mpv/mpv.conf:3: unparseable extra characters: ':jpn,jp,en'
C:\Users\jarod\AppData\Roaming/mpv/mpv.conf:4: unparseable extra characters: ':jpn,jp,en'
Resuming playback. This behavior can be disabled with --no-resume-playback.
[ytdl_hook] ERROR: Unable to extract al:web:url; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.

Exiting... (Errors when loading file)

script-binding mpvacious-update-last-note not working

Environment:

  • OS: Ubuntu 18.04 LTS
  • mpv version: 0.33.0

Describe the bug
I've binded Ctrl+m script-binding mpvacious-update-last-note in mpv input.conf. When I tried to use that Ctrl+m on mpv, the note is updated but with no sound file and no picture file.

alternative workflow of pressing a then m will achieve the same result and it is working on my machine.

To Reproduce
Steps to reproduce the behavior:

  1. press Ctrl+m on currently visible subtitle line on the front
  2. anki browse window pop out

Expected behavior
note created with sound file and picture file.

terminal output

[mpvacious] Note #1615893229052 updated. 
(Paused) AV: 00:09:51 / 00:23:47 (41%) A-V:  0.000
[modules] Note #1615893229052 updated. 
(Paused) AV: 00:09:51 / 00:23:47 (41%) A-V:  0.000
A: 00:09:53 / 00:23:47 (42%) {0.0min 11.50x 0.0MB}
A: 00:09:53 / 00:23:47 (42%) {0.0min 10.15x 0.0MB}
[mpvacious] File stored: 'MushokuTenseiIsekaiIttaraHonkiDasuS01E10_09m51s658ms-09m53s908ms.ogg'. 
(Paused) AV: 00:09:51 / 00:23:47 (41%) A-V:  0.000
[modules] Couldn't store file 'MushokuTenseiIsekaiIttaraHonkiDasuS01E10_09m51s658ms-09m53s908ms.ogg': [Errno 2] No such file or directory: '/tmp/MushokuTenseiIsekaiIttaraHonkiDasuS01E10_09m51s658ms-09m53s908ms.ogg' 
[mpvacious] File stored: 'MushokuTenseiIsekaiIttaraHonkiDasuS01E10_09m51s716ms.jpg'. 
[modules] Couldn't store file 'MushokuTenseiIsekaiIttaraHonkiDasuS01E10_09m51s716ms.jpg': [Errno 2] No such file or directory: '/tmp/MushokuTenseiIsekaiIttaraHonkiDasuS01E10_09m51s716ms.jpg' 

[subs2srs] Lua error: [string "~/.config/mpv/scripts/subs2srs...."]:525: attempt to call field 'unpack' (a nil value)

Environment:

  • OS: OSX
  • OS version: 10.15.2
  • mpv version: 0.33.0

Describe the bug
When I try to use Ctrl-H on cb39907, I get an error as described in the title and can no longer use any mpvacious shortcuts. I regressed to 3209db2 and it works fine.

To Reproduce
Steps to reproduce the behavior:

  1. Place the cb39907 configuration in /.config/mpv/scripts
  2. Open a video file with mpv.
  3. Enter a, and use advanced controls just fine.
  4. Enter Ctrl-H, and get error.

Is audio normalized?

Just a quick question, are the audio snippets that are created sound normalized?

(so if I create cards for a quiet show and a loud show, will the volume be roughly the same)

osd_styler not found

Environment:

  • OS: Ubuntu
  • 20.04
  • mpv 0.33.0

Describe the bug
I just did mpv anime.mkv and got that

To Reproduce
mpv videoname is enough.
Expected behavior
Work properly.

[feature request] custom mpv extraction arguments

I've noticed that some of my cards have really loud audio (because while I do now use tie_volume, sometimes people shout in a scene and I don't adjust the audio just for that scene -- also I sometimes adjust my system volume rather than the volume of the video). The net result is that some of my cards scream at me when I review them.

I originally wanted to propose some new mpvacious option to configure --af=loudnorm but after thinking about it, it's probably far more useful to have an option to let you configure arbitrary filters (or even arbitrary command-line arguments) for the mpv call where you extract the audio. That way I could add more complicated filters like silenceremove=stop_periods=-1:stop_duration=0.6:stop_threshold=-90dB,loudnorm=tp=-4:i=-40 and not have to have multiple configuration options for each filter.

Installation for Celluloid does not work

I cannot install the script for Celluoid 0.21 as just dropping all the *.lua files into the Plugins tab no longer works.
Nor does putting them all into a separate directory inside ~/.config/celluloid/scripts.

Could you please update the instructions to install the script for Celluloid?

Ubuntu version is not compatible with libwebp?

I downloaded my mpv from here: https://launchpad.net/~mc3man/+archive/ubuntu/mpv-tests

Only problem is I can't create snapshot files with mpv because it say it's not compatible with libwebp and my flashcards are showing up without an image. I tried to grab from another PPA and ran into all kinds of complications and problems that typically happens when I mess around with linux :(

Is this a known issue with the ubuntu mpv/mpvacious? Or am I just not finding the most recent version?

Trying to add note yields "Error: cannot create note because it is empty."

Environment:

  • Debian GNU/Linux bullseye/testing
  • mpv 0.32.0
  • anki 2.1.43 + latest AnkiConnect (no other addons)

Describe the bug
No note gets added, I see the error "Error: cannot create note because it is empty."

To Reproduce

I changed the settings in the subs2srs.lua file itself. I did check and double-check that the matching fields are used. Please see below the diff.

Steps to reproduce the behavior:

  1. Press a, then i, then n
  2. I see an error on screen: "Error: cannot create note because it is empty."
    In mpv terminal I see:
[modules] Error: cannot create note because it is empty. 

A: 00:05:14 / 00:23:38 (22%) {0.0min 34.12x 0.0MB} Cache: 20s/1MB
[modules] File stored: 'XXXXXX_05m13s720ms-05m14s960ms.ogg'. 
[modules] File stored: 'XXXXXX_05m13s719ms.webp'. 

(XXXXXXX is the name of the file I was playing sans its extension.)

  1. No note gets added

Expected behavior
Note gets added

Screenshots
Not applicable

diff --git a/subs2srs.lua b/subs2srs.lua
index 3ec9ce0..fd14a00 100644
--- a/subs2srs.lua
+++ b/subs2srs.lua
@@ -38,7 +38,7 @@ For complete usage guide, see <https://github.com/Ajatt-Tools/mpvacious/blob/mas
 local config = {
     -- Common
     autoclip = false,              -- enable copying subs to the clipboard when mpv starts
-    nuke_spaces = true,            -- remove all spaces from exported anki cards
+    nuke_spaces = false,           -- remove all spaces from exported anki cards
     clipboard_trim_enabled = true, -- remove unnecessary characters from strings before copying to the clipboard
     snapshot_format = "webp",      -- webp or jpg
     snapshot_quality = 15,         -- from 0=lowest to 100=highest
@@ -52,12 +52,12 @@ local config = {
 
     -- Anki
     create_deck = false,                -- automatically create a deck for new cards
-    deck_name = "Learning",             -- name of the deck for new cards
-    model_name = "Japanese sentences",  -- Tools -> Manage note types
-    sentence_field = "SentKanji",
-    audio_field = "SentAudio",
-    image_field = "Image",
-    miscinfo_field = "Notes",           -- misc notes and source information field
+    deck_name = "subs2srs",             -- name of the deck for new cards
+    model_name = "3. All-Purpose Card",  -- Tools -> Manage note types
+    sentence_field = "The full sentence (no words blanked out)",
+    audio_field = "Audio",
+    image_field = "Front (Picture)",
+    miscinfo_field = "Extra Info (Pronunciation, personal connections, conjugations, etc)",           -- misc notes and source information field
     miscinfo_format = "%n (%t)",        -- format string to use for the miscinfo_field, accepts note_tag-style format strings
     tag_nuke_brackets = true,           -- delete all text inside brackets before subsituting filename into tag
     append_media = true,                -- True to append video media after existing data, false to insert media before

Words do not have spaces in Danish language

  1. OS name windows
  2. OS version 10
  3. mpv version newest

Describe the bug
Clipboard autocopy does not make spaces in Danish language. words are squeezed sometimes.
This is what I get using texthooker.com
Capture

Expected behavior
this is expected copied text from tv series
Capture2

To Reproduce
load danish subs, enable autocopy, use texthooker.com to see the results

Menu to access Mpvacious doesn't function anymore.

Hello,

I apologize for creating a ticket for this small issue since i can't find an answer for this on YouTube or anywhere else, when i installed your Mpvacious script the key to access the menu ''A'' doesn't do anything anymore, a year ago when i first started using your script and Mpv Player it worked fine, also when i press the T key it just simply nudges the subtitle alittle, do you know what i am doing wrong? i've also tried to download and use a older version of MPV but the same issue still happens.

Kind regards

seeking to next subtitle not working when there is subtitle playing

Environment:

  • OS: Windows 10
  • OS version: 20H2
  • mpv version: v2020.1.27

Describe the bug
When there is subtitle playing, mpvacious do not seek to next subtitle, instead stay on the current frame. However, seeking to next subtitle functions properly when there is no subtitle on the current frame.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a frame with subtitle playing
  2. Press 'Shift + l'
  3. See error

Expected behavior
mpvacious seek to next subtitle instead of staying on current frame

Couldn't find the target note.

Environment:

  • OS: Windows 8.1
  • mpv version: latest (redownloaded yesterday)

Describe the bug
As mentioned in the title everything works fine until I return to mpv to press "m" and that error pops up. I think it's due to some kind of error in the config file.

To Reproduce
Steps to reproduce the behavior:
Follow the exact same method you described up until you get to the "press m" part.

Expected behavior
Shoul have taken and added screenshot and audio recording to the anki note. Instead it just says "Couldn't find the target note".

Screenshots
here is my config file and a bunch of screenshots included my yomichan settings.

config
config2
Config3
config4
config5
config6

Media files not being created/imported to Anki

Environment:

  • OS: Windows
  • OS 10
  • mpv version
    mpv 0.32.0-791-g73be20143e Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
    built on Sun Nov 1 10:19:46 +08 2020
    FFmpeg library versions:
    libavutil 56.60.100
    libavcodec 58.112.100
    libavformat 58.64.100
    libswscale 5.8.100
    libavfilter 7.88.100
    libswresample 3.8.100
    FFmpeg version: git-2020-10-31-3da35b7c

I am having trouble getting the media to properly create itself and import to Anki.
The subtitles properly get added to the field on the Anki Card but the videofilename_(starttime-endtime).ogg file and snapshot.webp Do not seem to be created.

I have tried searching for an ogg file with the name it attempts to put in the anki audio field but find nothing, the snapshot just shows up as a small icon with 'snapshot' in text after it.

There are no errors showing up in the MPV console

Steps to reproduce the behavior:
Attempting to make a card in any way

Add_anki_2020-11-07_04-17-48

The above screenshot is what the snapshot shows, instead of showing a frame of the media the card is being created from.

Bind for switching output deck

Hey!
Would be cool if one could change the output deck with a shortcut. For people like me who are learning different things in different profiles.

OSX 10.15.7 clipboard autocopy or copy subtitle not working

Environment:

  • OS: OSX
  • OS version 10.15.7
  • mpv version 0.32.0-750-ge1536193cb from nightly build

Describe the bug
I noticed that you made a commit to use pbcopy to support OSX. But clipboard autocopy doesn't work with the latest master script. I also tried doing control + c as well (though it's hard to know if there are any OSX binding that could be colliding with the shortcut) and it didn't seem to work.

To Reproduce
Steps to reproduce the behavior:

  1. Press a
  2. Press t (to enable enabled)
  3. Run video with subtitles, clipboard has nothing to paste

Expected behavior
It should copy the subtitles into the clipboard.

Screenshots
not applicable.

Unable to store screenshots and audio clips [Errno 2]

Environment:

  • OS Fedora 34
  • mpv version 0.33.1
  • Anki flatpak
  • wayland (probably irrelevant)
  • mpv config

Describe the bug
mpvacious can't store files while updating anki cards created via yomichan, i also tried changing: self.tmp_dir = function() return '/tmp' to self.tmp_dir = function() return '/home/giuji/.tmp' , mpv 'test_video.mkv' --loop-file=no --frames=1 -o='test_image.jpg' works on my machine

To Reproduce
Steps to reproduce the behavior:

  1. Open a video file and enable autocopy via mpvacious menu
  2. Create a new card using yomichan
  3. Update the note by pressing c + m in the mpvacious menu
  4. Preview the card
  5. Check mpv logs

Expected behavior
Anki card gets updated with screenshot and audio clip but no actual file gets created. mpv logs: [ 19.094][e][mpvacious] Couldn't store file '響け!ユーフォニアム01_16m35s489ms-16m37s399ms.ogg': [Errno 2] No such file or directory: '/tmp/響け!ユーフォニアム01_16m35s489ms-16m37s399ms.ogg'

Screenshots
Screenshot from 2021-06-19 17-24-04
Screenshot from 2021-06-19 17-23-23
Screenshot from 2021-06-19 17-26-28

PS: this is the first time I report an issue on github, help me if I've done something wrong

No scripts folder in mpv directory, cant install

  1. Win 11
  2. latest

Describe the bug
I did not have an mpv scripts folder, I installed mpv via scoop. I navigated to the directory scoop gave me, and created a scripts folder to see if this would work, but it doesn't. I cannot use the script at all.

To Reproduce
Open MPV

Expected behavior
proper function

Generating anki cards fails to store audio clip or image snapshot

Screen Shot 2021-06-12 at 10 49 08 PM

**Environment:** - OS: MacOS Catalina - Ver. 10.15.7 - mpv 0.33.1

Describe the bug
Exporting anki cards with audio or an image snapshot from mpv results in a new card being created but with a nonexistent image named snapshot and an audio file that is correctly named but totally empty and doesn't play anything (see screenshot below). Checking media through anki shows that both the snapshot and audio are missing. The mpv console shows two errors saying:
" Couldn't store file 'HorimiyaS01E02_01m16s994ms.jpg': [Errno 2] No such file or directory: '/tmp/HorimiyaS01E02_01m16s994ms.jpg' " and
" Couldn't store file 'HorimiyaS01E02_01m15s580ms-01m17s790ms.mp3': [Errno 2] No such file or directory: '/tmp/HorimiyaS01E02_01m15s580ms-01m17s790ms.mp3' "
It seems like saving these files to a temporary directory before sending them to the anki collection isn't working since they are never making it to the collection.media folder. When I make a card with yomichan and ankiconnect the audio is saved normally so I think it's an mpvacious specific issue. I've reinstalled mpvacious and mpv and the only changes I've made to the config within subs2srs.lua are to set up the deck, note type, and fields. Any help on this issue would be much appreciated.

To Reproduce
Steps to reproduce the behavior:

  1. Press control control-e in mpv with a video file open.
  2. Go to anki and find the generated card.
  3. See error

Screenshots
Screen Shot 2021-06-12 at 10 43 45 PM

Screen Shot 2021-06-12 at 10 44 17 PM

mpvacious crash when press m to update Yomichan'ed card

Before making a new issue please seek help in the matrix chat. Thank you.

Environment:

  • OS: Win10
  • OS version
  • mpv version: 20210316

Describe the bug
A description of what the bug is.
mpvacious automatically crashed when press m to update yomichan'ed card...

To Reproduce
Steps to reproduce the behavior:

  1. Press m to update Yomichan'ed card
  2. mpvacious exited, no appearance when press a.

Expected behavior
A description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Strange behavior with 's' key.

Environment:

  • OS: Manjaro
  • OS version: latest version, kernel 5.8
  • mpv version: 0.32.4

Describe the bug
's' key is taking screenshot and saving it at $HOME instead of setting start time to current position. But if I open advanced menu first (a), 's' works fine. Also, same for 'g' key and 'n'. Is that normal?

To Reproduce
Steps to reproduce the behavior:

  1. Open a video with subtitles
  2. Press 's'
  3. Screenshot:'/home/user/...........

Expected behavior
Setting start time to current positivion properly.

Screenshots
https://i.imgur.com/HnttFpE.png ('s' key)

JPG Snapshots don't work after ffmpeg update

I realized all my recent cards don't have any screenshots. This started after the ffmpeg upgrade from 4.4 to 5.0 and the related packages on Arch on February 17.

I'm getting this output
[ 16.605][e][mpvacious] Couldn't store file 'video_00m07s441ms.jpg': [Errno 2] No such file or directory: '/tmp/video_00m07s441ms.jpg'

Everything else like audio is working just fine.

Just tried webp, which is still working.

mpvacious_linux_v0.2.lua:325: '=' expected near 'ret'

I receive this error with the latest release:

11220 ~ $ mv dls/mpvacious_linux_v0.2.lua .config/mpv/scripts/
11220 ~ $ mpv pix/ani/hyouka/Hyouka\ -\ 01.mkv
[mpvacious_linux_v0_2]
[mpvacious_linux_v0_2] stack traceback:
[mpvacious_linux_v0_2]  [C]: ?
[mpvacious_linux_v0_2]  [C]: ?
[mpvacious_linux_v0_2] Lua error: /home/<user>/.config/mpv/scripts/mpvacious_linux_v0.2.lua:325: '=' expected near 'ret'

I have all dependencies listed in the readme and mpv version 0.32.0.

Error: cannot create note because it is empty.

Platform: Windows
running on the newest version of mpv

Hey, the script seems to work just fine with the exception that I can't generate any cards.
Whenever I try to do so I get the Error "cannot create note because it is empty."

high quality audio

Is there a way to export 64k sub audios? there only seems to be 16k to 32k

Multi-line subtitles are not copying into clipboard

Environment:

  • OS: Windows 10
  • OS version: 2004
  • mpv version: 0.32.0-759-g67b4a96e45

Bug:
Subtitles with line breaks are not copied onto the clipboard. For example, this dialogue in an srt file:

1
00:00:05,371 --> 00:00:08,404
私のアツいアイドル活動!
“アイカツ!”

When copied, the clipboard does not change, and the first line "leaks" into the verbose log.

Active code page: 65001
私のアツいアイドル活動!
[statusline] (Paused) AV: 00:00:03 / 00:24:26 (0%) A-V:  0.000 DS: 4.000/0

However, remove the line break and it copies successfully.

Addon doesn't working.

Before making a new issue please seek help in the matrix chat. Thank you.

Environment:

  • OS: Windows
  • OS version
  • mpv version mpv-x86_64-20210404-git-dd86f19

Describe the bug
I installed the addon following the instructions and the it doesn't work. I found something in the mpv console that maybe useful to know what's happening.

Screenshots
imagen

image_field fail to export to anki

Environment:

  • OS: Ubuntu
  • OS version: 18.04
  • mpv version: 0.33.0

Describe the bug
image_field fail to export to anki when updating the last added card with binding m.

sub2srs.conf file:

# Anki
deck_name=sentence mining 
model_name=Migaku Japanese
sentence_field=Expression
audio_field=Audio
image_field=Image
note_tag= 

#Media quality
# tried with snapshot_format=jpg, resulting in the same error
snapshot_format=webp 

output from terminal:

Resuming playback. This behavior can be disabled with --no-resume-playback.
 (+) Video --vid=1 (*) (h264 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=jpn (*) (eac3 2ch 48000Hz)
 (+) Subs  --sid=1 --slang=jpn (subrip)
AO: [pulse] 48000Hz stereo 2ch float
[modules] Deck sentence mining : check completed. 
VO: [gpu] 1920x1080 yuv420p
[subs2srs] Deck sentence mining : check completed. 
(Paused) AV: 00:06:25 / 00:22:52 (28%) A-V:  0.000
[subs2srs] Timings have been set to the current sub. 
(Paused) AV: 00:06:25 / 00:22:52 (28%) A-V:  0.000
[subs2srs] Note #1614754854560 updated. 
(Paused) AV: 00:06:25 / 00:22:52 (28%) A-V:  0.000
[subs2srs] mpv: ../video/zimg.c:241: repack_entrypoint: Assertion `!(i & (mp_repack_get_align_y(r->repack) - 1))' failed.
A: 00:06:27 / 00:22:52 (28%) {0.0min 16.97x 0.0MB}
[subs2srs] Couldn't store file 'BeastarsS208_06m25s176ms.jpg': [Errno 2] No such file or directory: '/tmp/BeastarsS208_06m25s176ms.jpg'
[subs2srs] File stored: 'BeastarsS208_06m25s051ms-06m27s427ms.ogg'. 
(Paused) AV: 00:06:25 / 00:22:52 (28%) A-V:  0.000

To Reproduce
Steps to reproduce the behavior:

  1. add expression with yomichan anki integration
  2. press binding a, c and m
  3. Anki browse window pop up with broken image icon on image_field

Expected behavior
Anki browse window pop up with sentence_field, audio_field and image_field imported.

Screenshots
image

attempt to call field 'create_osd_overlay' (a nil value)

Platform: Debian 10 Buster
mpv version: 0.29.1

Hello, I followed the installation instructions, but I'm getting this error when I play a video with mpv. I can still watch the video, but the script doesn't work.

[modules]
[modules] stack traceback:
[modules]       /home/user/.config/mpv/scripts/subs2srs/subs2srs.lua:737: in main chunk
[modules]       [C]: in function 'dofile'
[modules]       /home/user/.config/mpv/scripts/modules.lua:2: in function 'load'
[modules]       /home/user/.config/mpv/scripts/modules.lua:3: in main chunk
[modules]       [C]: in ?
[modules]       [C]: in ?
[modules] Lua error: /home/user/.config/mpv/scripts/subs2srs/subs2srs.lua:737: attempt to call field 'create_osd_overlay' (a nil value)

Clipboard Auto Copy

Before making a new issue please seek help in the matrix chat. Thank you.

Environment:

  • OS: Windows 10
  • Latest windows 10
  • Latest mpv version - 0.33.0 (2-28-21)

Describe the bug
Clipboard auto copy does not work correctly. This happened after playing around with youtube-dl and trying to get VRV to play through mpv

The only things that changed were downloading youtube-dl and adding these to the mpv config file.
Code passed: (commented out atm)
#ytdl-raw-options=username=user,password=pass
#ytdl-raw-options=format=best[format_id!*=hardsub]

I've figured out that everytime I try to pass arguments to ytdl it breaks my mpv so I tried removing the code but I still have the same issue.

The only time clipboard auto copy works correctly is when playing on from quick access, if any subsequent link or file is dragged into the current mpv it will work correctly

If I open up the file from anywhere that is not from quick access, will not automatically copy to the clipboard.

To Reproduce
Steps to reproduce the behavior:

  1. Put those lines of code in mpv.conf file
  2. Open up some video into mpv (cmd or exe)
  3. Drag subtitles onto video
  4. Enable mpvacious as normal
  5. Observe yomichan clipboard monitor

Expected behavior
Clipboard auto copying

Screenshots
Link to a youtube video demonstrating the problem
https://www.youtube.com/watch?v=C4njG0nHOa8

Doesn't seem to work with MIA Jpn DX note type.

Environment:

OS: Windows 10 Home
Version 2004
mpv version 0.32.0-759-g67b4a96e45
When trying to create an MIA Jpn DX note type, a new deck (Sentence Mining1) was created but no new note was added (no error was raised). When toggle autoclip to 'no', 'Error: Fatal Error for AnkiConnect' was raised.

To Reproduce Steps to reproduce the behavior:

Press 'Ctr + e'
Expected behavior A new note to be added to the deck.

image

Issues with "Modifying cards added with Yomichan"

Environment:

OS: Windows 10 Home
Version 2004
mpv 0.32.0-759-g67b4a96e45 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
built on Sun Oct 11 16:36:53 +08 2020
FFmpeg library versions:
libavutil 56.60.100
libavcodec 58.111.100
libavformat 58.62.100
libswscale 5.8.100
libavfilter 7.87.100
libswresample 3.8.100
FFmpeg version: git-2020-10-10-0c73c2909

Describe the bug
When update a note which were added using Yomichan with "m/ Shift +m" key, return "Note # updated" but no change occur aside from media being added to collection.media.

To Reproduce Steps to reproduce the behavior:

Add a note using Yomichan with clipboard inserter enabled
Switch to MPV
Click "a", click "m" or "Shift+m"
"Note # updated" is shown but no change was made

Expected behavior Screenshot and Audio from the video to be appended to the yomichan card.

Screenshots
subs2srs.conf: https://anotepad.com/notes/9d7cg39t
2
3
0
1

module 'config' not found

Environment

  1. OS name - arch
  2. OS version - 5.14.8
  3. mpv version - 0.33.1-dirty
  4. Logs
  5. Screenshots, if applicable

Describe the bug
Mpvacious doesn't work on a completely fresh install. I think the changes in 853a529 are relevant. Best I can tell, when installing from aur (I used yay), it doesn't include the config.lua file that was added in the commit before.

To Reproduce
Steps to reproduce the behavior:

  1. install mpv through pacman
  2. install mpv-mpvacious through yay
  3. open and video and open log to see that it can't find the config module.

Expected behavior
Mpvacious to load as usual

Fix installation instructions for mpv 0.32

In #34, it seems like a note about modules.lua was removed (8b10b63). Please consider re-adding it.

The next version of Debian GNU/Linux (which will be the next stable version for the next 2-3 years) is shipping mpv 0.32.

I just ran into this issue and it would have saved me ~30 minutes not to have to go look for this.

BTW, the old note did not work for me. I git cloned the mpvacious repository into ~/.config/mpv/mpvacious and had to put the following into modules.lua to get it to work:

local home = os.getenv("HOME")
package.path = package.path .. ';' .. home .. '/.config/mpv/scripts/mpvacious/?.lua'

local mpv_scripts_dir_path = os.getenv("HOME") ..  "/.config/mpv/scripts/"
function load(relative_path) dofile(mpv_scripts_dir_path .. relative_path) end
load("mpvacious/subs2srs.lua")

Thanks!

Clipboard feature not working

  1. Win 11
  2. latest
  3. latest

Describe the bug
clipboard capture doesn't work

To Reproduce
turn on autocopy, or press ctrl+c

Expected behavior
subtitle line is copied to clipboard

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.