This add-on adds a new option in the Tools menu to open a video file with mpv and create subs2srs-like cards by pressing the 'b' key.
WHAT IS SUBS2SRS
• subs2srs | Learn Any Language | Wiki
• substudy: A tool for learning languages using TV shows and subtitles
KNOWN ALTERNATIVES
mpv: The Best Video Player for Language Learning by Matt vs. Japan - https://www.youtube.com/watch?v=bbg6ztWecbU
WHAT'S NEW
2020-10-20 Support .ass and .vtt subtitles, in addition to .srt
2020-10-20 The mpv.conf was moved to user_files/mpv.conf
2020-10-20 Basic support for http(s) URLs (YouTube or any other site supported by youtube-dl)
Requires youtube-dl to be installed the same way as mpv or ffmpeg. In the add-on's configuration window make sure that "Use mpv?" is checked. To use it, just copy-paste the url instead of selecting a video file. If nothing happens in 5 seconds, it likely means that mpv can't play the url. Try to play it from the terminal with: mpv https://www.youtube.com/watch?v=Z1PCtIaM_GQ
2020-10-21 Add support for mpv 0.30.0 to automatically get the start time and the end time for the current line in the embedded subtitles
2020-10-22 Support opening multiple video files. The video files will be added to the playlist.
HOW TO INSTALL MPV
The add-on depends on mpv video player - https://mpv.io/
• Windows
• Linux
Install the latest mpv version from https://mpv.io/installation/, but it might be already installed alongside with Anki.
• macOS
HOW TO USE
A simple sample deck - https://gistpreview.github.io/?d515535b80a3d8f0775989e0d83c8a3b
There's also MIA Jpn DX card template from How to Learn Japanese with Netflix + Anki by Matt vs. Japan.
- Open the add-on via "Open Video..." option (Ctrl+O) in the Tools menu.
- Select a note type.
- Click on the gears icon to select which fields will be populated by the add-on.
- Select a deck or create a new one.
- Maybe change other settings.
- Click on "Go!", open a video file and press 'b' key to create a new Anki card (or press 'w' and 'e' and then 'b').
If you're on Mac and audio encoding isn't working (no audio file appears in the collection.media folder or it'll be 0KB), try to replace mp3 with m4a for File ext: in the add-on settings.
ADD-ON SETTINGS
DEFAULT FIELDS
"Id" | Tangled_(2010)00.26.43.226-00.26.47.019
"Source" | Tangled (2010)
"Time" | 00:26:45.395
"Line" | I was in a situation, gallivanting through the forest.
"Meaning: line" | Я попал в переплёт и, пробираясь сквозь чащу...
"Image" | <img src="Tangled(2010)00.26.45.395.jpg" />
"Audio" | [sound:Tangled(2010)_00.26.43.226-00.26.47.019.m4a]
ADDITIONAL FIELDS
"Path" | D:\Movies\Tangled (2010).mkv
"Image (with subtitles)" | <img src="Tangled_(2010)00.26.45.395_S.jpg" />
"Line: before" | Gesundheit, here's the deal.
"Line: after" | I came across your tower and...
"Meaning: line before" | Будь здорова. Послушай.
"Meaning: line after" | Увидел твою башню, а потом...
"Audio (with context)" | ...
"Video" | [sound:Tangled(2010)00.26.43.226-00.26.47.019.mp4]
"Video (with context)" | ...
"Video (HTML5)" | Tangled(2010)00.26.43.226-00.26.47.019.mp4
"Video (HTML5 with context)" | ...
"Video Subtitles" | [sound:Tangled(2010)_00.26.43.226-00.26.47.019.srt]
If the field "... (with context)" is selected then audio/video will start at the beginning of the previous line ("Line: before") and ends at the end of the next line ("Line: after").
Video can be saved either in mp4 or webm format. Default fields saves video in mp4 format. To save video in webm format select the same field name but with "[webm]" prefix in it. Probably choose webm if you're on Windows and want to embed video in the card, otherwise choose mp4 format.
DEFAULT HOTKEYS
b - create new card
w - set the start time
e - set the end time
ctrl + w - replay from the start time
ctrl + e - replay the last ~2 seconds and pause
ctrl + r - reset the start time and the end time
If the end time is set, 'ctrl + w' will pause playback after playing from the start time to the end time.
Default hotkeys can be changed by editing mpv2anki.lua in the add-on's folder (Anki - Tools - Open Add-ons Folder - ...).
Maybe some useful mpv hotkeys:
left and right - seek backward/forward 5 seconds
shift + left/right - seek backward/forward 1 second
. - step one frame forward
, - step one frame backward
For more information about default mpv hotkeys please see Interactive Control.
USAGE NOTES
It might be useful to create mpv.conf with similar default settings - https://gist.github.com/kelciour/c6d4fe4042431052ab35e8137379f91a
For more information please see https://mpv.io/manual/master/#configuration-files
Alternatively, the same settings can be added to mpv.conf in the add-on's folder, i.e. Anki - Tools - Add-ons - Create subs2srs ... - View Files - mpv.conf
The add-on is supposed to be used with external srt subtitles that have the same name as the video file and followed by <language> code from the add-on settings screen. For example, if the video file is "Tangled (2010).mkv" and language code is "en", any of these filenames will work for subtitles: "Tangled (2010).en.srt", "Tangled (2010).eng.srt", "Tangled (2010)_track_5_eng.srt".
The add-on can be used with embedded subtitles too, but in this case it can only save current video frame as a screenshot, current subtitle as a text and audio/video clip by specifying the start time and the end time using 'w' and 'e' keys.
With mpv 0.30.0 it's possible to get the start time and the end time for embedded subtitles automatically (only the current line).
The current synchronization of the foreign and native subtitles is a bit sloppy and sometimes might produce unexpected results.
The add-on immediately creates an Anki card after pressing the hotkey button ('b'), but it may take a few seconds to actually generate images, audio or video. Usually, it takes less than a second to export a screenshot and audio clip, but it may take a bit more time for the video clip.
If there's an error "object has no attribute '_callbacks'" after opening the video, try closing mpv video player and reopening the video file.
If it doesn't generate any cards, try to check the fields' mapping in the add-on's settings.
This is the first Anki add-on. The second one is movies2anki - watch foreign language movies with Anki.
CREDITS
mpv - a free, open source, and cross-platform media player
mpv.py - control mpv from Python using JSON IPC, (c) Lars Gustäbel & Damien Elmes.
pysubs2 - a Python library for reading .srt and .ass subtitle files
SUPPORT ME ON LAVA.TOP
If you like my work or have found it useful, consider supporting me at https://app.lava.top/2342402818
It'll be very much appreciated.
Thank you.
--
N. <kelciour@gmail.com>