I am using libvlcsharp to open RTSP stream in a MediaPlayer control. The issue is, when the MediaPlayer
“opens” the RTSP stream, it waits for about 1 minute (!) to actually display the stream. I checked the time used for Buffering (via MediaPlayer.Buffering
event) and it only takes one second to buffer (I use wired network connection).
How can speed up the video start-up or catch when it starts to actually play?
I have looked at discussion at https://code.videolan.org/videolan/LibVLCSharp/-/issues/203 which suggests using Buffering event and MediaPlayer.TimeChanged
event but Buffering doesn’t solve the issue (it accounts for 1 second out of 60) and TimeChanged event feels like a hack rather than solution.
I looked at my log files and it feels as if VLC library is spending time trying to figure out which codec to use to decode the stream – it finally settles for ‘trying format d3d11va_vld’. I was wondering if I could somehow specify the codec in advance as this does not change for the stream. The log file doesn’t have timestamps so I am guessing this is where the time is spent – I could be wrong.
I looked at VLC library options but I could not find an option to specify stream decoder; if I transcode the stream then I can specify output decoder in that case but not for input.
Log file says:
VLC media player - 3.0.20 Vetinari
Copyright © 1996-2023 the VideoLAN team
revision 3.0.20-0-g6f0d0ab126
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= -D_WIN32_WINNT=0x0502 -DWINVER=0x502 -D__MSVCRT_VERSION__=0x700 ' 'CXXFLAGS= -D_WIN32_WINNT=0x0502 -DWINVER=0x502 -D__MSVCRT_VERSION__=0x700 ' 'PKG_CONFIG=pkg-config' 'PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/lib/pkgconfig:/usr/lib/i686-w64-mingw32/pkgconfig'
creating audio output
looking for audio output module matching "any": 6 candidates
using default device
display name changed: VLC media player (LibVLC 3.0.20)
version 2 session control unavailable
volume from -65.250000 dB to +0.000000 dB with 0.750000 dB increments
using audio output module "mmdevice"
keeping audio output
Creating an input for 'rtsp://10.0.40.99:554/Streaming/Channels/101'
using timeshift granularity of 50 MiB
using timeshift path: C:UsersMeAppDataLocalTemp
`rtsp://admin:[email protected]:554/Streaming/Channels/101' gives access `rtsp' demux `any' path `admin:[email protected]:554/Streaming/Channels/101'
creating demux: access='rtsp' demux='any' location='admin:[email protected]:554/Streaming/Channels/101' file='\admin:[email protected]:554StreamingChannels101'
looking for access_demux module matching "rtsp": 15 candidates
version 2016.11.28
Password in a URI is DEPRECATED
RTP subsession 'video/H264'
selecting program id=0
RTP subsession 'audio/PCMU'
setup start: 0.000000 stop:0.000000
We have a timeout of 60 seconds
play start: 0.000000 stop:0.000000
using access_demux module "live555"
looking for packetizer module matching "any": 25 candidates
found NAL_SPS (sps_id=0)
found NAL_PPS (pps_id=0 sps_id=0)
using packetizer module "h264"
looking for video decoder module matching "any": 20 candidates
using ffmpeg Lavc58.134.100
CPU flags: 0x000fd3db
allowing 6 thread(s) for decoding
codec (h264) started
using frame thread mode with 6 threads
using video decoder module "avcodec"
audio is disabled, not selecting ES 0x1
looking for meta reader module matching "any": 2 candidates
Trying Lua scripts in C:UsersMeAppDataRoamingvlcluametareader
Trying Lua scripts in C:UsersMesourcereposVLC-DemobinDebuglibvlcwin-x86luametareader
Trying Lua playlist script C:UsersMesourcereposVLC-DemobinDebuglibvlcwin-x86luametareaderfilename.luac
no meta reader modules matched
`rtsp://admin:[email protected]:554/Streaming/Channels/101' successfully opened
lost 29895 bytes
increasing buffer size to 500000
Buffering 0%
Buffering 1%
Buffering 3%
Buffering 7%
Buffering 35%
Buffering 40%
Buffering 45%
Buffering 50%
Buffering 55%
Buffering 60%
Buffering 65%
Buffering 70%
Buffering 75%
Buffering 80%
Buffering 85%
Buffering 90%
Buffering 95%
Buffering 100%
Stream buffering done (1050 ms in 832 ms)
buffer deadlock prevented
Decoder wait done in 0 ms
lost 78214 bytes
increasing buffer size to 1000000
lost 283943 bytes
increasing buffer size to 2000000
restarting module due to input format change
removing module "avcodec"
looking for video decoder module matching "any": 20 candidates
using ffmpeg Lavc58.134.100
CPU flags: 0x000fd3db
allowing 6 thread(s) for decoding
codec (h264) started
using frame thread mode with 6 threads
using video decoder module "avcodec"
available hardware decoder output format 53 (dxva2_vld)
available hardware decoder output format 118 (d3d11va_vld)
available hardware decoder output format 174 (d3d11)
available software decoder output format 12 (yuvj420p)
trying format d3d11va_vld
looking for text renderer module matching "any": 3 candidates
Using DWrite backend
DWrite_GetFamily(): family name: Arial
DWrite_ParseFamily(): using font at index 0 with weight 400 for bold: 0, italic: 0
DWrite_ParseFamily(): using font at index 1 with weight 700 for bold: 1, italic: 0
DWrite_ParseFamily(): using font at index 2 with weight 400 for bold: 0, italic: 1
DWrite_ParseFamily(): using font at index 3 with weight 700 for bold: 1, italic: 1
using text renderer module "freetype"
looking for video converter module matching "any": 24 candidates
32x32 (32x32) chroma: YUVA -> 16x16 (16x16) chroma: RGBA with scaling using Bicubic (good quality)
using video converter module "swscale"
looking for video converter module matching "any": 24 candidates
YUVP to YUVA converter
using video converter module "yuvp"
Deinterlacing available
deinterlace -1, mode auto, is_needed 0
looking for vout window module matching "embed-hwnd,any": 3 candidates
using vout window module "drawable"
looking for inhibit module matching "any": 1 candidates
using inhibit module "inhibit"
Opening vout display wrapper
looking for vout display module matching "any": 12 candidates
creating Vout EventThread
Win32VoutCreateWindow
VoutDisplayEvent 'resize' 2688x1520
inclinometer not found. (hr=0x80070490)
created video sub-window
Vout EventThread running
Created the D3D11 device type 1 level b100.
NVIDIA WDDM driver 32.0.15.5599
supports colorspace RGB Rec.709 gamma:22 range:FULL
supports colorspace RGB Rec.709 gamma:22 range:STUDIO
supports colorspace RGB Rec.2020 gamma:22 range:STUDIO
supports colorspace RGB Rec.2020 gamma:22 range:FULL
supports colorspace RGB Rec.2020 gamma:2084 range:FULL
supports colorspace RGB Rec.2020 gamma:2084 range:STUDIO
Output max luminance: 270.0, colorspace RGB Rec.709 gamma:22 range:FULL, bits per pixel 8
using colorspace RGB Rec.709 gamma:22 range:FULL
Using pixel format VA_NV12 for chroma DX11
VoutDisplayEvent 'resize' 2704x1559
using GPU render fence
Direct3D11 resources created
Direct3D11 device adapter successfully initialized
Direct3D11 Open Succeeded
using vout display module "direct3d11"
D3D11 pool succeed with 40 surfaces (2688x1520) context 0x0841d410
original format sz 2688x1520, of (0,0), vsz 2688x1520, 4cc DX11, sar 1:1, msk r0x0 g0x0 b0x0
removing module "freetype"
VoutDisplayEvent 'resize' 623x309
looking for text renderer module matching "any": 3 candidates
Using DWrite backend
DWrite_GetFamily(): family name: Arial
DWrite_ParseFamily(): using font at index 0 with weight 400 for bold: 0, italic: 0
DWrite_ParseFamily(): using font at index 1 with weight 700 for bold: 1, italic: 0
DWrite_ParseFamily(): using font at index 2 with weight 400 for bold: 0, italic: 1
DWrite_ParseFamily(): using font at index 3 with weight 700 for bold: 1, italic: 1
using text renderer module "freetype"
looking for hw decoder module matching "any": 2 candidates