mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.89k stars 2.87k forks source link

Very short audio files don't play #14867

Open andrewbaxter opened 2 days ago

andrewbaxter commented 2 days ago

mpv Information

mpv v0.38.0-dirty Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
 built on Sep  4 2024 19:59:01
libplacebo version: v7.349.0
FFmpeg version: n7.0.2
FFmpeg library versions:
   libavutil       59.8.100
   libavcodec      61.3.100
   libavformat     61.1.100
   libswscale      8.1.100
   libavfilter     10.1.100
   libswresample   5.1.100

Other Information

- Linux version: Arch
- Kernel Version: Linux deepmass 6.10.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 x86_64 GNU/Linux
- GPU Model: NVIDIA Corporation GP107 [GeForce GTX 1050] (rev a1)
- Mesa/GPU Driver Version: 4.6.0 NVIDIA 560.35.03
- Window Manager and Version: openbox 3.6.1-11
- Source mpv:
- Introduced in version:

Reproduction Steps

mpv clip_pixabay_21156.ogg

Expected Behavior

To hear the sound

Actual Behavior

I hear nothing

Log File

If there's something specific in the log I can provided it. Here's the end

[   0.070][i][cplayer] AO: [pipewire] 44100Hz mono 1ch floatp
[   0.070][v][cplayer] AO: Description: PipeWire audio output
[   0.070][v][af] [convert] (disabled)
[   0.070][v][af] [out] 44100Hz mono 1ch floatp
[   0.070][v][af] filter input EOF
[   0.070][v][af] filter output EOF
[   0.070][v][cplayer] audio filter EOF
[   0.070][d][osc] osc_init
[   0.070][v][cplayer] audio ready (and EOF)
[   0.070][v][cplayer] starting audio playback
[   0.070][d][ao/pipewire] Stream state changed: old_state=connecting state=paused error=(null)
[   0.070][v][cplayer] audio draining
[   0.070][v][cplayer] playback restart complete @ 0.002902, audio=draining, video=eof
[   0.070][v][cplayer] audio EOF reached
[   0.070][v][cplayer] EOF code: 1  
[   0.070][d][ad] Uninit decoder.
[   0.070][d][cplayer] Terminating demuxers...
[   0.071][d][cplayer] Done terminating demuxers.
[   0.071][v][cplayer] finished playback, success (reason 0)
[   0.071][i][cplayer] Exiting... (End of file)
[   0.071][d][ytdl_hook] Exiting...
[   0.071][d][stats] Exiting...
[   0.071][d][console] Exiting...
[   0.071][d][auto_profiles] Exiting...
[   0.071][v][cplayer] Set property: user-data/osc/margins={"b":0,"l":0,"t":0,"r":0} -> 1
[   0.071][d][cplayer] Run command: del, flags=64, args=[name="user-data/osc"]
[   0.072][d][osc] Exiting...
[   0.072][d][ao/pipewire] Stream state changed: old_state=paused state=streaming error=(null)
[   0.075][v][cplayer] draining left over audio
[   0.323][d][ao/pipewire] Stream state changed: old_state=streaming state=paused error=(null)

Sample Files

sample.zip

I carefully read all instruction and confirm that I did the following:

andrewbaxter commented 2 days ago

I think this is the same as https://github.com/mpv-player/mpv/issues/9535 maybe? I.e. I don't think the issue with audio not playing is platform/driver specific. AFAIK this has always happened.

I'm not sure but my guess would be the audio sink hasn't finished initializing before playback starts and some audio data goes into the void. I'm not sure initialization is even reported, or if it's possible to solve this other than by just sleeping a bit before playing for short audio files (where the important audio information is at the very start).

Doing -loop=inf makes the sound audible, although in looped fashion.

Dudemanguy commented 2 days ago

The samples play fine for me on pipewire and alsa on git master.

llyyr commented 2 days ago

I'm pretty certain this is a pipewire issue

set the following options in your pipewire.conf

    default.clock.allowed-rates = [ 44100 48000 ]
    default.clock.quantum       = 128

I can't hear it with a ridiculously high default quantum (>1000) but I can at lower quantums.

llyyr commented 2 days ago

You should be able to reproduce with just pw-play as well.

Try pw-play then try it with PIPEWIRE_QUANTUM=128/44100 pw-play click_pixabay_21156.ogg

andrewbaxter commented 2 days ago

Thanks for the replies!

So, I just tried pw-play with no env overrides and it produced sound. I reran mpv and it didn't play anything. I reran mpv again and it played, as it did in subsequent invocations.

I did sysctl vm.drop_caches=3 then mpv and it failed to play again, then subsequent invocations played fine.

llyyr commented 2 days ago

I did sysctl vm.drop_caches=3 then mpv and it failed to play again, then subsequent invocations played fine.

Can you do this and also restart pipewire systemctl --use restart pipewire then play the file with pw-play?

andrewbaxter commented 2 days ago

I 1. dropped caches, 2. systemctl --user restart pipewire, 3. ran pw-play and it produced audio on the first invocation. To confirm, I ran mpv again and on the first invocation it didn't produce audio.

I will note that my testing environment isn't super clean... browsers open, various editors, etc. I made sure nothing was playing audio first before dropping caches and restarting pipewire.

llyyr commented 2 days ago

And what if you reduce the default quantum size in your pipewire config? Does mpv play it then? Also make sure you aren't setting any pipewire options in mpv config

andrewbaxter commented 2 days ago

Ah sorry, I should have tried that earlier. I just tried it now and the pipewire config file didn't work (read: I didn't have an existing config and I'm not exactly sure where to put it) but PIPEWIRE_QUANTUM=128/44100 mpv click_pixabay_21156.ogg did work on the first invocation after dropping caches. So it seems like PIPEWIRE_QUANTUM=128/44100 does help.