When playing short audio (a few seconds), the playback is incomplete.
Summary
When I play short audio (a few seconds) using LibVLCSharp in a C# WPF project, the playback is incomplete. It will automatically stop before the full playback ends. But if you set the cache parameter to 0, it will work fine.
Minimal project and steps to reproduce
Run this test project: LibvlcsharpTest
What is the current bug behavior?
Audio playback stops early.
What is the expected correct behavior?
Effectively enables full playback of media files, including local files and network streams, with caching enabled.
Does it work on other plaforms? Does it work with the official VLC apps?
It works fine in the official VLC media player (3.0.19).
Relevant LibVLC logs and/or screenshots
main Debug: VLC media player - 3.0.18 Vetinari
main Debug: Copyright ? 1996-2022 the VideoLAN team
main Debug: revision 3.0.18-0-ge9eceaed4d
main Debug: configured with /builds/videolan/vlc/extras/package/win32/../../../configure '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-dca' '--enable-mpc' '--enable-libass' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-shout' '--enable-goom' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-nls' '--host=i686-w64-mingw32' '--with-contrib=../contrib/i686-w64-mingw32' '--with-breakpad=https://win.crashes.videolan.org' '--enable-qt' '--enable-skins2' '--enable-dvdread' '--enable-caca' 'host_alias=i686-w64-mingw32' 'CFLAGS= ' 'CXXFLAGS= ' 'PKG_CONFIG=pkg-config' 'PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/lib/pkgconfig:/usr/lib/i686-w64-mingw32/pkgconfig'
main Debug: creating audio output
main Debug: looking for audio output module matching "any": 6 candidates
mmdevice Error: cannot initialize COM (error 0x80010106)
directsound Debug: found 4 devices
main Debug: using audio output module "directsound"
main Debug: keeping audio output
main Debug: Creating an input for 'demo.mp3'
main Debug: using timeshift granularity of 50 MiB
main Debug: using timeshift path: C:\Users\bigq5\AppData\Local\Temp
main Debug: creating demux: access='file' demux='any' location='/F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3' file='F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\demo.mp3'
main Debug: `file:///F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3' gives access `file' demux `any' path `/F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3'
main Debug: looking for access_demux module matching "file": 15 candidates
main Debug: no access_demux modules matched
main Debug: creating access: file:///F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3
main Debug: (path: F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\demo.mp3)
main Debug: looking for access module matching "file": 27 candidates
main Debug: using access module "filesystem"
main Debug: looking for stream_filter module matching "prefetch,cache_read": 24 candidates
cache_read Debug: Using stream method for AStream*
cache_read Debug: starting pre-buffering
cache_read Debug: received first data after 0 ms
cache_read Debug: pre-buffering done 1024 bytes in 0s - 1000000 KiB/s
main Debug: using stream_filter module "cache_read"
main Debug: looking for stream_filter module matching "any": 24 candidates
lua Debug: Trying Lua scripts in C:\Users\bigq5\AppData\Roaming\vlc\lua\playlist
lua Debug: Trying Lua scripts in F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\anevia_streams.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\anevia_xml.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\appletrailers.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\bbc_co_uk.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\cue.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\dailymotion.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\jamendo.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\koreus.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\liveleak.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\newgrounds.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\rockbox_fm_presets.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\soundcloud.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\twitch.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\vimeo.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\vocaroo.luac
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\playlist\youtube.luac
main Debug: no stream_filter modules matched
main Debug: looking for stream_directory module matching "any": 1 candidates
main Debug: no stream_directory modules matched
main Debug: attachment of directory-extractor failed for file:///F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3
main Debug: looking for stream_filter module matching "record": 24 candidates
main Debug: using stream_filter module "record"
main Debug: creating demux: access='file' demux='any' location='/F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3' file='F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\demo.mp3'
main Debug: looking for demux module matching "any": 55 candidates
es Debug: detected format mpga
main Debug: looking for packetizer module matching "any": 25 candidates
main Debug: using packetizer module "mpegaudio"
mpegaudio Debug: MPGA channels:1 samplerate:24000 bitrate:160
main Debug: selecting program id=0
main Debug: using demux module "es"
main Debug: looking for a subtitle file in F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\
main Debug: looking for audio decoder module matching "any": 23 candidates
main Debug: using audio decoder module "mpg123"
mpg123 Debug: mpga->f32l, bits per sample: 32
main Debug: looking for meta reader module matching "any": 2 candidates
lua Debug: Trying Lua scripts in C:\Users\bigq5\AppData\Roaming\vlc\lua\meta\reader
lua Debug: Trying Lua scripts in F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\meta\reader
lua Debug: Trying Lua playlist script F:\VSTest\LibvlcsharpTest\VlcTest\bin\Debug\libvlc\win-x86\lua\meta\reader\filename.luac
main Debug: no meta reader modules matched
main Debug: `file:///F:/VSTest/LibvlcsharpTest/VlcTest/bin/Debug/demo.mp3' successfully opened
main Debug: Buffering 0%
main Debug: Buffering 2%
main Debug: Buffering 4%
main Debug: Buffering 7%
main Debug: Buffering 14%
main Debug: Buffering 16%
main Debug: Buffering 12%
main Debug: Buffering 9%
main Debug: Buffering 19%
main Debug: Buffering 21%
main Debug: reusing audio output
main Debug: Buffering 24%
directsound Debug: Opening DirectSound Audio Output
main Debug: Buffering 26%
main Debug: Buffering 28%
main Debug: Buffering 31%
main Debug: Buffering 33%
main Debug: Buffering 36%
main Debug: Buffering 38%
main Debug: Buffering 40%
main Debug: Buffering 43%
main Debug: Buffering 45%
main Debug: Buffering 48%
main Debug: Buffering 50%
main Debug: Buffering 52%
main Debug: Buffering 55%
main Debug: Buffering 57%
main Debug: Buffering 60%
main Debug: Buffering 62%
main Debug: Buffering 64%
main Debug: Buffering 67%
main Debug: Buffering 69%
main Debug: Buffering 72%
main Debug: Buffering 74%
main Debug: Buffering 76%
main Debug: Buffering 79%
main Debug: Buffering 81%
main Debug: Buffering 84%
main Debug: Buffering 86%
main Debug: Buffering 88%
main Debug: Buffering 91%
main Debug: Buffering 96%
main Debug: Buffering 93%
main Debug: Buffering 98%
main Debug: Stream buffering done (1008 ms in 10 ms)
directsound Debug: Windows speaker config: Quad and stream has 1 channels, using 1 channels
main Debug: output 'f32l' 24000 Hz Stereo frame=1 samples/8 bytes
main Debug: looking for audio volume module matching "any": 2 candidates
main Debug: using audio volume module "float_mixer"
main Debug: input 'f32l' 24000 Hz Mono frame=1 samples/4 bytes
scaletempo Debug: format: 24000 rate, 1 nch, 4 bps, fl32
main Debug: looking for audio filter module matching "scaletempo": 16 candidates
scaletempo Debug: params: 30 stride, 0.200 overlap, 14 search
scaletempo Debug: 1.000 scale, 720.000 stride_in, 720 stride_out, 576 standing, 144 overlap, 336 search, 1200 queue, fl32 mode
main Debug: using audio filter module "scaletempo"
main Debug: conversion: 'f32l'->'f32l' 24000 Hz->24000 Hz Mono->Mono
main Debug: conversion pipeline complete
main Debug: conversion: 'f32l'->'f32l' 24000 Hz->24000 Hz Mono->Stereo
main Debug: looking for audio converter module matching "any": 8 candidates
main Debug: using audio converter module "trivial"
main Debug: conversion pipeline complete
main Debug: looking for audio resampler module matching "any": 3 candidates
main Debug: using audio resampler module "samplerate"
main Debug: Decoder wait done in 49 ms
main Warning: playback too late (89791): up-sampling
main Debug: EOF reached
_mediaPlayer_EndReached
main Debug: removing module "mpg123"
线程 0x3984 已退出,返回值为 0 (0x0)。
main Debug: killing decoder fourcc `mpga'
main Debug: removing module "samplerate"
main Debug: removing module "scaletempo"
main Debug: removing module "trivial"
directsound Debug: closing audio device
main Debug: removing module "float_mixer"
main Debug: keeping audio output
main Debug: removing module "es"
main Debug: removing module "record"
main Debug: removing module "mpegaudio"
main Debug: removing module "cache_read"
main Debug: removing module "filesystem"
main Debug: Program doesn't contain anymore ES
_mediaPlayer_Stopped
线程 0x2e64 已退出,返回值为 0 (0x0)。
Environment
- OS: Windows 10
- LibVLC version and architecture 3.0.18,x86
- LibVLCSharp version 3.8.1
Possible fixes
For local files:
new LibVLC("--file-caching=0")
For network streams:
new LibVLC("--network-caching=0")
Other
I'm not sure if this issue is a LibVLCSharp bug, or a LibVLC/VLC specific issue...