Skip to content

Instantly share code, notes, and snippets.

@visioforge
Last active July 22, 2021 14:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save visioforge/96e7ccf8ce684de01be8b4f1a785a21e to your computer and use it in GitHub Desktop.
Save visioforge/96e7ccf8ce684de01be8b4f1a785a21e to your computer and use it in GitHub Desktop.
5 lines of code sample - IP camera preview - VisioForge Video Capture SDK .Net - https://www.visioforge.com/video-capture-sdk-net
// Required NuGet packages:
// https://www.nuget.org/packages/VisioForge.DotNet.VideoCapture/
// https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x64/
// https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x86/
// https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.LAV.x64/
// https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.LAV.x86/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisioForge.Types.OutputFormat;
using VisioForge.Types.VideoEffects;
namespace SampleCapture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
videoCapture1.OnError += OnError;
}
private void btStart_Click(object sender, EventArgs e)
{
videoCapture1.IP_Camera_Source = new VisioForge.Types.Sources.IPCameraSourceSettings() { URL = "http://192.168.233.129:8000/camera/mjpeg", Type = VisioForge.Types.VFIPSource.Auto_LAV };
videoCapture1.Audio_PlayAudio = videoCapture1.Audio_RecordAudio = false;
videoCapture1.Mode = VisioForge.Types.VFVideoCaptureMode.IPPreview;
videoCapture1.Start();
}
private void btStop_Click(object sender, EventArgs e)
{
videoCapture1.Stop();
}
private void OnError(object sender, ErrorsEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
}
}
@PannuHacker
Copy link

Hello sir ,
i tried it , but i got some errors.
like:-

You can see this window because OnError event is not implemented in your code. Implement OnError event to see errors, create empty handler to ignore all errors.

Unable to connect main screen filter to video output pin.

plz help

@visioforge
Copy link
Author

visioforge commented Nov 22, 2019 via email

@sefatanam
Copy link

sefatanam commented Jun 6, 2020

Thanks a lot, it worked!

@Decompressor-art
Copy link

URL = "http://192.168.233.129:8000/camera/mjpeg
camera - Is it camera name?

@visioforge
Copy link
Author

Camera URL.

@Decompressor-art
Copy link

When debug code as in video I get message: "You can see this window because OnError event is not implemented in your code. Implement OnError event to see errors, create empty handler to ignore all errors.
Unable to create LAV Splitter Source filter. Please be sure that LAV filters installed.
Unable to open IP camera stream. Please check URL. Remember, you're need direct video URL, not just IP address."

@visioforge
Copy link
Author

Please install SDK from product page or add the following NuGet packages: VisioForge.DotNet.VideoCapture.TRIAL, VisioForge.DotNet.Core.Redist.VideoCapture.x64, VisioForge.DotNet.Core.Redist.LAV.x64.

@Decompressor-art
Copy link

I've installed NuGet packages: VisioForge.DotNet.VideoCapture.TRIAL, VisioForge.DotNet.Core.Redist.VideoCapture.x64, VisioForge.DotNet.Core.Redist.LAV.x64. But I have error: Unable to create filter: LAV Splitter Source
Не удалось получить фабрику класса COM для компонента с CLSID {B98D13E7-55DB-4385-A33D-09FD1BA26338} из-за следующей ошибки: 80040154 Класс не зарегистрирован (Исключение из HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Unable to create LAV Splitter Source filter. Please be sure that LAV filters installed.

Unable to open IP camera stream. Please check URL. Remember, you're need direct video URL, not just IP address.
What does this mean?

@visioforge
Copy link
Author

If your app started as x64 that should work. For x86 app you can add x86 NuGet packages.

@issamsaidd
Copy link

videoCapture lose from tools

@visioforge
Copy link
Author

videoCapture lose from tools

What do you mean?

@Decompressor-art
Copy link

I have x64 Windows and this program doesn't work

@Decompressor-art
Copy link

May be that is because I have login and password but I don't know where them to insert in code

@visioforge
Copy link
Author

Yes, if your camera require login/password.

Login/password can be set in videoCapture1.IP_Camera_Source property.

Please check https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Video%20Capture%20SDK/WinForms/CSharp/IP%20Capture demo.

@issamsaidd
Copy link

videoCapture lose from tools

What do you mean?

This videoCapture tool is missing. I couldn't get it

@visioforge
Copy link
Author

VisioForge.DotNet.VideoCapture.TRIAL NuGet package have VideoCapture class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment