Audio not playing on desktop/ causing crashes

Hello All,
Recently made some flash cards with audio included in them on desktop. However, the audio will not play and causes to program to massively slow down on desktop (and crash if I hit play audio 2 times) but works fine on iOS (I just have to get play audio a few times) and perfectly on AnkiWeb. I tried uninstalling, deleting all files, downgrading to an older version, resetting computer, getting different sources for audio but I still can’t make it work on any deck.
Update: tried downloaded ones and they didn’t work either.
Thanks for any help you can offer!

That’s quite unusual. Have you tried starting Anki with the add-ons disabled? I noticed you didn’t mention it as an already-taken step.

Another option would be to check whether the following option is disabled or not in the deck options.

anki_Rs1LhMjyso

1 Like

Could you please try to run anki from python and post the log of the application, especially what is printed when you try to play audio?

1 Like

Sorry, should have out this in the original post but that did not work.

I downgraded to Anki 2.1.15 and that was able to get everything working before I saw your post. If something like this happens again in the future I’ll be sure to do that, thanks for reaching out. (I apologize for wasting your time :frowning: )

Anki 2.1.15 is starting to get quite outdated. I would recommend trying to figure out what the problem is right away, before you realize you miss a feature from an older version, or that version simply goes unsupported.

1 Like

@kelciour I see you’ve marked your add-on as legacy; is it no longer of any help for users hitting this issue on 2.1.49?

https://ankiweb.net/shared/info/1586469444

1 Like

@dae I thought that the add-on is no longer needed for Windows, had no intention to update the add-on (libmpv) in the future and marked it as legacy. By the time the add-on is loaded, mpv.exe will be already started by Anki and successfully communicated through the named pipe, and theoretically the add-on should make no difference.

But the add-on doesn’t create a separate mpv.exe process, uses a different way to communicate with mpv and maybe it’ll be still useful for testing purposes to eliminate some possibilities, maybe just in case if the issue is somehow related to Windows or some antivirus software, I don’t know. This is in case if Asus Sonic Studio isn’t installed on Windows as it might cause no sound in Anki (according to two people here and one person on Reddit).

@Jbro I guess it’s about Mac, not Windows. If one day the same issue happens again, maybe the log file from mpv will reveal anything useful.

Anki uses a program called mpv in order to support sounds and videos.
https://docs.ankiweb.net/media.html?highlight=mpv#supported-formats

If it’s easily reproducible, just run this code in the debug console after opening Anki to temporarily enable mpv logging (until Anki isn’t closed or mpv isn’t restarted). Once Anki got unresponsive or crashed, take a look at mpv.log.txt in the Desktop folder.

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

import os
from aqt import mw
from aqt.sound import mpvManager
logfile = os.path.join('~/Desktop', 'mpv.log.txt')
Logfile = os.path.expanduser(logfile)
mpvManager.set_property("log-file", logfile)
print('log-file:', mpvManager.get_property('log-file'))

If the issue isn’t easily reproducible, it might be better to enable mpv logging all the time by running this code in the debug console (just one time) to create mpv.conf in ~/Library/Application Support/Anki2. In this case, mpv.log.txt will be also saved to ~/Library/Application Support/Anki2.

https://docs.ankiweb.net/files.html#file-locations

import os
from aqt import mw
from aqt.sound import mpvManager
logfile = os.path.join(mw.pm.base, 'mpv.log.txt')
path = os.path.expanduser(logfile)
with open(os.path.join(mw.pm.base, 'mpv.conf'), 'a') as f:
    f.write('log-file={}\n'.format(path))
print('log-file:', mpvManager.get_property('log-file'))
mpvManager.shutdown()
print('log-file:', mpvManager.get_property('log-file'))

In this case, it might be better to also install the “No Sound Debug” add-on (https://ankiweb.net/shared/info/881480056) to prevent Anki from trying to restart mpv again and again and overwriting the log file.

Incidentally, the add-on might also prevent the crash, if the crash happens because Anki is trying to restart mpv again and again.

Alternatively, if the sound doesn’t work at all, for example, you don’t hear any sound played back by Anki after pasting this mp3 url https://www.groovydomain.com/gallery/music/ORIGINAL/Pink%20Floyd/The%20Dark%20Side%20of%20the%20Moon/09%20Eclipse.mp3 to some field in the editor (it’s from https://tools.woolyss.com/html5-audio-video-tester/), maybe try to play the same audio file with mpv from the Terminal, i.e. mpv audio.mp3. At first open Terminal.app, copypaste /Applications/Anki.app/Contents/Resources/audio/mpv (for Anki 2.1.49), press Space, then use Finder to locate the audio file in the collection.media folder and drag-and-drop it to the Terminal (to copy the full path), and press Return.

4 Likes

@kelciour Sorry, that was a thinko on my part - I’d assumed the OP was on Windows, and had forgotten we’d switched the Windows code away from a long-running process.

2 Likes

Should have mentioned this in the original post but I am windows. I also have ASUS sonic studio installed as it came with my ASUS motherboard.
One last note is when anki crashes I cannot open it back up until I restart my computer.
Here is the file that your debug code made:

[ 109.579][v][cplayer] mpv 0.33.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects
[ 109.579][v][cplayer] built on Sun Dec 6 10:03:04 +08 2020
[ 109.579][v][cplayer] FFmpeg library versions:
[ 109.579][v][cplayer] libavutil 56.62.100
[ 109.579][v][cplayer] libavcodec 58.114.100
[ 109.579][v][cplayer] libavformat 58.64.100
[ 109.579][v][cplayer] libswscale 5.8.100
[ 109.579][v][cplayer] libavfilter 7.92.100
[ 109.579][v][cplayer] libswresample 3.8.100
[ 109.579][v][cplayer] FFmpeg version: git-2020-12-05-89e3f5ab
[ 109.579][v][cplayer]
[ 109.579][v][cplayer] Configuration: /home/shinchiro/build64/packages/mpv-stable-prefix/src/mpv-stable/waf configure --enable-static-build --enable-pdf-build --disable-manpage-build --enable-libmpv-shared --enable-lua --enable-javascript --enable-sdl2 --enable-libarchive --enable-libbluray --enable-dvdnav --enable-uchardet --enable-rubberband --enable-lcms2 --enable-openal --enable-spirv-cross --enable-vulkan --enable-vapoursynth --prefix=/home/shinchiro/build64/install/mingw
[ 109.579][v][cplayer] List of enabled features: asm build-date cplayer cuda-hwaccel cuda-interop d3d-hwaccel d3d11 d3d9-hwaccel debug-build direct3d dos-paths dvdnav egl-angle egl-angle-win32 egl-helpers ffmpeg ffnvcodec gl gl-dxinterop gl-dxinterop-d3d9 gl-win32 glob glob-win32 gpl iconv javascript jpeg lcms2 libarchive libass libavdevice libbluray libm libmpv-shared libplacebo lua luajit mingw noexecstack openal optimize plain-gl posix-or-mingw rubberband sdl2 sdl2-audio sdl2-gamepad sdl2-video shaderc shaderc-static sixel spirv-cross spirv-cross-static static-build stdatomic uchardet vapoursynth vulkan wasapi win32-desktop win32-internal-pthreads zimg zlib
[ 109.579][v][cplayer] Set property: log-file="~/Desktop\mpv.log.txt" → 1
[ 117.898][d][cplayer] Run command: loadfile, flags=64, args=[url=“C:\\Users\\JBromme\\AppData\\Roaming\\Anki2\\User 1\\collection.media\\pronunciation_ja_一方的.mp3”, flags=“replace”, options=“pause=no”]
[ 117.898][d][global] config path: ‘watch_later’ → ‘C:\Users\JBromme\AppData\Roaming\Anki2/watch_later’
[ 117.898][v][cplayer] Setting option ‘pause’ = ‘no’ (flags = 16)
[ 117.898][v][cplayer] Running hook: ytdl_hook/on_load
[ 117.898][v][ytdl_hook] ytdl:// hook
[ 117.898][v][ytdl_hook] not a ytdl:// url
[ 117.898][v][ifo_dvdnav] Opening C:\Users\JBromme\AppData\Roaming\Anki2\User 1\collection.media\pronunciation_ja_一方的.mp3
[ 117.898][v][bdmv/bluray] Opening C:\Users\JBromme\AppData\Roaming\Anki2\User 1\collection.media\pronunciation_ja_一方的.mp3
[ 117.898][v][file] Opening C:\Users\JBromme\AppData\Roaming\Anki2\User 1\collection.media\pronunciation_ja_一方的.mp3
[ 117.898][d][file] resize stream to 131072 bytes, drop 0 bytes
[ 117.898][d][file] Stream opened successfully.
[ 117.898][v][demux] Trying demuxers for level=normal.
[ 117.898][d][demux] Trying demuxer: disc (force-level: normal)
[ 117.898][d][demux] Trying demuxer: edl (force-level: normal)
[ 117.898][d][demux] Trying demuxer: cue (force-level: normal)
[ 117.898][d][demux] Trying demuxer: rawaudio (force-level: normal)
[ 117.898][d][demux] Trying demuxer: rawvideo (force-level: normal)
[ 117.898][d][demux] Trying demuxer: mkv (force-level: normal)
[ 117.898][d][demux] Trying demuxer: libarchive (force-level: normal)
[ 117.898][d][demux] Trying demuxer: lavf (force-level: normal)
[ 117.900][v][lavf] Found ‘mp3’ at score=12 size=2048.
[ 117.900][v][lavf] Found ‘mp3’ at score=12 size=4096.
[ 117.900][v][lavf] Found ‘mp3’ at score=12 size=8192.
[ 117.901][v][lavf] Found ‘mp3’ at score=51 size=16384.
[ 117.901][d][ffmpeg/demuxer] mp3: Skipping 0 bytes of junk at 11932.
[ 117.904][w][ffmpeg/demuxer] mp3: Estimating duration from bitrate, this may be inaccurate
[ 117.904][v][lavf] avformat_find_stream_info() finished after 20419 bytes.
[ 117.904][v][demux] Detected file format: mp3 (libavformat)
[ 117.904][v][cplayer] Opening done: C:\Users\JBromme\AppData\Roaming\Anki2\User 1\collection.media\pronunciation_ja_一方的.mp3
[ 117.904][v][cplayer] Running hook: ytdl_hook/on_preloaded
[ 117.904][v][lavf] select track 0
[ 117.904][i][cplayer] Video --vid=1 [P] ‘Forvo’ (png 200x200)
[ 117.904][i][cplayer] (+) Audio --aid=1 (mp3 1ch 44100Hz)
[ 117.904][i][display-tags] File tags:
[ 117.904][i][display-tags] Artist: Forvo
[ 117.904][i][display-tags] Album: Pronunciation in Japanese
[ 117.904][i][display-tags] Title: 一方的
[ 117.904][v][ad] Codec list:
[ 117.904][v][ad] mp3float (mp3) - MP3 (MPEG audio layer 3)
[ 117.904][v][ad] mp3 - MP3 (MPEG audio layer 3)
[ 117.904][v][ad] Opening decoder mp3float
[ 117.904][v][ad] Requesting 1 threads for decoding.
[ 117.904][v][ad] Selected codec: mp3float (MP3 (MPEG audio layer 3))
[ 117.904][v][af] User filter list:
[ 117.904][v][af] (empty)
[ 117.904][v][cplayer] Starting playback…
[ 117.905][v][af] [in] 44100Hz mono 1ch floatp
[ 117.905][v][af] [userspeed] 44100Hz mono 1ch floatp
[ 117.905][v][af] [userspeed] (disabled)
[ 117.905][v][af] [convert] 44100Hz mono 1ch floatp
[ 117.905][v][ao] Trying audio driver ‘wasapi’
[ 117.905][v][ao/wasapi] requested format: 44100 Hz, mono channels, floatp
[ 117.905][d][ao/wasapi] Init wasapi
[ 117.905][d][ao/wasapi] Find device ‘’
[ 117.908][v][ao/wasapi] No device specified. Selecting default.
[ 117.909][v][ao/wasapi] Selecting device ‘{6ca16258-bb1d-43b8-898f-fb107ccfe57c}’ (Speakers (Realtek High Definition Audio))
[ 117.909][v][ao/wasapi] Monitoring changes in device {0.0.0.00000000}.{6ca16258-bb1d-43b8-898f-fb107ccfe57c}
[ 117.935][d][ao/wasapi] Init wasapi thread
[ 117.935][d][ao/wasapi] Activating pAudioClient interface
[ 121.280][v][ipc_2] Client connected
[ 126.422][v][ipc_3] Client connected
[ 131.562][v][ipc_4] Client connected

Says that for the rest of the file.
Thank you for trying to help me out.

1 Like

Used the link that @dae posted to your legacy solution and it worked! Thank you guys for all the help!!

1 Like

Well that’s a bit of a surprise, but glad to hear it resolved things!