GoodSimon
GoodSimon

Reputation: 161

Enumerating the video capture devices with DirectShow works well in console but does not work with Unity (2018.2.12)

I use Unity 2018.2.12 and DirectShow.Net

I created simple code that enumerates video capture devices. It founds devices but it cannot obtain their FriendlyName property under being running as Unity script.

using DirectShowLib;
using UnityEngine;

namespace DirectShow.Net_Tests {
    public class CodeForUnity : MonoBehaviour {

        void Start() {
            foreach (var device in DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice))
            {
                Debug.Log(
                    $"Device Name:\t{device.Name}\n" +
                    $"\tDevice FriendlyName (Property):\t{device.GetPropBagValue("FriendlyName")}\n" +
                    $"\tDevice Class GUID:\t{device.ClassID}\n");
            }
        }
    }
}

The same code can obtain FriendlyName property being running as console application.

using System;
using DirectShowLib;

namespace DirectShow.Net_Tests {
    static class Program {

        public static void Main(string[] args) {
            foreach (var device in DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice))
            {
                Console.WriteLine(
                    $"Device Name:\t{device.Name}\n" +
                    $"\tDevice FriendlyName (Property):\t{device.GetPropBagValue("FriendlyName")}\n" +
                    $"\tDevice Class GUID:\t{device.ClassID}\n");
            }
        }
    }
}

Why does not it work in Unity?

Upvotes: 0

Views: 638

Answers (0)

Related Questions