MrGlass1024 Posted November 23, 2020 Share Posted November 23, 2020 After a week of tinkering I managed to get a stable live stream set up with my raspberry pi and a webcam. Here's what I used: Required: A Raspberry Pi 4GB A Aukey 1080p webcam A Micro SD card 32gs class A1 (16 would also work, make sure it's A1) A 5V power adapter with usb C cable for the PI Optional: Hetsinks for the Pi A nano fan A case for the Pi Initial Set up: I'm gonna go quick through this since there are plenty resources online. Download Raspberry Pi OS with desktop and Balena Etcher, plug in your micro sd and user Etcher to write the os to the card. If you have a mouse keyboard and display plug those in to the Pi put in your card and plug in the ethernet and the power. Go through the initial set up and you're done. I didn't have those at hand so I created a file called SSH (with no extension) in the root folder of the card before putting it into the Pi. After I powered up the Pi I downloaded Putty and connected to the Pi ip adress, you can find that by doing ping rapberrypi in a cmd line in windows or in your rooter menu. The default user and password for the Pi are pi and raspberry. Put these in when putty prompt you to do it. There are a few commands to do before we can connect to the Pi in a friendlier manner. sudo apt-get update and sudo apt-get upgrade. I would also do passwd to change your default password as a safety measure. When you're done with that do a sudo reboot to get everything set up. Your putty will disconnect as the pi reboots you need to connect one more time and put in sudo apt-get install xrdp this will enable access to your Pi via windows remote desktop do another sudo reboot. For other OSes google is your friend. After the Pi reboots use Remote Desktop Connection to connect to your Pi. The username is pi and the password will be the new one you hopefully set. Getting the stream working: Open up a terminal window and type sudo apt-get install ffmpeg. A reboot is advised here as well. After you're back in open up a new terminal and put in: ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -pix_fmt mjpeg -i /dev/video0 -codec:v h264_omx -acodec aac -ab 128k -b:v 6000k -g 50 -strict experimental -f flv rtmp:// Depending on your desired streaming platform put in after rtmp:// your link and stream key. That's it! Congrats you are live! A few things that you might need to change depending on your setup. -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero creates a fake audio device if you want to record different audio this bit of code needs to change. For my setup I'm sendin internal audio to the stream via pulse and mocp music player. Just install them from terminal sudo apt-get install pulseaudio and sudo apt-get install moc. Start moc with mocp in terminal and using pulse redirect audio volume controll redirect the moc sound in the recording to monitor of built in audio. Now you can run the command ffmpeg -re -ar 44100 -ac 2 -f pulse -i default -pix_fmt mjpeg -i /dev/video0 -codec:v h264_omx -acodec aac -ab 128k -b:v 6000k -g 50 -strict experimental -f flv rtmp:// to start the stream. -pix_fmt mjpeg -i /dev/video0 -codec:v h264_omx is refering to my webcam that is set up as device0 if your camera is supported it usaully go to either 0 or 1. For a full list of supported cameras check out this link. I would sugest the logitech C920 as it has its own h264 hardware encoding and you would tax the processor a lot les with that one, you could then run -pix_fmt mjpeg -i /dev/video0 -codec:v h264 as an argument. I'm running and Aukey webcam which requires the h264_omx encoding on the Pi. The optional bit: If you went through the effort of buying the extra stuff for the pi cooling then you might want to check out this guide on how to overclock it. Final notes: Hope this quick and dirty tutorial is useful, if anybody wants extra info or having issues with the set up hit me up. I have some ideas for the on how to make the stream interactive involving pistons and rotors and step motors but that is still in the concept phase. I'll make sure to update if they come to life. Oh and if you want to see how it looks check out my stream. 4 1 Quote Link to comment
REEFsnap Posted November 23, 2020 Share Posted November 23, 2020 that's so impressive! any way i can order one from you 😄 will there be any issues if im using an imac? Quote Link to comment
MrGlass1024 Posted November 23, 2020 Author Share Posted November 23, 2020 1 hour ago, REEFsnap said: that's so impressive! any way i can order one from you 😄 will there be any issues if im using an imac? Hey I'm glad you like it. You can sure do it with an iMac, it's just a bit different with how you do the initial set up and connection. OSX has native ssh so you can do it from the terminal on your iMac and I think you can easily do a VNC connection to do the server. There's no point to sell a Pi kit as all i've done is in software, just buy something like this and a webcam then follow the guide. That kit even comes with the operating system installed on the card. You just need to put the SSH file in the root folder and install vnc viewer on your mac. This guide seems pretty good. Then just follow the rest of the steps and you're good to go. 2 Quote Link to comment
REEFsnap Posted November 23, 2020 Share Posted November 23, 2020 does the size of the memory card matter since it just streaming and im not trying to save anything? Quote Link to comment
Christopher Marks Posted November 23, 2020 Share Posted November 23, 2020 The live feed looks great! Thanks for sharing this project guide @MrGlass1024 I briefly had a webcam on my nano reef back in 2001 at the start of this website. It just snapped 480x320 jpgs and uploaded them every minute ☺️ Quote Link to comment
MrGlass1024 Posted November 23, 2020 Author Share Posted November 23, 2020 53 minutes ago, REEFsnap said: does the size of the memory card matter since it just streaming and im not trying to save anything? No not really it just needs to be fast A1 class i think 16gb would be more then enough. 1 Quote Link to comment
MrGlass1024 Posted November 24, 2020 Author Share Posted November 24, 2020 11 hours ago, Christopher Marks said: The live feed looks great! Thanks for sharing this project guide @MrGlass1024 I briefly had a webcam on my nano reef back in 2001 at the start of this website. It just snapped 480x320 jpgs and uploaded them every minute ☺️ That's some old school cool right there. My initial idea was to have an automated way to take a picture every day so I can see how the tank progesses but since I have no practical way to set up a camera in front of the tank and not obscure the view I settled on the stream and manually tanking photos weekly. I'm thinking of doing a robotic arm to move in and take a pic at a set time then fold back neatly away from the tank or a underwatter camera just at the surface level, but I need to see how I can watterproof the Pi camera. Arguably the second option would be a lot less cost and time consuming. 1 Quote Link to comment
ocpondpoacher Posted January 11, 2021 Share Posted January 11, 2021 @MrGlass1024 I would like to check out your stream. The link sends me to a private youtube page. Please share another link or put that thing back up for a few minutes so I can check it out. I am planning on working on a similar project soon. Thanks Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.