Maximum PC - USA (2019-10)

(Antfer) #1
camera icon, click it, and select “Go Live.” In the “New Stream”
window, give the feed a suitable title, set a “Public/Unlisted/
Private” option, a description, and a genre, then click “Create
Stream.” The “Stream Preview” window now appears, displaying
the standard stream URL and the stream name/key. You’ll need
this, so click the visibility icon, and make a note of the key for
later [Image B].

3


STREAMING SPECIFICS
To create a video stream, you should have the avconv
software installed. This comes pre-installed in Raspbian
Stretch, so if you’re using an older version, it’s wise to update
it first:
sudo apt upgrade
sudo apt update
>> If you don’t want to do this (perhaps because you’ve got
deprecated software that you don’t want to stop using), simply
install avconv as part of the libav-tools package instead:
sudo apt install libav-tools
>> Creating the stream requires the input of a long
raspivid command, consisting of various switches and
instructions, such as fps to set the frames per second. As it’s
quite a complicated command, it’s worth looking at some of its
key elements.
>> -fps As noted, this sets the frames per second captured
by the camera. Anything over 24fps should be fine; less than
this, and it may resemble time-lapse. A lower rate can improve
streaming, however.
>> -w <xxx> -h <xxx> Specifies the width and height of the
video. Without these, raspivid defaults to 1920x1080 HD.
>> -b The output bitrate limit, which YouTube recommends
should be 400–600Kb/s. A lower figure means a lower-quality
video, but better streaming.
>> -acodec If you’re not using a mic, you need to include this.
YouTube doesn’t permit videos without audio (or audio without
video), so this command creates a fake audio track. If you have a
mic connected and working, you can omit this.
>> -f The output format. For streaming video from YouTube to
the Raspberry Pi, FLV is the best option.

4


KEEP ON STREAMIN’
If you’re setting this up over SSH, it’s a good idea to take
steps to avoid the stream closing when you disconnect.
One way of avoiding this is with screen :
sudo apt install screen
>> Wait while it installs, then reboot the Pi:
sudo reboot
>> Connect again over SSH, then enter the screen command.
You can then run the raspivid command. Note that this should
be entered as a single line, like so:
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | avconv -re -ar 44100
-ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i -
-vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f
flv rtmp://a.rtmp.youtube.com/live2/[your-secret-key-here]
>> Simply copy the YouTube stream key from the browser
window into the terminal, replacing [your-secret-key-here].
Press Return and wait while the stream starts. A moment later,
you should see it running in the top-left corner of the YouTube
livestreaming page. If nothing happens, double-check all the
setup steps as listed above.

5


CROSSING THE STREAMS
With the stream running, you can share it or simply watch
it. Using a private channel for the feed at the setup stage
lets you limit the feed to YouTube apps or browser sessions with

the corresponding account details. Otherwise, the feed
will be public or unlisted.
>> With both options, you can share the feed with
others. The public feed is open to anyone, whereas the
unlisted feed is limited to those who have the feed URL;
it isn’t displayed in search results. Both options enable
you to share the feed URL on your preferred social
networks as well.

B

Why might you want to stream video with a
Raspberry Pi? Various uses can be considered,
although some will be impacted by latency, which
can be as much as 30 seconds once the video has
been captured, sent, and uploaded to YouTube.
For example, you could set up the Raspberry Pi
as a baby monitor. Configuring the YouTube feed
as private means that you can keep an eye on your
little ones from any portable device, just as long as
you’re signed in with the same account.
Alternatively, you might use the Raspberry Pi
as a security camera. Again, a private channel
can let you watch your home from any location you
can get a signal. While it will miss the benefits of
a standard IPTV security camera (such as motion
detection), it makes an adequate substitute.
Other problems can be solved with a
Raspberry Pi streaming video camera. You
could go public with your YouTube video feed,
perhaps making short livestreams to share your
thoughts about recent topical events. You could
demonstrate your job, your work setup, or even
a hobby you enjoy; you might even conduct an AMA
with your Raspberry Pi as the stream host, direct
to YouTube.

USES FOR


LIVESTREAMING


maximumpc.com OCT 2019 MAXIMUMPC 57

Free download pdf