Search the Community
Showing results for tags 'livestream'.
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.