-1

I am using LibVLCSharp to play an RTSP stream in my Winforms application. The library is great and everything is working fine. However, my ram usage of the application jumped from around 20-30MB to around 140MB! In addition, I have to include about 140MB worth of DLL files with my application, despite the executable being 2MB! The library right now is bascailly the whold VLC media player application bundled with my app.

I only use very limited capabilites of the library (only streaming from an RTSP URL and displaying it in a form, without even and playback capabilities), so I figured there must be a way to include the required DLLs for my app with the program.

Testing my theroy, I tried to randomly remove some DLLs from the libVLC directory. By some guessing and trial and error, I was actually able to remove ~20MB from the library and the stream worked just fine. For example, by removing the DLLs under audio directory, the stream worked well but had no audio (which I don't need in my case). Unfortunately, there is still about ~120MB of DLLs.

I tried searching how to only include the DLLs required by the used features, or how to determine such DLLs such that the rest can be deleted, but I couldn't find any solution.

A similar unanswered question here on stackoverflow: Libvlc - minimal files (functions) set for streaming out

1 Answers1

0

There is no such guidelines because it really depends on what you are trying to do with your app. For example, libavcodec is needed in 99% of the builds, but whether you need the D3D9 plugin depends on the machines on which you will install the app.

Once you have determined what to exclude, you may use exclusion lists in your csproj, like this :

<ItemGroup>
  <!-- You can exclude plugin-by-plugin: -->
  <VlcWindowsX64ExcludeFiles Include="plugins\gui\libqt_plugin.dll" />

  <!-- You can exclude a whole folder. Notice how the wildcard is mandatory when doing exclude on folders -->
  <VlcWindowsX64ExcludeFiles Include="plugins\lua\%2A" />

  <!-- You can exclude with wildcards -->
  <VlcWindowsX64ExcludeFiles Include="plugins\%2A\%2Adummy%2A" />

  <!-- You can exclude the same files for Windows x86 -->
  <VlcWindowsX86ExcludeFiles Include="@(VlcWindowsX64ExcludeFiles)" />
</ItemGroup>

If you want to only include the plugins you selected, you can do it that way instead :

<ItemGroup>
  <!-- Includes the codec folder. Notice how the wildcard is mandatory when doing include on folders -->
  <VlcWindowsX64IncludeFiles Include="plugins\codec\%2A" />

  <!-- You can include plugin-by-plugin -->
  <VlcWindowsX64IncludeFiles Include="plugins\audio_output\libdirectsound_plugin.dll" />

  <!-- You can include with wildcards all in d3d9/d3d11 -->
  <VlcWindowsX64IncludeFiles Include="plugins\d3d%2A\%2A" />

  <!-- You can still exclude things from what you have included -->
  <VlcWindowsX64IncludeFiles Include="plugins\codec\libddummy_plugin.dll" />

  <!-- You can include the same files for Windows x86 -->
  <VlcWindowsX86IncludeFiles Include="@(VlcWindowsX64IncludeFiles)" />
</ItemGroup>

Please see the full documentation here : https://code.videolan.org/videolan/libvlc-nuget/-/blob/master/cherry-picking.md

cube45
  • 3,429
  • 2
  • 24
  • 35
  • Thanks for the tip on excluding the files. What I need though is how to know what I need for an app (in this specific case an app that plays an RTSP stream), I can't find any sources for this. For example, in a win32 API documentation page for a function, the required DLL and header files are stated at the bottom of the page. This makes it easier for me to know exactly what my app depends on. I hope to find a source for something similar with LibVLC, as I intend to use the library for many projects. – Mohamed Atef Dec 28 '22 at 20:26
  • RTSP is a protocol that can transmit video and audio, encoded with many codecs. What is complex is that you can't say, for example "I will only play .mkv files" and have only one "mkv plugin" that plays it all, because you can put any codec in that container format. – cube45 Dec 29 '22 at 07:28
  • What you can do though, is saying "I won't access files from a samba share or an http URL" and remove those access plugins. If you don't want to transcode your video to stream it elsewhere, you may also remove some output access – cube45 Dec 29 '22 at 07:30