Live Streaming Video Chat App

SUMMER 2021 — Task 03

Team : Summer_6_14
-Mohammed Adnan
-Prattipati Sri Raviteja
-Mohammed Awais Ahmed
-Saami Abdul Samad

Task 03

Description 📄

🧿 Create Live Streaming Video Chat App without voice using cv2 module of Python.

GitHub Repo:

The Computer Vision (Cv2) module of Python is employed.

Socket programming to connect the two ends of the network to connect to each other.

we have used There are two key nodes here:

  • The Sender(Server)
  • The Receiver(Client)

The Sender:

Importing the Libraries:

import socket
import cv2
import pickle
import struct
import imutils

Creating the Socket:

server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host_name = socket.gethostname()
host_ip = socket.gethostbyname(host_name)
print('HOST IP:',host_ip)
port = 10050
socket_address = (host_ip,port)

Output: Host IP: <IP Address>

Binding & Listening the Socket

print("Listening @",socket_address)

Output: Listening @ <Host IP>, <Port>

Running and Streaming the Video:

while True:
client_socket,addr = server_socket.accept()
print('Connection from:',addr)
if client_socket:
vid = cv2.VideoCapture(0)

img,frame =
a = pickle.dumps(frame)
message = struct.pack("Q",len(a))+a

key = cv2.waitKey(10)
if key ==13:

The Receiver :

Importing the same libraries as the Server-Side

import socket
import cv2
import pickle
import struct
import imutils

Connecting to the Socket:

client_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host_ip = '<Host IP>'
port = <Port_No>

Streaming the Server Side Video:

while True:
while len(data) < payload_size:
packet = client_socket.recv(4*1024)
if not packet: break
packed_msg_size = data[:payload_size]
data = data[payload_size:]
msg_size = struct.unpack("Q",packed_msg_size)[0] while len(data) < msg_size:
data += client_socket.recv(4*1024)
frame_data = data[:msg_size]
data = data[msg_size:]
frame = pickle.loads(frame_data)
key = cv2.waitKey(10)
if key == 13:

The Output:

Thank You!!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Getting the best out of Cosmos DB’s scale-out Graph API aka partitioned Graph containers

Setup a custom domain for your Gmail address for free

How to design a good Load Test with Markov Chain (Part3)

Building a Kettle Manager: Raspberry Pi, Machine Learning, and 3D Printing

DPWK Mine Planet 2.0 Announcement

Creating Enemy Explosions!

Web Testing with Selenium Webdriver Part 1: Start with basic tests

Agave Development Updates #7 / 15–21 May, 2021

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mohammed Adnan

Mohammed Adnan

More from Medium

HW#26 Using Code to Make a Card

How to setup automate deploy Google Apps Script (Pipeline)(Git)

Ember Query Params

KYC Solutions — User-friendly API, Dashboard by Argos KYC