{"id":25208212,"url":"https://github.com/1010code/python-webcam-socket-streaming","last_synced_at":"2025-10-25T08:31:00.672Z","repository":{"id":40938852,"uuid":"352335157","full_name":"1010code/python-webcam-socket-streaming","owner":"1010code","description":"Python OpenCV webcam sending frames through TCP socket.","archived":false,"fork":false,"pushed_at":"2022-06-22T15:11:40.000Z","size":3908,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-28T05:23:36.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1010code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-28T13:21:24.000Z","updated_at":"2024-04-03T07:48:24.000Z","dependencies_parsed_at":"2022-07-19T14:47:32.437Z","dependency_job_id":null,"html_url":"https://github.com/1010code/python-webcam-socket-streaming","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fpython-webcam-socket-streaming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fpython-webcam-socket-streaming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fpython-webcam-socket-streaming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fpython-webcam-socket-streaming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1010code","download_url":"https://codeload.github.com/1010code/python-webcam-socket-streaming/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238109516,"owners_count":19417881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-10T12:19:05.691Z","updated_at":"2025-10-25T08:30:54.385Z","avatar_url":"https://github.com/1010code.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-webcam-socket-streaming\nPython OpenCV webcam sending frames through TCP socket. \n\n## YouTube Tutorial\n[\u003cimg src=\"./screenshot/cover.png\" width=\"550px\"\u003e](https://www.youtube.com/watch?v=MQ8JfdvA7Yk)\n\n## What is a network Socket?\n- A software structure within a network node\n- Serves as an endpoint to send \u0026 receive\n- A combination of protocpl type, IP address and Port number for data communication\n\n## Implementation of Sockets\nIn standard interent protocols like TCP and UDP, socket address is the combination of:\n\n```\nsocket address = (IP address, port number)\n```\n\n## How to find IP address?\nDepending on the operating system, you can easily find the IP address of your machine. Go to the terminal window and run this command:\n#### macOS\n\n```\nipconfig getifaddr en0\n```\n#### Windows/Linux/Ubuntu\n\n```\nifconfig\n```\n\n\u003e For Windows users. The required IP address will show against IPv4 Address.\n\n\u003e For Linux and Ubuntu users. The required IP address will be for Wifi LAN (inet).\n\n## client-server model\n- Server creates socket on startup\n- May serve several  clients concurrently\n- A client should know the server IP and port\n\n![](./screenshot/img01.png)\n\n## Python Server module\n\n![](./screenshot/img02.png)\n\n## Python Client module\n\n![](./screenshot/img03.png)\n\n## Video data transmission\n### At server side\n- With OpenCV get video frames of webcam\n- With pickle serialize frame to byte data\n- Pack each frame data using struct module\n- Send data to client and display frame\n\n### At client side\n- Receive packets and append them to data\n- Unpack the data using struct module\n- Load the frame using pickle\n- Display the frame at client side\n\n## Getting Started\n### Clone Project\nyou can create a new project based on this repo by doing the following:\n\n```\ngit clone https://github.com/1010code/python-webcam-socket-streaming.git\n```\n\n### Installation\nWhen that's done, install the project dependencies.\n\n```\npip install -r requirements.txt\n```\n\n#### Run server\nopen terminal and execute `server.py`. And we'll create TCP socket and listening 8485 port.\n\n```\npython server.py\n```\n\n### Run client\nAfter running the `server.py`, copy paste the IP and PORT to `client.py`. After doing that, then start client.\n\n```\npython client.py\n```\n\n## Demo\n- PC 1: run server.py\n- PC 1: run client.py\n\n![](./screenshot/demo.gif)\n\n\n- PC 1: run server.ipynb\n- PC 1: run client.py\n\n![](./screenshot/demo-2.gif)\n\n- PC 1: run server.ipynb\n- PC 2: run client.py\n\n![](./screenshot/demo-3.gif)\n\n## Reference\n- [kittinan/socket](https://gist.github.com/kittinan/e7ecefddda5616eab2765fdb2affed1b)\n- [Socket programming and OpenCv in Python](https://www.youtube.com/watch?v=7-O7yeO3hNQ)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1010code%2Fpython-webcam-socket-streaming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1010code%2Fpython-webcam-socket-streaming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1010code%2Fpython-webcam-socket-streaming/lists"}