Page 1 of 1

Problem on play dshow devices on C#

Posted: 18 Sep 2024 21:49
by Ilario42
Hello everyone!
I apologize for my horrible English.

I've been trying to solve my problem for days, but I can't. My c# app keeps giving an error when I try to play any dshow:// in libVlc. If I manually enter the command in the windows cmd it works, in my app it doesn't want to know.

I don't know what to do anymore.

Help me, thanks

Code: Select all

private void PlayLiveStream(string videoDeviceName, string audioDeviceName, string txt) { try { Trace.WriteLine("videoDeviceName: " + videoDeviceName); Trace.WriteLine("audioDeviceName: " + audioDeviceName); // Crea il media utilizzando dshow:// var media = new Media(_libVLC, "dshow://", FromType.FromLocation); // Opzioni per dshow string[] dshowOptions = { $":dshow-vdev={videoDeviceName}", // Dispositivo video $":dshow-adev={audioDeviceName}", // Dispositivo audio ":live-caching=300", // Buffering minimo ":dshow-aspect-ratio=16:9", // Imposta l'aspect ratio ":dshow-fps=30" // Imposta il frame rate }; // Aggiungi tutte le opzioni al media foreach (string option in dshowOptions) { media.AddOption(option); Trace.WriteLine($"Aggiunto opzione: {option}"); } // Avvia il flusso all'interno del tuo controllo VLC _mediaPlayer.Play(media); Trace.WriteLine("Flusso live avviato correttamente."); } catch (Exception ex) { MessageBox.Show("Errore durante la riproduzione del flusso live: " + ex.Message); } }
This is the log console:

Code: Select all

videoDeviceName: vMix Video audioDeviceName: vMix Audio Aggiunto opzione: :dshow-vdev=vMix Video Aggiunto opzione: :dshow-adev=vMix Audio Aggiunto opzione: :live-caching=300 Aggiunto opzione: :dshow-aspect-ratio=16:9 Aggiunto opzione: :dshow-fps=30 [VLC Log] Debug: main: Creating an input for 'dshow://' Flusso live avviato correttamente. [VLC Log] Debug: main: using timeshift granularity of 50 MiB [VLC Log] Debug: main: using timeshift path: C:\Users\Ilari\AppData\Local\Temp [VLC Log] Error: main: Your input can't be opened [VLC Log] Debug: main: `dshow://' gives access `dshow' demux `any' path `' [VLC Log] Debug: main: looking for access module matching "dshow": 25 candidates [VLC Log] Debug: main: no access_demux modules matched [VLC Log] Error: main: VLC is unable to open the MRL 'dshow://'. Check the log for details. [VLC Log] Debug: main: looking for access_demux module matching "dshow": 11 candidates [VLC Log] Debug: main: no access modules matched [VLC Log] Debug: main: creating demux: access='dshow' demux='any' location='' file='(null)' [VLC Log] Debug: main: creating access: dshow:// Errore VLC durante la riproduzione del flusso

Re: Problem on play dshow devices on C#

Posted: 24 Sep 2024 05:48
by popfuture
Quick disclaimer, I haven't actually tried this in csharp, and I am not good at csharp. I am more of a C or C++ person. Still, can you try without foreach? Also, can you try hardcoding the device name, too (just as a test, not permanently)? You can find out the device name by opening up VLC player.

For example, in the non-csharp examples (specifically in C) in forum posts like this one: https://forum.videolan.org/viewtopic.php?t=147103

Here is what I am seeing people doing, but with modification to match my device names:

Code: Select all

media = libvlc_media_new_location(_libVLC, "dshow://"); libvlc_media_add_option(media, ":dshow-vdev=USB Video"); libvlc_media_add_option(media, ":dshow-adev=Digital Audio Interface (2-USB Digital Audio)");

So perhaps csharp would look something like this:

Code: Select all

var media = new Media(_libVLC, "dshow://", FromType.FromLocation); media.AddOption(":dshow-vdev=USB Video"); media.AddOption(":dshow-adev=Digital Audio Interface (2-USB Digital Audio)"); // now do whatever you were going to do and see what happens

Once you have that working, then try querying devices to get the strings for the devices and insert those strings into the option string using String.Format() or similar.

Again, I haven't coded this up yet, so it might not work. I hope it is helpful.

Re: Problem on play dshow devices on C#

Posted: 30 Sep 2024 08:52
by mfkl
make sure dshow is included in your libvlc build