`audio-buffer` option won't set buffer for DirectShow audio devices
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
I'm trying to achieve the lowest latency playback on a set of input devices (audio+video) but found myself to be locked out by the DirectShow audio buffer of 500ms.
The demuxer (ffmpeg) allows you to set the DirectShow audio buffer with the -audio_buffer_size <value> (under mpv would be option demuxer-lavf-o=audio_buffer_size=<value>) and I believe --audio-buffer=<value> is the equivalent option for mpv. However, neither actually sets the buffer size.
- mpv version 0.35.0-327-ga45995f6
- Windows Version 11 - 21H2 (build 22000.1696)
- Source of the mpv binary shinchiro on SourceForge
- If known which version of mpv introduced the problem N/A
- Possible screenshot or video of visual glitches N/A
Reproduction steps
Run any command with a DirectShow audio device, and set the audio buffer. i.e.:
mpv.com av://dshow:video="this is a video device:audio=this is an audio device" --hwdec=no --profile=low-latency --no-cache-pause --video-sync=display-resample-vdrop --framedrop=decoder+vo --video-latency-hacks=yes --untimed --demuxer-lavf-o=audio_buffer_size=128
or
mpv.exe av://dshow:"audio=this is an audio device" --no-cache-pause --untimed --audio-buffer=0.1
For reference, DirectShow devices on your system can be shown by running the command ffmpeg -list_devices true -f dshow -i dummy.
Expected behavior
Playback has a latency of less than 500ms
Actual behavior
Playback has a latency of 500ms or more
Log file
Ran mpv.com --demuxer-lavf-o=audio_buffer_size=128 av://dshow:"audio=Microphone (Blue Snowball )" --log-file=%tmp%\log.txt
Additional notes
Since ffmpeg is the demuxer it might be worth to note how ffmpeg/ffplay handles this.
According to ffmpeg documentation, the default DirectShow audio delay is 500ms (which can be perceived if running ffplay -f dshow -i audio="this is an audio device"). The option -audio_buffer_size allows one to adjust the buffer size. Adding this parameter to ffplay with a buffer size lower than 500 allows for lower latency playback (e.g. ffplay -f dshow -i audio="this is an audio device" -audio_buffer_size 64).
mpv should set the demuxer audio buffer using either --audio-buffer=<value> or demuxer-lavf-o=audio_buffer_size=<value>. It doesn't return an error nor set the buffer to the expected value.
Possible relevant DirectShow sources:
Setting Audio Capture Properties
IAMBufferNegotiation interface (strmif.h)
mpv-player/mpv#9703
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the DirectShow command with --demuxer-lavf-o=audio_buffer_size=128 and compare it with ffplay's -audio_buffer_size behavior. Trace the DirectShow audio-device path and the demuxer option handling; done means the configured buffer is applied and playback latency falls below the default 500ms.
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