Anki Forums

Anki 2.1.35/32 doesn't play audio

Since my first installation of Anki there’s no audio playback, I came here looking for people that had the same problem and I tried almost everything from other threads and still no solution.

For a quick list of what I’ve done already:

  • Checked Media/Database
  • Restarted Anki/Computer
  • Reinstalled Anki/Deck
  • Updated my drivers
  • Manually checked if mpv is working by dragging one of the audios from the deck (yes, it works perfectly if I do that)
  • Reinstalled mpv
  • Switched the Anki version from 2.1.35 to 2.1.32 and repeated all of the above

Now for more clarification of the situation and also weird behavior:
I have looked through the task manager and it seems like Anki does initialize with mpv normally but the moment I try to play an audio from a deck it crashes instantly.
Similarly when I open the anki console it stays fine until I try to play an audio and it keeps saying:

mpv timed out, restarting
Exception: Unable to put request

This also happens when I tried to change the samplerate, when first initializing it says "audio-samplerate: None" then after playing an audio it says the same as above.
And finally, I got a debug log: Gofile

1 Like

This is very impressive.

One possible option is to install Anki 2.1.35-alternate and use this Anki version or replace mpv.exe in C:\Program Files\Anki with mplayer.exe from C:\Program Files (x86)\Anki, e.g. by renaming or deleting mpv.exe so Anki couldn’t find it.

Otherwise, I’m not sure where is the problem but the log file looks good to me, I see there “Run command: loadfile” with the actual audio file, but for some reason the log file is cut short and there no log entries that mean that the audio playback was successful. Maybe mpv got unresponsive or maybe it’s something else.

Just to be sure that “mpv.debug.log.txt” will still be the same and as before end with

[  74.652][d][ao/wasapi] Init wasapi thread
[  74.652][d][ao/wasapi] Activating pAudioClient interface

maybe start Anki with anki-console.exe and run the following code in the Debug Console to play the audio file with Anki.

filename = "ATTS audio02.mp3"

import os
from aqt.sound import mpvManager

path = os.path.join(os.getcwd(), filename)
mpvManager.command("loadfile", path, "append-play")

I assume there will be no sound. After waiting for a few seconds it should be safe to upload the log file on gofile.io or open it in the text editor.

The correct log file should look something like

[  66.004][d][ao/wasapi] Init wasapi thread
[  66.004][d][ao/wasapi] Activating pAudioClient interface
[  66.007][d][ao/wasapi] Probing formats
[  66.054][v][ao/wasapi] Trying stereo float (32/32 bits) @ 48000hz (shared) -> ok
[  66.054][v][ao/wasapi] Accepted as stereo float @ 48000hz -> stereo float (32/32 bits) @ 48000hz (shared)
[  66.054][d][ao/wasapi] Fixing format
[  66.054][d][ao/wasapi] IAudioClient::GetDevicePeriod
[  66.054][v][ao/wasapi] Device period: 10 ms
[  66.054][d][ao/wasapi] IAudioClient::Initialize
[  66.084][d][ao/wasapi] IAudioClient::Initialize pRenderClient
[  66.084][d][ao/wasapi] IAudioClient::Initialize IAudioClient_SetEventHandle
[  66.084][d][ao/wasapi] IAudioClient::Initialize IAudioClient_GetBufferSize
[  66.084][v][ao/wasapi] Buffer frame count: 2400 (50 ms)
[  66.084][v][ao/wasapi] IAudioClock::GetFrequency gave a frequency of 384000.
[  66.087][d][ao/wasapi] IAudioClient::Initialize pAudioVolume
[  66.087][d][ao/wasapi] Entering dispatch loop
[  66.087][d][ao/wasapi] Init wasapi done
[  66.087][v][ao/wasapi] device buffer: 2400 samples.
[  66.087][v][ao/wasapi] using soft-buffer of 9600 samples.
[  66.087][i][cplayer] AO: [wasapi] 48000Hz stereo 2ch float
[  66.087][v][cplayer] AO: Description: Windows WASAPI audio output (event mode)
[  66.088][v][autoconvert] inserting resampler
[  66.088][v][swresample] format change, reinitializing resampler
[  66.088][v][swresample] 44100Hz stereo floatp -> 48000Hz stereo float
[  66.088][v][af] [out] 48000Hz stereo 2ch float
[  66.089][d][osc] osc_init 
[  66.089][v][cplayer] audio ready
[  66.089][v][cplayer] starting audio playback

Also it might be better to open the Task Manager or Process Explorer and double-check that mpv.exe is still there.

After that, maybe play the same audio file directly with mpv.exe but with log-file enabled and upload it on gofile.io so we could compare two log files for any significant differences.

To enable logging with mpv.exe and create the log file on Desktop, either open cmd.exe in C:\Program Files\Anki, copy-paste something like mpv --log-file=%USERPROFILE%\Desktop\mpv.log.txt and drag-and-drop the audio file from the collection.media folder, i.e. it will look like

mpv --log-file=%USERPROFILE%\Desktop\mpv.log.txt "C:\Users\Nickolay\AppData\Roaming\Anki2\# Debug\collection.media\ATTS audio02.mp3"

https://lifehacker.com/quickly-open-a-command-prompt-from-the-windows-explorer-5989434

or create mpv folder in %APPDATA% and put there mpv.conf containing something like this

log-file=C:\Users\Nickolay\Desktop\mpv.log.2.txt

and drag-and-drop the audio file to mpv.exe.

2 Likes

Another thing to try is to try to play the same audio file with mpv and JSON IPC to see if it’s Anki-related or mpv-related.

https://mpv.io/manual/master/#json-ipc

  1. Open cmd.exe in “C:\Program Files\Anki”.

  2. Run mpv -v --no-config --idle --input-ipc-server=\\.\pipe\mpvsocket


    If there’s no visible output, make sure that mpv.com can be found alongside with mpv.exe.

  3. Open another cmd.exe. It could be anywhere.

  4. Run something like

    echo loadfile "C:\\Users\\Nickolay\\AppData\\Roaming\\Anki2\\User 1\\collection.media\\audio.mp3" >\\.\pipe\mpvsocket

    The path should be absolute and \ should be replaced with \\ or /.

  5. You should hear the audio file and if you take a look at the first cmd.exe window, it should be updated with new information and contain the corresponding log entries about the audio playback.

If the audio doesn’t work and log entries in cmd.exe with input-ipc-server are cut short like in the log file on gofile, it’d be a bit strange that the same audio file will play fine directly with mpv but won’t with JSON IPC, but since it could be reproducible without Anki, it might be better to create a new issue on Issues · mpv-player/mpv · GitHub

1 Like

Okay here we go

This works just fine (honestly I should’ve done this first since it is already suggested, guess I’m that dumb).

So I went back to normal Anki to help with the debugging instead of just leaving mpv hanging with the issue. I made 5 logs going through your posts, I was going to post them in a .7z file but I thought that it may be inconvenient for you to download a zip file or go through 5 different links for each log (and because you probably use gofile just to not have to download anything because of the preview feature) so I decided to just stick them all together in a single .txt file. Gofile
So in order we have:

mpv.debug.log0-first.txt
This one was just a log from when I first reinstalled the standard Anki again, thought of looking at it and I noticed that there’s some strange stuff in there, it seems like mpv doesn’t even load?

mpv.debug.log-new1.txt
This one was when I reinstalled mpv with the newer version, just like before, still the same.

mpv.debug.log2-consoleloop.txt
This one was really weird, I started Anki with anki-console.exe to play the audio through the Debug Console and the moment I started anki-console.exe I don’t know what happened but it started restarting mpv over and over again, I looked at the Task Manager what was going on and it was just starting and closing mpv over and over:


mpv.debug.log3-debugconsole.txt
Now this is also from starting Anki with anki-console.exe, but this time it magically worked so I just went straight ahead to test with playing the audio through the Debug Console and that’s what happened, it looks like it the same as the other tries? And also the Debug Console always says: <no output> the first time I ask it to play the audio (and also mpv doesn’t get closed) and the second time I do it it always goes back to the mpv timed out, restarting message (and mpv closes)

and finally for the last one
mpv.log.2.txt
This is from just dragging the audio to mpv, the audio playing just fine like always, and I checked the log and it looks something like what you sent and said to be correct.

Now about JSON IPC:
This seems to be it, with IPC the audio doesn’t work and also the log is cut short.


1 Like

Thank you! Unfortunately, the good log file wasn’t much of a help. I don’t see any difference between the correct one and the one that is cut short.

mpv.debug.log0-first.txt

It looks like Anki was opened, no file was played, and then closed a bit later and it looks good to me.

[   0.014][v][ipc] Starting IPC master
[   0.015][v][ipc] Listening to IPC pipe.
...
[   0.102][v][ipc_0] Client connected
...
[  18.064][v][cplayer] Run command: quit, flags=0, args=[0]
[  18.064][i][cplayer] 
[  18.064][i][cplayer] Exiting... (Quit)
[  18.064][v][ipc_0] Exiting...

mpv.debug.log2-consoleloop.txt

I’m not sure what could cause a lot of “mpv timeout out, restarting” messages, it probably won’t happen anymore and probably not worth the time to investigate.

mpv.debug.log3-debugconsole.txt

Yes, the log file looks the same as before, and <no output> in the Debug Console and mpv timed out, restarting after the second try are to be expected.

JSON IPC

Thank you. I happened to find a similar issue that is related to JSON IPC and Windows. It’s a few years old. Unfortunately, no sample was provided and in the end there were no progress. It’s about the video file, but everything looks similar.

Playing directly on mpv.exe - no issues, movie plays great throughout

Playing via Emby Theatre on Windows 7 - movie freezes at the 00:26:25 mark, consistently, also tested by other users.

Seems like it actually uses json IPC

The log just stops

If you’d like to continue, I googled a bit and have two ideas, but I’m not sure if they’ll reveal something useful.

At first, get a stacktrace for mpv.exe.

  1. Close Anki if it uses mpv.exe (to make sure that no mpv.exe is running)

  2. Download mpv from https://sourceforge.net/projects/mpv-player-windows/files/64bit/mpv-x86_64-20190831-git-b539eb2.7z

  3. Download mpv-debug-x86_64-20190831-git-b539eb2.7z from mpv player (Windows) - Browse /debug-symbol at SourceForge.net and put mpv.debug in the same folder as mpv.exe.

  4. Download drmingw-0.9.2-win64.7z from Release 0.9.2 · jrfonseca/drmingw · GitHub and unpack it in the same folder as mpv.exe.

  5. Open cmd.exe and start mpv using something like this:

    mpv -v --no-config --idle --force-window=yes --input-ipc-server=\\.\pipe\mpvsocket

  6. Open another cmd.exe and try to play the audio file the same way as before.

    echo loadfile "C:\\Users\\Nickolay\\AppData\\Roaming\\Anki2\\User 1\\collection.media\\audio.mp3" >\\.\pipe\mpvsocket

  7. I guess, it won’t work and the log output will be cut short.

  8. In this case, run drmingw -b -p mpv.exe to get a stack trace and wait maybe 5-10 seconds and use File to save it as txt. Maybe it’ll contain something useful.

    https://github.com/jrfonseca/drmingw#how-can-i-get-a-stack-trace-from-a-process-that-is-hung

    I’m not sure I’ll be able to understand it, but maybe ipc-win.c will be not @ 387, but something else.

    0000000000ED8793 ... 0000000000000000 mpv.exe!ipc_thread [/home/shinchiro/build/build64/packages/mpv-prefix/src/mpv/build/../input/ipc-win.c @ 387]

After that, close Dr. Mingw (drmingw), mpv will be closed too, repeat 5-6 steps, i.e. start mpv with mpvsocket and echo loadfile, and then try something like this.

  1. Try to resize mpv window and take a look at the console window with --input-ipc-server=\\.\pipe\mpvsocket. The window should be updated with new log messages. Or maybe press 9 or 0 keys to see if mpv is still responding to key presses.

  2. I guess, mpv won’t respond and you won’t see any new output in the cmd.exe window with \.\pipe\mpvsocket. I doubt it’ll help, but just in case, go to cmd.exe window with \.\pipe\mpvsocket, click on it and press Enter a few times.

  3. Next, open Process Explorer, File > Show Details for All Process, then Find > Find Handle or DLL and search for mpvsocket, then close it.

  4. Then try to resize mpv window again and press 9 or 0. Maybe mpv won’t be unresponsive anymore. Maybe try to drag-and-drop the audio file. Maybe it’ll be paused, but after pressing Space it probably will be played fine since IPC was closed.

2 Likes

It actually worked when doing that

1 Like

Maybe open cmd.exe and try to play the audio file with

mpv -v --no-config "C:\\Users\\...\\collection.media\\audio.mp3"

(exptected result: it won’t work, but it probably will work)

and

mpv -v --no-config --force-window=yes "C:\\Users\\...\\collection.media\\audio.mp3"

(expected result: it will work)

And try this one too.

mpv -v --no-config --audio-samplerate=48000 --idle --input-ipc-server=\\.\pipe\mpvsocket

echo loadfile "C:\\Users\\...\\collection.media\\audio.mp3" >\\.\pipe\mpvsocket

And maybe try the add-on - No Sound Fix (libmpv) - AnkiWeb

After installing the add-on and restarting Anki, the audio will be played using https://github.com/jaseg/python-mpv and libmpv instead of JSON IPC.

The add-on requires Anki 2.1.36+.

But I doubt it’ll help.

1 Like

Yes, it didn’t work when doing that.

Also yes, it worked when doing that.

This didn’t work, here’s what happened:

This worked perfectly for me (Anki 25.1.38), good job on the add-on and nice bug hunting, now I’ll go back to learning Russian since it seems like this is properly solved now lol.

1 Like

I have the same problem, but it started after upgrading my pc from an Intel i5-2500 to an AMD Ryzen 5 5600X.
I was on the latest version of Windows 10 before. Audio was playing correctly.
After upgrading to my new AMD system I did a clean install to the latest version of Windows 10 and now audio isn’t playing anymore in Anki.
I replaced “mpv.exe” with “mplayer.exe” from the alternate installer and now audio is working correctly.

Same problems as OP, working with this and ofc with anki 32bits

The latest beta contains an updated mpv. Does it help?

2 Likes

The new beta fixed it for me.

2 Likes