Camera Chat in Python
Key Takeaways
The video demonstrates how to create a simple camera chat application in Python, utilizing various libraries and tools for AI coding.
Full Transcript
[Music] what is going on guys welcome back in today's video we're going to build a simple camera chat in python so let's get right into it all right now before we get into actual coding i want to mention that this is not going to be a zoom clone or a skype clone because we're not going to transmit any audio data we're only going to transmit camera data uh we're going to stream the video from the camera we're not going to transmit any audio data and the reason for that is because i have not really figured out how to do this platform independently yet so i need to work on that and i don't want to publish a package that only runs on windows because i know how to do the audio transmission on windows but i it's kind of tricky on linux for me right now so i need to figure that out and then we can do another video on that which brings me to the next point that we need to install a package that i have written it's called vidstream so you open up your command line and you type pip install vidstream like that and if you want to make sure that you have the latest version because it's currently in the alpha and the buggy alpha so it's constantly changing and if you want to make sure you have the latest version you say pip install minus minus upgrade with stream and then you should get the latest version which you need uh to use or in order to use the latest features so once you have that what you're going to do is you're going to say import or actually we're going to see from vidstream import camera client and from bitstream import streaming server those are the two things that we're going to need because what we're going to do here is we're not going to have a server and a client we're going to have two clients connecting to each other so we're going to have two computers with the exact same script and they're going to connect i mean the data is going to be different so the ips are going to be different but but the functionality of the script is going to be the exact same and they're just going to connect they're going to have a receiving end and a sending answer they're going to send camera data and they're going to read or receive and display camera data and for this we're going to need multi-threading so we're going to import threading and we're going to import time so the first thing we need to do is we need to define the receiving and descending end so we're going to say receiving is going to be the streaming server here we're going to receive the data from the other camera client and the address that we're going to pass here is the local ip address of this computer so in my case 192 168 0 17. if you want to figure out what your ip address is you're going to have to go to cmd or terminal on windows you're going to go to cmd and type ip config and you're going to look for the ipv4 address i think it's ipv4 address and on linux what you're going to do is you're going to type ifconfig into the terminal and it should be something like inet uh inet address or something like that so this is how you find out your private ip address now the important thing is here if you're streaming this in the internet and not only in your local private network at home with multiple computers you need to um take into account that you need to specify your private ip address on the receiving end so if you're running a server you need to specify that it's running on your local private ip address but if someone connects to that server and it's not in the same network you need to specify the public ip address or the the sender is going to have to specify the public ip address because if you have a server running in the internet this server is going to run on its local ip address but if you want to connect to it you need to specify the public ip address and for this you can use services like myip.is i think that's the site that showed your your public ip address but we're going to do this locally with two laptops we're going to have a live demonstration in the end and for this we're going to only use private ip addresses here so the port is going to be 9999 you can choose another port as well and then we're going to have ascending and in descending end is going to be the camera client and here we're going to have a different ip address and this different ip address is going to be um the the target ip address so in this case the ip address of my other laptop and this is going to be 192 1680 172 in my case again what you do here is you go to the other laptop uh the other laptop types ipconfig or ifconfig and then you get the ip address from there or you know the public ip address so once we have that we have a server and a client and we now have to specify the thread so we're going to say t1 equals threading dot threat and the target function of the first thread is going to be target is going to be um the receiving end dot start server we're not calling the function we're passing the function and then we're running the threat by saying t1 dot start like that now what we do after that is we say time sleep and this here is uh really not a good practice this is not best practice this is not a good practice you should never synchronize scripts with uh with the sleep method because the reason i'm doing this here is just for demonstrational purposes but actually what we need to do is we need to make sure that both both clients are actually listening before they can start sending or start connecting to a server so we need to set up the servers and then we need to have some time for the clients to connect to those servers because if the client connects or tries to connect to a server that doesn't exist we're going to get an exception it's going to stop and this is not what we want so actually if you're gonna do this properly what you would have to do is you would have to use locks or some kind of synchronization you should not do this with time.sleep but you can do this for this video you can also do time sleep five uh the basic idea here is that we're going to say start the server and then wait give me time to start the client and then uh so we need to start both both scripts simultaneously here otherwise you would also be able to if you don't want to do this with sleep you could also say sending dot start server try over and over again until you get no exception and then start the actual stream but we're going to do it like that here and we're going to say t2 equals threading threat target equals the sending end dot start stream again not calling just passing t2 start and then what we're going to do um now right now we have the main thread and the main thread calls two extra threads but the main thread is still running and we want to have it running because then we can say while input is not equal to stop while this is not the case we're going to just continue so we're going to ask for the input over and over again and if we get out of that loop because the input was stopped what we're going to do is we're going to say receiving dot stop server and sending dot stop stream so we can always terminate we can always terminate the script by just writing stop and now what we're going to do is we're going to take that script we're going to change or actually we're going to swap those ip addresses i'm going to do this on my second laptop as well and then we're going to see how the camera chat or the camera streaming works here all right so let's go for a little live demonstration i now have my linux machine on with the exact same script uh the only difference is that those two ipa addresses are swapped so windows is hosting on this ip address and sending to this ip address and on linux it's hosting on this ip address and sending to this ip address so it's swapped i also changed the ip address because i figured out that this is my actual local ip address but it doesn't really matter to you and i turned off my camera because i need the camera to be available to this script so that it can stream uh to the other machine other than that those two scripts are actually the same and we're going to run them at the same time on windows we need to uh navigate with cmd to the directory and we're going to say python and main.py and on linux i'm going to also run the same file so we're running here we're running here and it's going to take a little while here but it's going to connect eventually and you're going to see me from the other camera here because i'm screen recording my windows machine uh and you can see here i'm holding my laptop here's my recording setup um and i don't think that you're going to be able to see this but actually no i don't think that you have any chance to see that but on my linux machine right now i can see the scree the stream from this camera maybe you can see that it's you can see the little light here it's streaming at the moment so on my linux machine here i can actually see uh the recording of that camera and on windows as you can see it's streaming this camera so it works and i can now stop it by just saying s t op and it stopped it the script terminated it also terminated on linux and as you can see we can stream camera data across two different machines so that's it for this video if you enjoyed it hope you learned something if so let me know by hitting the like button and leaving a comment in the comment section down below by the way of course you can extend this camera streaming by adding the chat just look at my tcp chat my tcp guitar or my advanced tcp chat or you can combine it with sound streaming if you figure out a way to do this platform independently or you only need it on windows then you can do it on windows you can extend this as you want and i maybe will follow up with a zoom clone or a skype clone in the future but for now that's it and i thank you very much for watching see you in the next video and bye [Music] you
Original Description
In this video we learn how to do a simple camera chat in Python.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
🐍 The Python Bible Book: https://www.neuralnine.com/books/
👕 Programming Merch: https://www.neuralnine.com/shop
💻 Exclusive Content 💻
👥 Patreon: https://www.patreon.com/neuralnine
🌐 Social Media & Contact 🌐
📱 Website: https://www.neuralnine.com/
📷 Instagram: https://www.instagram.com/neuralnine
🐦 Twitter: https://twitter.com/neuralnine
🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/
📁 GitHub: https://github.com/NeuralNine
🎵 Outro Music From: https://www.bensound.com/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from NeuralNine · NeuralNine · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
Python Beginner Tutorial #5 - Loops
NeuralNine
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
Python Beginner Tutorial #7 - Functions
NeuralNine
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
Python Beginner Tutorial #9 - File Operations
NeuralNine
Python Beginner Tutorial #10 - String Functions
NeuralNine
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
Python Intermediate Tutorial #6 - Queues
NeuralNine
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
Python Intermediate Tutorial #9 - Recursion
NeuralNine
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
Python Intermediate Tutorial #11 - Logging
NeuralNine
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
Python Machine Learning #4 - Support Vector Machines
NeuralNine
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
Making Text Images Readable Again with Python and OpenCV
NeuralNine
Neural Networks Simply Explained (Theory)
NeuralNine
Motion Filtering with OpenCV in Python
NeuralNine
Top 5 Programming Languages To Learn in 2020
NeuralNine
Simple TCP Chat Room in Python
NeuralNine
Image Classification with Neural Networks in Python
NeuralNine
Edge Detection with OpenCV in Python
NeuralNine
S&P 500 Web Scraping with Python
NeuralNine
Simple Sentiment Text Analysis in Python
NeuralNine
Introduction - Algorithms & Data Structures #1
NeuralNine
More on: AI Pair Programming
View skill →Related Reads
📰
📰
📰
📰
AI Coding Agents in 2026: 8 Tools That Actually Ship Production Code
Dev.to AI
I wanted a better way to code with ChatGPT, so I built SVI
Dev.to · Aleksandr Razinkin
I Cut 1,300 Lines of CLAUDE.md — My Token Bill Dropped 75%
Medium · Programming
Anthropic Just Dropped a Banger on “Loops” and It Quietly Changes How You Should Use Your Coding…
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI