Problem on play dshow devices on C#

This forum is about all development around libVLC.
Ilario42
New Cone
New Cone
Posts: 2
Joined: 01 Jul 2019 02:16

Problem on play dshow devices on C#

Postby Ilario42 » 18 Sep 2024 21:49

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

popfuture
New Cone
New Cone
Posts: 1
Joined: 24 Sep 2024 05:13

Re: Problem on play dshow devices on C#

Postby popfuture » 24 Sep 2024 05:48

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.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Problem on play dshow devices on C#

Postby mfkl » 30 Sep 2024 08:52

make sure dshow is included in your libvlc build
https://mfkl.github.io


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 12 guests