This only happens on the desktop version and only when I’m using my Focusrite Scarlett 4i4 audio interface as my default sound device.(not bluetooth) I don’t have this issue when I use my monitor as the default audio device. It’s random. It used to happen sometimes, and not happen at certain times. When it would happen, it would only happen to certain audio tracks. This time, the issue won’t go away and a restart won’t fix it. I see absolutely no pattern regarding the audio tracks that get cut out and those that do. Some are from forvo, some are from anime, some from other places. All mp3
I used to be on version 2.1.45, but I updated to:
Version 2.1.50 (26d40c3a)
Python 3.9.7 Qt 5.15.2 PyQt 5.15.5
to see if it would fix it, but it didn’t. If possible, I don’t want to update to something too recent and risk messing up my addons, etc.
I had this issue for a while now and I’m completly lost. Since it won’t go away, I mostly do anki on my phone, which is not as good imo. I also can’t check the audio quickly when I’m creating cards.
It’s probably caused by the underlying mpv issue on Windows.
opened 02:37PM - 28 Nov 21 UTC
os:win
ao:wasapi
### Important Information
Provide following Information:
- Pulled from maste… r Github branch
- Windows 10 (21H1)
- Built using MSYS2 accord to Windows Compilation Instructions
### Reproduction steps
Download the sample mp3 file. Try building mpv and running the mp3 file:
```
/usr/bin/python3 waf install && winpty mpv.com /D/file.mp3 -v --no-config
```
### Expected behavior
It should play the full audio file (Full audio file plays with VLC for example)
### Actual behavior
It cuts off shortly before the end of the file
### Log file
```
$ /usr/bin/python3 waf install && winpty mpv.com /D/file.mp3 -v --no-config
Waf: Entering directory `/C/Users/Gareth/CLionProjects/mpv/build'
[1/1] Compiling version.sh
- install /mingw64/bin/mpv.exe (from build/mpv.exe)
- install /mingw64/share/doc/mpv/input.conf (from etc/input.conf)
- install /mingw64/share/doc/mpv/mpv.conf (from etc/mpv.conf)
- install /mingw64/share/doc/mpv/mplayer-input.conf (from etc/mplayer-input.conf)
- install /mingw64/share/doc/mpv/restore-old-bindings.conf (from etc/restore-old-bindings.conf)
- install /mingw64/bin/mpv.com (from build/mpv.com)
- install /mingw64/share/zsh/site-functions/_mpv (from etc/_mpv.zsh)
- install /mingw64/share/bash-completion/completions/mpv (from etc/mpv.bash-completion)
- install /mingw64/share/applications/mpv.desktop (from etc/mpv.desktop)
- install /mingw64/etc/mpv/encoding-profiles.conf (from etc/encoding-profiles.conf)
- install /mingw64/share/icons/hicolor/16x16/apps/mpv.png (from etc/mpv-icon-8bit-16x16.png)
- install /mingw64/share/icons/hicolor/32x32/apps/mpv.png (from etc/mpv-icon-8bit-32x32.png)
- install /mingw64/share/icons/hicolor/64x64/apps/mpv.png (from etc/mpv-icon-8bit-64x64.png)
- install /mingw64/share/icons/hicolor/128x128/apps/mpv.png (from etc/mpv-icon-8bit-128x128.png)
- install /mingw64/share/icons/hicolor/scalable/apps/mpv.svg (from etc/mpv-gradient.svg)
- install /mingw64/share/icons/hicolor/symbolic/apps/mpv-symbolic.svg (from etc/mpv-symbolic.svg)
Waf: Leaving directory `/C/Users/Gareth/CLionProjects/mpv/build'
'install' finished successfully (0.805s)
[cplayer] Command line options: 'D:/file.mp3' '-v' '--no-config'
[cplayer] mpv 0.34.0-91-g4991ffa859-dirty Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
[cplayer] built on Sun Nov 28 13:23:45 GMT 2021
[cplayer] FFmpeg library versions:
[cplayer] libavutil 56.70.100
[cplayer] libavcodec 58.134.100
[cplayer] libavformat 58.76.100
[cplayer] libswscale 5.9.100
[cplayer] libavfilter 7.110.100
[cplayer] libswresample 3.9.100
[cplayer] FFmpeg version: 4.4.1
[cplayer]
[cplayer] Configuration: waf configure CC=gcc.exe --check-c-compiler=gcc --prefix=/mingw64
[cplayer] List of enabled features: asm build-date caca cplayer d3d-hwaccel d3d9-hwaccel debug-build direct3d dos-paths ffmpeg ffmpeg-aviocontext-bytes-read gl gl-dxinterop gl-dxinterop-d3d9
gl-win32 glob glob-win32 gpl iconv jpeg lcms2 libarchive libass libavdevice libbluray libm lua lua5_1 mingw noexecstack optimize posix-or-mingw stdatomic vector wasapi win32-desktop win32-i
nternal-pthreads zlib
[cplayer] Setting option 'v' = '' (flags = 8)
[cplayer] Setting option 'config' = 'no' (flags = 8)
[cplayer] Waiting for scripts...
[osd/libass] libass API version: 0x1502000
[osd/libass] libass source: tarball: 0.15.2
[osd/libass] Shaper: FriBidi 1.0.11 (SIMPLE) HarfBuzz-ng 3.1.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider directwrite (with GDI)
[osd/libass] Done.
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Done loading scripts.
[cplayer] Running hook: ytdl_hook/on_load
[ytdl_hook] ytdl:// hook
[cplayer] Set property: shared-script-properties -> 1
[ytdl_hook] not a ytdl:// url
[cplayer] Set property: shared-script-properties -> 1
[bdmv/bluray] Opening D:/file.mp3
[osd/libass] libass API version: 0x1502000
[osd/libass] libass source: tarball: 0.15.2
[file] Opening D:/file.mp3
[demux] Trying demuxers for level=normal.
[osd/libass] Shaper: FriBidi 1.0.11 (SIMPLE) HarfBuzz-ng 3.1.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider directwrite (with GDI)
[osd/libass] Done.
[lavf] Found 'mp3' at score=25 size=2048.
[lavf] Found 'mp3' at score=51 size=4096.
[lavf] avformat_find_stream_info() finished after 12884 bytes.
[demux] Detected file format: mp3 (libavformat)
[cplayer] Opening done: D:/file.mp3
[find_files] Loading external files in D:/
[cplayer] Running hook: ytdl_hook/on_preloaded
[lavf] select track 0
[cplayer] (+) Audio --aid=1 (mp3 1ch 44100Hz)
[ad] Codec list:
[ad] mp3float (mp3) - MP3 (MPEG audio layer 3)
[ad] mp3 - MP3 (MPEG audio layer 3)
[ad] Opening decoder mp3float
[ad] Requesting 1 threads for decoding.
[ad] Selected codec: mp3float (MP3 (MPEG audio layer 3))
[af] User filter list:
[af] (empty)
[cplayer] Starting playback...
[lavf] EOF reached.
[af] [in] 44100Hz mono 1ch floatp
[af] [userspeed] 44100Hz mono 1ch floatp
[af] [userspeed] (disabled)
[af] [convert] 44100Hz mono 1ch floatp
[ao] Trying audio driver 'wasapi'
[ao/wasapi] requested format: 44100 Hz, mono channels, floatp
[ao/wasapi] No device specified. Selecting default.
[ao/wasapi] Selecting device '{315b772a-d1d7-40b4-a5ac-416cc5a49cb7}' (Headphones (Arctis Pro Wireless Game))
[ao/wasapi] Monitoring changes in device {0.0.0.00000000}.{315b772a-d1d7-40b4-a5ac-416cc5a49cb7}
[ao/wasapi] Trying mono float (32/32 bits) @ 48000hz (shared) -> close
[ao/wasapi] Closest match is stereo float (32/32 bits) @ 48000hz
[ao/wasapi] Accepted as stereo float @ 48000hz -> stereo float (32/32 bits) @ 48000hz (shared)
[ao/wasapi] Device period: 10 ms
[ao/wasapi] Buffer frame count: 2400 (50 ms)
[ao/wasapi] IAudioClock::GetFrequency gave a frequency of 384000.
[ao/wasapi] device buffer: 2400 samples.
[ao/wasapi] using soft-buffer of 9600 samples.
[cplayer] AO: [wasapi] 48000Hz stereo 2ch float
[cplayer] AO: Description: Windows WASAPI audio output (event mode)
[autoconvert] inserting resampler
[swresample] format change, reinitializing resampler
[swresample] 44100Hz mono floatp -> 48000Hz stereo float
[swresample] Remix: mono -> stereo
[af] [out] 48000Hz stereo 2ch float
[cplayer] audio ready
[cplayer] starting audio playback
[cplayer] playback restart complete @ -0.000000, audio=playing, video=eof
[cplayer] Set property: shared-script-properties -> 1
[statusline] A: 00:00:00 / 00:00:00 (64%)
[af] filter input EOF
[af] filter output EOF
[cplayer] audio filter EOF
[cplayer] audio draining
[cplayer] audio EOF reached
[cplayer] EOF code: 1
[cplayer] finished playback, success (reason 0)
[cplayer]
[cplayer] Exiting... (End of file)
[cplayer] Set property: shared-script-properties -> 1
[cplayer] draining left over audio
```
### Sample files
[Sample File](https://0x0.st/-7dN.mp3)
### Attempted Debugging
I attempted some crude debugging of the source code (I'm unsure how to attach a debugger to this under windows) and managed to track it down to [`filter_resamepl_output`](https://github.com/mpv-player/mpv/blob/master/filters/f_swresample.c#L402). I doubt the issue lies there, but I found that if I commented out either [line 662](https://github.com/mpv-player/mpv/blob/master/filters/f_swresample.c#L622) or [line 629](https://github.com/mpv-player/mpv/blob/master/filters/f_swresample.c#L629) then the audio played the whole way through but caused their own problems (Namely mpv not detecting the end of the audio file at all and just never closing).
I suspect that somewhere mpv is reading what looks like an EOF marker in the audio file that's not actually a real EOF marker
The latest Anki version includes a workaround that adds 150 ms of silence to the end.
To apply it for Anki 2.1.50, try running this code in the debug console (or manually create mpv.conf
with af-add=lavfi=[apad=pad_dur=0.150]
in the %APPDATA%\Anki2
folder and restart Anki).
https://docs.ankiweb.net/misc.html#debug-console
import os
from aqt import mw
from aqt.sound import mpvManager
with open(os.path.join(mw.pm.base, 'mpv.conf'), 'a') as f:
f.write('af-add=lavfi=[apad=pad_dur=0.150]\n')
print('[af] before:', mpvManager.get_property('af'))
mpvManager.shutdown() # restart mpv to apply new settings
print('[af] after:', mpvManager.get_property('af'))
3 Likes
I didn’t even know the debug menu was a thing! I entered the code as you instructed and it no longer cuts off. Thank you so much!! I’ve been googling about this issue for months now. It’s a big relief
system
Closed
August 14, 2023, 3:28pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.