mpv-player / mpv-player/mpv

[Windows][Audio] ao-wasapi driver sometimes cutting audio files off before the end of the file

Open
#9,535 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ao:wasapi os:win
Dominant language
C
Stars
37k
Forks
3.5k
Avg merge
1d 10h
Merged PRs (30d)
22

Description

Important Information

Provide following Information:

  • Pulled from master 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

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. I doubt the issue lies there, but I found that if I commented out either line 662 or line 629 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the linked sample MP3 and the Windows WASAPI command, then inspect filters/f_swresample.c around the referenced filter_resample_output lines 629 and 662 alongside the ao/wasapi playback path. Done means the sample plays through its end and mpv exits normally without the EOF or draining behavior described.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.