Maximum PC - USA (2019-10)

(Antfer) #1

Stream Live to


Yo uT ube from


Yo u r R a spberry Pi


1


STREAMING ESSENTIALS
Before you even pick up your Raspberry Pi, it’s a good idea to
ensure your network is up to the task. The optimum bitrate
for YouTube videos [Image A] from the Pi is 400–600Kb/s. You can
change this if necessary, but your router needs to be up to the
job. Help things along by moving the Pi closer to the router, using
an Ethernet cable if necessar y, or employing powerline adapters
to improve signal strength at your Raspberry Pi’s location.
>> While you don’t necessarily need a wireless Pi, the best
results can be enjoyed with a Raspberry Pi 3, 3B+, or 4. The
improved spec of these three over the Raspberry Pi 2 results in
superior streaming performance. The Pi 2 will work, but you may
run into resource bottlenecks. Tweaking that bitrate (you’ll find
out how later) will help if you’re stuck using one.
>> Your choice of camera may impact how well this works. USB
cameras, while compatible with the Pi, are largely pointless,
because the computer has such a good official camera. We used
the Raspberry Pi Camera Module v2.1 for this project, but the
older models should work just as well. If you’re planning to add
audio to your camera stream, you’ll also need a microphone,

STREAMING VIDEOS on the web is increasingly popular, and YouTube is the chosen platform
for many. Almost any device can stream video to YouTube, but what if you want a dedicated
streaming solution? The Raspberry Pi is a great choice for this, giving you the option to stream
anything you like, just as long as there is an unlimited network connection.
You’re limited only by your imagination, with the Raspberry Pi and its Camera Module ideal
for everything from a YouTube-based baby monitor to running live presentations (see the boxout
on the opposite page for more ideas).
With a good network connection, the right Raspberry Pi setup, and a YouTube channel stream
URL, you can have your Raspberry Pi YouTube-streaming video camera up and running in just
a few minutes. –CHRISTIAN CAWLEY

YOU’LL NEED THIS


RASPBERRY PI
You also need the
Pi Camera Module.

of course. The best option here is to use a Raspberry
Pi-compatible USB mic, although anything connected
to a suitable HAT will work. Don’t use the TRRS port,
however, because it won’t work. Raspberry Pi audio is
beyond the scope of this tutorial, so we’re continuing
with a silent video.

2


WE HAVE A STREAM
The Raspberry Pi Camera Module must be
connected before you power up the computer. If
you haven’t done this before, find the camera port, then
lift the catch. Insertion is straightforward: The rule of
thumb to remember is that the silver side of the contacts
point toward the HDMI port. Before booting up, it’s
also a good idea to connect the microphone ready for
configuration later on.
>> With the Raspberry Pi up and running, you need to
configure the Camera Module. You can do this either in
the Raspberry Pi Configuration screen in the desktop
environment, or via the raspi-config tool in the command
line if you prefer:
sudo raspi-config
>> Whichever method you choose, you need to display
the Interfacing Options and set the Camera to “Enabled.”
S ele c t “OK ” to co nfi r m an d r eb o ot th e R a sp b er r y P i w h en
prompted. Next, you need to confirm that the camera is
working. Use the raspistill command in the terminal:
raspistill –o image.jpg
>> This creates a file called “image.jpg” in the “/home”
directory. You can check it has been created by listing
the directory contents:
ls
>> In most cases, the camera image will be fine. To
check it properly, you need to plug your Pi into an HDMI
display, or check via VNC.
>> For streaming to work, you need a YouTube account
and a unique key that is created for each stream. If you
have a Google account, you probably already have a
YouTube account, too, so sign into YouTube, and find the

A

56 MAXIMUMPC OCT 2019 maximumpc.com


R&D

Free download pdf