Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewFrame not getting called on OBS Virtual Camera #48

Open
Bit00009 opened this issue Mar 19, 2021 · 2 comments
Open

NewFrame not getting called on OBS Virtual Camera #48

Bit00009 opened this issue Mar 19, 2021 · 2 comments

Comments

@Bit00009
Copy link

Bit00009 commented Mar 19, 2021

Hi I want to access to OBS Studio virtual camera using AForge.NET but it doesn't work properly.
It finds it and name and everything is fine but NewFrame is not getting called.
I tested the same code with my laptop webcam and it works...

namespace WebCamStudy
{
    class Program
    {
        static FilterInfoCollection filterInfoCollection;
        static VideoCaptureDevice videoCaptureDevice;
        static Viewer camView = new Viewer();

        static void Main(string[] args)
        {
            Console.WriteLine("Initializing...");
            /* ========================================================= */
            filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo Device in filterInfoCollection) Console.WriteLine($"Device [{Device.Name}]");
            var FilterInfo = filterInfoCollection[0]; // OBS Virtual Camera
            Console.WriteLine($"Connecting to [{FilterInfo.Name}]...");
            videoCaptureDevice = new VideoCaptureDevice(FilterInfo.MonikerString);
            videoCaptureDevice.NewFrame += OnFrameSync;
            videoCaptureDevice.Start();
            Console.WriteLine("Syncing...");
            camView.ShowDialog();

            /* ========================================================= */
            Console.WriteLine("Releasing...");
            if (videoCaptureDevice.IsRunning == true)
                videoCaptureDevice.Stop();
            camView.Close();
            Console.WriteLine("App finished.");
        }

        static private void OnFrameSync(object sender, NewFrameEventArgs eventArgs)
        {
            camView.SetFrame((Bitmap)eventArgs.Frame.Clone());
        }
    }
}

What is wrong?

  • Also there is no VideoSourceError
@Katod
Copy link

Katod commented Apr 23, 2022

Maybe some one find way to fix it and capture obs virtual camera too ?

@jirunn
Copy link

jirunn commented Oct 6, 2023

Hi , You must set videoCaptureDevice.VideoResolution before start video.

VideoCapabilities[] vcs = videoCaptureDevice.VideoCapabilities;
videoCaptureDevice.VideoResolution = vcs[0];
videoCaptureDevice.NewFrame += VideoCaptureDevice_NewFrame;
videoCaptureDevice.Start();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants