Winform VlcControl在Windows7播放摄像头流黑屏问题求助
Vlc.DotNet.Forms在Windows7 x64下仅能播放音频无法显示视频的问题
问题描述
使用Vlc.DotNet.Forms播放摄像头RTSP流,在Windows10上正常运行,但复制到Windows7 x64设备后,仅能听到音频,视频无法显示。但该流在VLC Player中可正常播放。
环境信息
- 操作系统:Windows7 x64
- Vlc.DotNet.Forms版本:3.1.0
- LibVLC版本:3.0.20
- .NET Framework版本:4.5.2
- 项目构建架构:x64
代码实现
VlcControl初始化代码
this.vlcControl = new VlcControl(); this.vlcControl.Dock = DockStyle.Fill; this.vlcControl.BackColor = System.Drawing.Color.Black; this.vlcControl.BeginInit(); var currentDirectory = Directory.GetCurrentDirectory(); this.vlcControl.VlcLibDirectory = new DirectoryInfo(currentDirectory + "\\libvlc\\win-x64\\"); this.vlcControl.VlcMediaplayerOptions = new[] { "-vv", #if DEBUG "-I", "dummy", "--ignore-config", "--extraintf=logger", "--verbose=2", "--file-logging", "--logfile=vlc-log.txt" #endif }; this.vlcControl.EndInit();
播放流代码
var playUrl = await QueryPlayUrl(cameraIndexCode); var options = new string[] { ":vout=direct3d11", }; this.vlcControl.Play(playUrl, options);
VLC日志输出
-- logger module started -- main debug: VLC media player - 3.0.20 Vetinari main debug: Copyright © 1996-2023 the VideoLAN team main debug: revision 3.0.20-0-g6f0d0ab126 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=x86_64-w64-mingw32' '--with-contrib=../contrib/x86_64-w64-mingw32' '--with-breakpad=https://win.crashes.videolan.org' '--enable-qt' '--enable-skins2' '--enable-dvdread' '--enable-caca' 'host_alias=x86_64-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/x86_64-w64-mingw32/lib/pkgconfig:/usr/lib/x86_64-w64-mingw32/pkgconfig' main debug: using multimedia timers as clock source main debug: min period: 1 ms, max period: 1000000 ms main debug: searching plug-in modules main debug: loading plugins cache file C:\Users\Administrator\Desktop\IM_Camera\Debug\libvlc\win-x64\plugins\plugins.dat main debug: recursively browsing `C:\Users\Administrator\Desktop\IM_Camera\Debug\libvlc\win-x64\plugins' main debug: plug-ins loaded: 497 modules main debug: looking for logger module matching "any": 2 candidates file debug: opening logfile `vlc-log.txt' main debug: using logger module "file" main debug: translation test: code is "C" main debug: looking for keystore module matching "memory": 3 candidates main debug: using keystore module "memory" main debug: CPU has capabilities MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 FPU main debug: creating audio output main debug: looking for audio output module matching "any": 6 candidates mmdevice debug: using default device mmdevice debug: display name changed: VLC media player (LibVLC 3.0.20) mmdevice debug: version 2 session control unavailable mmdevice debug: volume from -192.000000 dB to +0.000000 dB with 1.500000 dB increments main debug: using audio output module "mmdevice" main debug: keeping audio output main debug: looking for interface module matching "logger,none": 16 candidates logger error: The logger interface no longer exists. logger: As of VLC version 0.9.0, use --file-logging to write logs to a file. main debug: no interface modules matched main error: no suitable interface module main error: interface "logger,none" initialization failed main debug: creating audio output main debug: looking for audio output module matching "any": 6 candidates mmdevice debug: using default device mmdevice debug: version 2 session control unavailable mmdevice debug: volume from -192.000000 dB to +0.000000 dB with 1.500000 dB increments main debug: using audio output module "mmdevice" main debug: keeping audio output main debug: Creating an input for 'rtsp://xx.xx.xx.xx:554/openUrl/PWvKA5W' main debug: using timeshift granularity of 50 MiB main debug: using timeshift path: C:\Users\ADMINI~1\AppData\Local\Temp main debug: `rtsp://xx.xx.xx.xx:554/openUrl/PWvKA5W' gives access `rtsp' demux `any' path `xx.xx.xx.xx:554/openUrl/PWvKA5W' main debug: creating demux: access='rtsp' demux='any' location='xx.xx.xx.xx:554/openUrl/PWvKA5W' file='\xx.xx.xx.xx:554\openUrl\PWvKA5W' main debug: looking for access_demux module matching "rtsp": 15 candidates live555 debug: version 2016.11.28 live555 debug: RTP subsession 'video/H264' main debug: selecting program id=0 live555 debug: setup start: 0.000000 stop:0.000000 live555 debug: We have a timeout of 8 seconds live555 debug: play start: 0.000000 stop:0.000000 main debug: using access_demux module "live555" main debug: looking for packetizer module matching "any": 25 candidates main debug: using packetizer module "h264" main debug: looking for video decoder module matching "any": 20 candidates avcodec debug: using ffmpeg Lavc58.134.100 avcodec debug: CPU flags: 0x000fd3db avcodec debug: allowing 6 thread(s) for decoding avcodec debug: codec (h264) started avcodec debug: using frame thread mode with 6 threads main debug: using video decoder module "avcodec" main debug: looking for meta reader module matching "any": 2 candidates lua debug: Trying Lua scripts in C:\Users\Administrator\AppData\Roaming\vlc\lua\meta\reader lua debug: Trying Lua scripts in C:\Users\Administrator\Desktop\IM_Camera\Debug\libvlc\win-x64\lua\meta\reader main debug: no meta reader modules matched main debug: `rtsp://xx.xx.xx.xx:554/openUrl/PWvKA5W' successfully opened main debug: Buffering 0% main debug: Buffering 1% main debug: Buffering 4% main debug: Buffering 8% h264 warning: waiting for SPS/PPS h264 warning: waiting for SPS/PPS main debug: Buffering 12% h264 warning: waiting for SPS/PPS h264 debug: found NAL_SPS (sps_id=0) main debug: Buffering 82% h264 debug: found NAL_PPS (pps_id=0 sps_id=0) main debug: Stream buffering done (1109 ms in 760 ms) main error: buffer deadlock prevented main debug: Decoder wait done in 0 ms main debug: killing decoder fourcc `h264' main debug: removing module "avcodec" main debug: removing module "h264" main debug: removing module "live555" main debug: Program doesn't contain anymore ES main debug: removing module "mmdevice" main debug: exiting main debug: no exit handler main debug: removing all interfaces main debug: destroying main debug: deactivating the playlist main debug: removing module "mmdevice" main debug: deleting item `Playlist' main debug: removing module "memory" -- logger module stopped --
解决方案
1. 更换视频输出模块
你指定的:vout=direct3d11在Windows7环境兼容性较差,部分老显卡或系统配置无法正常驱动。尝试更换为以下兼容选项:
- 使用
direct3d9(平衡兼容性与性能):
var options = new string[] { ":vout=direct3d9", };
- 使用
gdi(兼容性最强,性能稍低):
var options = new string[] { ":vout=gdi", };
- 使用
d3d11va(硬件加速,需显卡支持Direct3D11):
var options = new string[] { ":vout=d3d11va", };
2. 修复接口初始化错误
日志显示main error: no suitable interface module,是因为你使用了废弃的--extraintf=logger参数,移除该参数即可:
this.vlcControl.VlcMediaplayerOptions = new[] { "-vv", #if DEBUG "-I", "dummy", "--ignore-config", "--verbose=2", "--file-logging", "--logfile=vlc-log.txt" #endif };
3. 检查LibVLC依赖与插件
- 确保Windows7设备已安装Visual C++ Redistributable for Visual Studio 2015-2019 x64,LibVLC 3.x版本依赖该运行库。
- 确认LibVLC的
plugins目录完整复制到目标设备,尤其是video_output子目录下的libdirect3d9_plugin.dll、libgdi_plugin.dll等视频输出插件未缺失。
4. 调整缓冲参数
日志中出现main error: buffer deadlock prevented,可增加网络缓冲时间避免死锁:
var options = new string[] { ":vout=direct3d9", ":network-caching=2000", ":rtsp-caching=2000" };
内容的提问来源于stack exchange,提问作者Marvin Wilson
相关产品推荐
相关产品推荐

