Ajatt-Tools / mpvacious

🍜 Adds mpv keybindings to create Anki cards from movies and TV shows.
https://tatsumoto-ren.github.io/blog/mining-from-movies-and-tv-shows.html
GNU General Public License v3.0
602 stars 51 forks source link

Problems with base64 encoding #94

Closed rivke41levp656 closed 1 year ago

rivke41levp656 commented 1 year ago

OS name: arch linux mpv version: 0.35.1

2 problems:

1) starting from commit 059f505, every time I add a card there is monstrous garbage output to the terminal like so

. . .
VqRb8qSyn/JnAEJi6viFLmOO7tejU4vEWDci1n907ae0Tuz1PrT2PHVWxzpa1T9rPREg70E+mQvQPlbeyKgV+3yO7XXEMNE2bAUhyzWeyzITneK9jc7w8oMF/FlxiAurqr1wLEG3DqnPx26naanm8axzgebur7dgB5AQmFFA3l+NerWCmXpQQ6EtXpP3zd3Um3/UAAAAA="},"action":"storeMediaFile","version":6}' 
mpvacious_059f505106e5a26ed545b6b9f72e950d1bd4ca68: Couldn't store file 'file_52m20s000ms-52m25s000ms.webp': Ankiconnect isn't running 

My terminal only shows 1000 lines, so there are over 1000 lines of garbage preceding this. I increased it to 5000 to test this and it still fills up the entire terminal. So something is terribly wrong with this base64 stuff.

2) In addition to the above, some snapshots will have audio but fail to play any video. Some are still fine though, despite the above message saying Couldn't store . . .

46f2836 works perfectly and I only tested 1 card but I think eb563de is fine too.

here is my config ``` deck_name=deck model_name=model sentence_field=SentKanji secondary_field=SentEng audio_field=SentAudio image_field=Image note_tag=subs2srs note_tag=%n %t menu_font_size=24 menu_font_name=Noto Serif CJK JP use_ffmpeg=yes create_deck=yes allow_duplicates=yes autoclip=no nuke_spaces=yes tie_volumes=no clipboard_trim_enabled=yes append_media=yes tag_nuke_brackets=no tag_nuke_parentheses=no tag_del_episode_num=yes tag_del_after_episode_num=no tag_filename_lowercase=no disable_gui_browse=no preview_audio=no show_selected_text=yes snapshot_format=webp snapshot_quality=50 snapshot_width=-2 snapshot_height=720 screenshot=no image_template=snapshot animated_snapshot_enabled=yes animated_snapshot_fps=10 animated_snapshot_width=-2 animated_snapshot_height=720 animated_snapshot_quality=0 audio_format=opus audio_bitrate=32k audio_padding=0.0 use_forvo=no vocab_field=VocabKanji vocab_audio_field=VocabAudio miscinfo_enable=yes miscinfo_field=Notes miscinfo_format=%n EP%d (%t) secondary_sub_lang= secondary_sub_area=0.15 secondary_sub_visibility=auto ffmpeg_audio_args=-af loudnorm=I=-16:TP=-1.5:LRA=11 mpv_audio_args=--af-append=silenceremove=1:0:-50dB --af-append=loudnorm=I=-16:TP=-1.5:LRA=11 ```
tatsumoto-ren commented 1 year ago

Does this problem persist when you have Anki open and AnkiConnect installed and running?

tatsumoto-ren commented 1 year ago

Currently files are sent in base64-encoded form to work around problems that can arise when Anki is sandboxed and doesn't have access to /tmp. If you run mpv from the terminal, the output will be long, but I don't see why a request would fail. Yomichan uses the same process for adding media to cards.

rivke41levp656 commented 1 year ago

Yes, everything I described is with ankiconnect installed and anki open.

tatsumoto-ren commented 1 year ago

I think this problem occurs when using animations. Can be due to large sizes of the generated files.

rivke41levp656 commented 1 year ago

Yes that seems to be part of it. I reduced the resolution from 720 to 120 and the fps from 10 to 1 and now it makes a card with video and the "Couldn't store ... " message went away.

tatsumoto-ren commented 1 year ago

If you revert 059f505, the problem goes away.

Or for now you can stick to static images. If the PR to AnkiConnect is merged, I'll push a fix using that.