C# 视频流操作
Posted C# java C++ 开源通信
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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# 视频流操作的主要内容,如果未能解决你的问题,请参考以下文章