I received this error while reviewing a deck with cards that had video (mp4)

^Title.
The error reads: “Sound and video on cards will not function until mpv or mplayer is installed.” I checked the anki folder in the program files folder in my c-drive, and I saw that the mpv application was in there. I reinstalled Anki multiple times, but after each reinstallation, the error still showed. Anyone know a fix?

Maybe Anki can’t find mpv.exe or can’t start it. Try to…

  • Reinstall or update Anki

  • Start Anki and hold down the Shift key (to disable the add-ons)

  • Double-click on mpv.exe and drag-and-drop any audio or video file (to make sure that mpv.exe works fine on its own)

    image

  • Replace mpv.exe (and d3dcompiler_43.dll just in case) with the latest ones from https://sourceforge.net/projects/mpv-player-windows/files/64bit/


To investigate a bit, the following code could be executed in the debug console.

https://docs.ankiweb.net/misc.html#debug-console

from distutils.spawn import find_executable
from aqt.sound import mpvManager

executable = find_executable("mpv")

print(executable)
print(mpvManager)

For example, if Anki can’t find mpv.exe, the output will be

None
None

The first line will be None if Anki can’t find mpv.exe (in the same folder as anki.exe or somewhere in the PATH environment variable).
The second line will be None if Anki can’t start mpv.exe.

If everything is okay, the output will be

C:\Program Files\Anki\mpv.exe (or just mpv.exe)
<aqt.sound.MpvManager object at 0x0000021DAF594D00>
2 Likes

I replaced the two files you mentioned in the Anki folder and confirmed that mpv.exe was working. I even started the app with the add-ons disabled by holding shift like you suggested, but the error still appeared. After each solution, I used the code you sent in the debug console, and the first line was okay. The second line returned “None,” though, so I don’t know why Anki cannot start mpv.exe.

Please try starting Anki via anki-console.bat, then run this in the debug console before attempting to play a sound. What does it print/popup?

import aqt.sound as s
def repl(ret, cb):
  ret.result()
  cb()
s.MpvManager._on_done = repl
1 Like

It prints no output.

Ah, sorry, since it’s about video, maybe Anki can’t find mpv.exe for some reason.

What’s the output from this code in the debug console?

import sys
from aqt.sound import _packagedCmd

mpvPath, popenEnv = _packagedCmd(["mpv"])
print(mpvPath)

packaged_path = Path(sys.prefix) / ("mpv.exe")
print(packaged_path.exists())
print(sys.prefix)
1 Like

[‘C:\Program Files\Anki\mpv.exe’]
True
C:\Program Files\Anki

It looks good and everything seems to be okay.

What about this code? What’s the output?

from aqt.sound import av_player
print(av_player.players)

Maybe also try this slight modified version. The test video will be played, if everything is okay, or some error message will pop up.

import aqt.sound as s

def repl(self, ret, cb):
  ret.result()
  cb()

s.SimpleMpvPlayer._on_done = repl

from aqt import mw
from anki.sound import SoundOrVideoTag

player = s.SimpleMpvPlayer(mw.taskman, mw.pm.base, mw.col.media.dir())
filename = SoundOrVideoTag(filename="https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4")
player.play(filename, lambda: None)

The first bit of code you sent gave me this:
[<aqt.sound.SimpleMplayerSlaveModePlayer object at 0x000001CED696BF70>, <aqt.tts.WindowsTTSPlayer object at 0x000001CED696BFA0>, <aqt.tts.WindowsRTTTSFilePlayer object at 0x000001CED696BF40>]

Then, I tried the code with the test video, and I got “” as well as an error message that stated I needed to restart Anki and disabling add-ons by holding down shift.

Could you copy or show the last line from the error message?

Also run this code in the debug console to see if it works or not.

from aqt import mw
from aqt.sound import _packagedCmd
import subprocess

args, env = _packagedCmd(
        [
            "mpv",
            "--no-terminal",
            "--force-window=no",
            "--ontop",
            "--audio-display=no",
            "--keep-open=no",
            "--input-media-keys=no",
            "--autoload-files=no",
        ]
    )

base_folder = mw.pm.base
media_folder = mw.col.media.dir()
args += [f"--config-dir={base_folder}"]

filename = "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4"

env["PATH"] = r"C:\Program Files\Anki;" + env["PATH"]
_process = subprocess.Popen(
    args + [filename],
    env=env,
    cwd=media_folder,
    stdout=subprocess.DEVNULL,
    stderr=subprocess.DEVNULL,
)

Just to confirm, since my instructions above were not clear - I meant what does it print or show when you go to play a file after doing that?

Anki 2.1.62 (77dd1dc1) Python 3.9.15 Qt 6.4.3 PyQt 6.4.0
Platform: Windows-10-10.0.19045
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-05-08 13:46:43

Caught exception:
Traceback (most recent call last):
File “aqt.taskman”, line 122, in _on_closures_pending
File “aqt.taskman”, line 71, in
File “aqt.sound”, line 297, in
File “”, line 4, in repl
File “concurrent.futures._base”, line 439, in result
File “concurrent.futures._base”, line 391, in __get_result
File “concurrent.futures.thread”, line 58, in run
File “aqt.sound”, line 297, in
File “aqt.sound”, line 306, in _play
File “subprocess”, line 951, in init
File “subprocess”, line 1420, in _execute_child
OSError: [WinError 87] The parameter is incorrect

Traceback (most recent call last):
File “aqt.debug_console”, line 292, in onDebugRet
File “”, line 25, in
File “subprocess”, line 951, in init
File “subprocess”, line 1420, in _execute_child
OSError: [WinError 87] The parameter is incorrect

Prints no output. I can’t play the video file in the card since the error mentioned in the original post still occurs.

OSError: [WinError 87] The parameter is incorrect

By any chance, do you have COMODO Antivirus installed and running (or any other third-party antivirus)? Maybe try to turn it off to see if it makes any difference.

I had the exact same WinError 87, strange location error. (Win10/RenderDoc1.13/MMIv0.4.1/Blender v3.0.1/SacreCoeur).
=> It turned out, this was my COMODO Antivirus software messing somehow.

https://github.com/eliemichel/MapsModelsImporter/issues/180#issuecomment-1037621133

I’m not sure why exactly the WinError 87 was thrown, but I managed to solve the issue by shutting off auto containment in Comodo.

https://stackoverflow.com/a/56313754

2 Likes

I had the original error on a school laptop (this error with video does not occur on my other laptop). I found that this laptop had COMODO antivirus, however, turning it off requires a password from my school administrators. They also do quarterly checks on laptops to ensure nothing “malicious” has been done by students, so I am honestly thinking of giving up here. I think I’ll just workaround the issue via imgur links with sound. Thanks for the help, I appreciate you giving your time.

1 Like

So that we can improve the error message for future people hitting this issue, could you confirm that the following is shown when starting Anki via anki-console.exe?

mpv too old, reverting to mplayer

Just in case, I updated Zzz (legacy) No Sound Fix (libmpv) - AnkiWeb to support videos too. If you can install add-ons, there’s a chance that it will work with Comodo. But in certain situations it might cause Anki to freeze and stop responding (at least if the Add screen is opened/closed while the video was playing).

Alternatively, <audio> and <video> HTML tags might work too after using Find and Replace to convert [sound.audio.mp3] to <audio src="audio.mp3" controls=""></audio> and [sound.video.mp4] to
<video src="video.webm" controls=""></video><img src="video.webm" hidden="">. But it might take some time to batch convert all mp4 files in the collection.media folder to webm using FFmpeg from the command line.
for %I in (*.mp4) do ffmpeg -i "%I" -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus -b:a 64k "%~nI.webm"