Anki crashes because of MPV

I’m having a little issue since I updated Anki a while ago. (the update that made MPV controls available) And since then my Anki keeps on crashing in very specific scenarios:

scenario 1 : If I play a video from an Anki card and toggle to another window, when the video is over, Anki crashes and I lose some of my progress. (this happens every single time no exceptions)

Scenario 2 : If I play a video and use the controls of the MPV player. (this happens only a few times, every 3 or 4 times ,say)

Scenario 3 : If I play a video and then use the X button to close the video, Anki will crash (this isn’t as frequent, maybe every 5 or 6 times)

Anybody thinks they might have a solution or a clue as to why this happens?

It kinda gets annoying and gets in the way of reviewing since I review about a 100 cards a day, and this thing crashes like a good 4-5 times a day.

Thanks in advance,

@kelciour this sounds similar to Tons of images missing in Anki Iphone - if you have any ideas your input would be appreciated as usual :slight_smile:

I actually tried the new version now, so yes same - it crashes (Anki, not a video player.)

And now I faced a new problem. I can’t install the old version because of error :joy:

Okay, actually I solved this problem with installing Anki in another directory.

and I can’t reply to the mentioned topic anymore. y everything is so complicated :sob:

@dae thank you, I’ll try to do what I can.

@influencia @mysaturnday thank you, that was very helpful. I could reproduce the issue with mpv video player on Windows when Anki is no longer responding and can only be closed with the Task Manager.

I could reproduce it with the packaged mpv version and with the latest mpv version. It’s a bit random, though with the latest mpv version it seems to happen more frequently. I used a deck with one card and ~3 seconds video for testing. I clicked the audio play button, the video file started playing, went back to Google Chrome, and when the video file stopped playing clicked Anki icon in the taskbar, and if Anki was still responding clicked the audio play button again and went back to Google Chrome. Sometimes it happened on the 3rd try, sometimes on 5th or 10th, but sometimes I couldn’t reproduce it and restarted Anki to try again.

@influencia I believe you’re talking about the same problem as @mysaturnday , i.e. the main Anki window is still there, but it’s greyed out and you can’t click on anything. It should be scenario 1 (“when the video is over”) and scenario 3 (“use the X button to close the video”).

@influencia and @mysaturnday for now please try to install the add-on “Video Fix 1” - - restart Anki and let me know if it still happens. The add-on will tell Anki to create a new mpv.exe process every time to play the audio or video file. It seems to work for me but I haven’t tested it very much.

@influencia If mpv crashes in the middle of the video playback (probably scenario 2), try to update your graphics card driver, restart your PC and install the latest mpv version.

If it won’t help, we could try then to tell mpv to enable or disable hardware decoding or try a different video output driver or maybe some other mpv options.


Thank you, that fix works!

There is another problem with the new player: it doesn’t respond to shorcated buttons. Sometimes it can only respond to “space” but sometimes it just “passes” the actual cart, and what’s more, after switching to a new card, it doesn’t close automatically. The problem is also that “escape” doesn’t work anymore for closing player, and what’s more frustrating, if it’s an audio card, i can’t even pause the sound.

I attached this three non-functional buttons in the next screenshot.


Sorry, I didn’t think about the hotkeys and the hotkeys won’t work with “Video Fix 1”. Though it should still close automatically if you move to the next card and Tools - Preferences - “Interrupt current audio when answering” is checked.

The “q” button can be used to close the video player, but the issue with the space bar seems to be caused by mpv window isn’t being active sometimes, i.e. focused, and it’s something that needs to be investigated alongside with the original issue when Anki is no longer responding after the video is closed.

I’d suggest to install the alternate Anki version for now. There should be no noticeable differences on Windows and it’s packaged with mplayer and should work as it used to be in earlier Anki versions.

1 Like

I would like to use the old version, but it causes errors in sync media with my iPhone, - that what this discussion started about 1 month ago :sweat_smile: .

Also, the new hotkeys(media player binded) doesn’t work every time you press it.

Seem like we have nothing to do with it for now, and just need to wait for the next update… ?

Maybe install 2.1.34-alternate for now as mplayer doesn’t seem to cause the freezing issue.

just a picture

About media sync, I’d recommend to watch new intro videos about syncing.

And if I correctly understood the issue with the hotkeys, they only work in Anki, i.e. they should work just fine with the audio file, but with the video file the hotkeys will only work if Anki window is active, i.e. focused.

The freezing issue is yet to be investigated. I tried a different backend for mpv video player as a temporary workaround - Video Fix 2 - AnkiWeb (Video Fix 2) - but it didn’t go well, Anki can only be closed from the task manager and I couldn’t quickly find where is the problem, but it looks like the freezing issue is still there.

The freezing issue seems to be possible to reproduce with a short video clip like this one - Gofile - Free file sharing and storage platform - it seems to be a bit random and might take some time to trigger it.

I’m not sure if I’ll be able to handle it, but I’ll try to find a way to fix it, or maybe a possible workaround, over the weekend.

@kelciour Apologies for the naive questions, I have not been following closely. Is this issue limited to videos? Does it occur if a new mpv process is started each time? If yes to both those questions, perhaps we could work around the issue by loading a new mpv process when a video file is encountered, instead of using the slave mode machinery?

@dae Yes and yes, the issue seems to be limited to videos and I can’t reproduce it after starting a new mpv process each time.

I haven’t thought about it and that was very helpful. Thank you! I’ll do it.

1 Like

A basic proof of concept:

Edit: is_audio_file() should handle the case where the extension is missing

1 Like

Thank you @dae. It looks like there isn’t much for me to do and it’s much better than I could come up with. Maybe a few modifications.

I changed is_audio_file by copy-pasting a line from, added config-dir to mpv and removed startupinfo because it causes the video window to be hidden and nowhere to be found on the latest mpv version. I considered using something like and so it could be later overridden with None but wasn’t sure it’s necessary and would make sense.

I used make fix and the formatting is a bit different now.

My concern is how Mac will handle two mpv processes. Just in case, I sligntly changed the code to make it work on Mac and Linux as it used to be, i.e. just mpvManager for sound and video, and SimpleMpvPlayer will only be used on Windows and also set default_rank = 1 to make it to be chosen by Anki for video files.

It’s probably not possible to fork the same gist two times and this is a new one.

1 Like

The rank was originally intended to be used by add-ons, but it should work here. Happy to merge such a patch after 2.1.35 comes out - thanks for turning a proof of concept into a proper solution :slight_smile:

1 Like