如何在c#中从网络摄像头发送视频? [英] How can send video from webcam in c#?

查看:141
本文介绍了如何在c#中从网络摄像头发送视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




©想要在c#windons应用程序中从服务器向客户端发送网络摄像头视频。在服务器中,ı从网络摄像头拍摄视频,然后发送给客户端。所以我可以看服务器的网络摄像头。怎么办?请帮帮我。

Hi
İ want to send webcam video from server to client in c# windons application .In server , ı take video from webcam and then i send to client. so i can watch server's webcam . How can do that ? Please help me.

推荐答案

请看我对这个问题的评论。请进行搜索,例如 http://www.codeproject.com/search.aspx?q=Webcam+video+capture+%28%22.NET%22+OR+%22C%23%22%29&doctypeid= 1



-SA
Please see my comment to the question. Please do the search, for example, http://www.codeproject.com/search.aspx?q=Webcam+video+capture+%28%22.NET%22+OR+%22C%23%22%29&doctypeid=1.

—SA


此源代码可用于发送您的网络摄像头的图像到远程位置。如果您寻找这样的解决方案,我可以提供帮助:服务器将是网络摄像头所连接的PC,远程计算机将是客户端。



This source code can be used to send the image of your webcam to remote locations. I can help if you look for a solution like this: the server will be the PC that the webcam is connected to, and the remote computers will be the clients.

namespace Onvif_IP_Camera_Server_04
{
    public class MyServer : IPCameraServer
    {
        private MediaConnector _connector;
        private IIPCamera _camera;
        private IIPCameraClient _client;
 
        public string IpAddress { get; set; }
        public int Port { get; set; }
 
        public event EventHandler<eventargs> ClientCountChange;
 
        public MyServer()
        {
            _connector = new MediaConnector();
            _camera = IPCameraFactory.GetCamera("192.168.115.175:8080", "admin", "admin");
 
            if (_camera != null)
                _camera.Start();
        }
 
        protected override void OnClientConnected(IIPCameraClient client)
        {
            _client = client;
            _connector.Connect(_camera.AudioChannel, _client.AudioChannel);
            _connector.Connect(_camera.VideoChannel, _client.VideoChannel);
 
            var handler = ClientCountChange;
            if (handler != null)
                handler(null, new EventArgs());
 
            base.OnClientConnected(_client);
        }
 
        protected override void OnClientDisconnected(IIPCameraClient client)
        {
            _connector.Disconnect(_camera.AudioChannel, _client.AudioChannel);
            _connector.Disconnect(_camera.VideoChannel, _client.VideoChannel);
            _connector.Dispose();
 
            var handler = ClientCountChange;
            if (handler != null)
                handler(null, new EventArgs());
 
            base.OnClientDisconnected(client);
        }
    }
 
    class Program
    {
        static MyServer _server = new MyServer();
 
        static void Main(string[] args)
        {
            _server.Start();
            _server.SetListenAddress("192.168.115.172", 554);
            _server.ClientCountChange += new EventHandler<eventargs>(server_ClientCountChange);
            Console.WriteLine("Started");
            Console.Read();
        }
 
        static void server_ClientCountChange(object sender, EventArgs e)
        {
            _server.ConnectedClients.ForEach(x => Console.WriteLine(x.TransportInfo.RemoteEndPoint.ToString()));
        }
    }
}





参考:

如何在C#中将视频同时传输到多个位置(视频流复制)[ ^ ]


这篇关于如何在c#中从网络摄像头发送视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆