Search code examples
c#directxwebcamvideo-capture

Directx.Capture How to set resolution


So, I was redding a article(this one : https://dashingquill.wordpress.com/2012/06/27/capturing-webcam-using-directshow-net-library/ ) and i download it to study the code.

Im trying to implemente this changes(to make video in 1920x1080) :

            capture.FrameRate = 29.997;
            capture.FrameSize = new Size(1920, 1080);
            capture.AudioSamplingRate = 44100;
            capture.AudioSampleSize = 16;

But my ask to you is where in code do i apply this codes? I try to apply here :

    void preview()
    {
        try
        {

                capture = new Capture(filters.VideoInputDevices[0], filters.AudioInputDevices[0]);
                capture.FrameRate = 29.997;
                capture.FrameSize = new Size(1920, 1080);
                capture.AudioSamplingRate = 44100;
                capture.AudioSampleSize = 16;
                capture.PreviewWindow = panel1;

but when i do that something funny happens, my video is in (1920x1080) only when i click on "stop" anything different make the preview video "weird"(not in 192x1080).

Can you help me on that?

Aa, another question. If i want to capture a sigle frame,like a picture,how can i do that with that code?

Thank you and osrry for my bad english . Its not my natural language.


Solution

  • I found by myself the solution. Well, apparently what i was doing is correct, but i was running on debug mode. When a change to realese thats works fine and the framesize was set correct.