I have 2 webcams installed on my desktop - Intex USB 2.0 and Logitech Webcam C170. I am using libvlc .net wrapper and I want to stream the second webcam.
I am creating a playerStream using the given example -
VlcSinglePlayer playerStream = (VlcSinglePlayer)factory.CreatePlayer(new
PlayerOutput(":sout=#transcode{vcodec=h264,vb=256,fps=30,scale=1,acodec=none}:udp{mux=ts,dst=127.0.0.1:8080}"));
playerStream.SetMediaInput(new MediaInput(MediaInputType.UnparsedMrl,
"dshow://:dshow-vdev=\"Webcam C170\" :dshow-adev=none :live-caching=300 "));
The above code works but the stream I capture in VLC (udp://@:8080) is always from the first webcam (Intex USB 2.0) and not from the Logitech Webcam C170.
When I try using VLC from the command line everything works fine.
How can I fix this error?
Since it is always picking your first device VLC must not be aware of the device option you specified, so most likely there's an error in the syntax somewhere.
Are you simply missing a space after "dshow://"?
You have this:
playerStream.SetMediaInput(
new MediaInput(MediaInputType.UnparsedMrl,
"dshow://:dshow-vdev=\"Webcam C170\" :dshow-adev=none :live-caching=300"));
There should be a space after "dshow://" and before the following colon:
playerStream.SetMediaInput(
new MediaInput(MediaInputType.UnparsedMrl,
"dshow:// :dshow-vdev=\"Webcam C170\" :dshow-adev=none :live-caching=300"));
Sometimes it is necessary to use "--" syntax rather than ":", so this might be necessary instead:
playerStream.SetMediaInput(
new MediaInput(MediaInputType.UnparsedMrl,
"dshow:// --dshow-vdev=\"Webcam C170\" --dshow-adev=none --live-caching=300"));
If that still doesn't work, then you need to consult the documentation for how that MediaInputType.UnparsedMrl
expects its arguments. In my own LibVLC bindings, here only "dshow://" would be considered the "MRL", and everything else would be options that must be passed separately and explicitly added to the media (it's a different API call under the covers).
Some options can (and in some cases need to) be passed when creating the LibVLC instance. For this library that would be something like this:
factory = new VlcMediaLibraryFactory (new string[] {
"--dshow-vdev=\"Webcam C170\"",
"--dshow-adev=none",
"--live-caching=300"});