首页 > 代码库 > C# 视频流操作
C# 视频流操作
发送视频流
1 void SendVideoBuffer(object bufferIn) 2 { 3 try 4 { 5 TcpClient tcp = new TcpClient(PeerIP_TXT.Text, 6000); 6 NetworkStream ns = tcp.GetStream(); 7 Image buffer = (Image)bufferIn; 8 buffer.Save(ns, System.Drawing.Imaging.ImageFormat.Jpeg); 9 ns.Close(); 10 tcp.Close(); 11 } 12 catch (Exception) { } 13 }
接收视频流
1 Socket server_sock; 2 void server() 3 { 4 try 5 { 6 server_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 7 server_sock.Bind(new IPEndPoint(IPAddress.Any, 6000)); 8 server_sock.Listen(-1); 9 10 while (true) 11 { 12 try 13 { 14 Socket new_socket = server_sock.Accept(); 15 NetworkStream ns = new NetworkStream(new_socket); 16 pictureBox_Remote.Image = Image.FromStream(ns); 17 ns.Close(); 18 new_socket.Close(); 19 } 20 catch (Exception) 21 { 22 } 23 } 24 } 25 catch(Exception){} 26 27 }
C# 视频流操作
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。