Jump to content

Attention: RC-CAM.com will be closing down August 2021.

The RC-Cam.com forum was the very first online community dedicated to the advancement of wireless video cameras on radio controlled (R/C) models. This is now called "FPV" (First Person View). We are proud of the contributions that our members have made to the FPV hobby.

We've seen significant changes over the last twenty years. Initially there were a lot of eager R/C hobbyist that built their own video systems. Allowing these creative individuals to share their work was the purpose of this site. Now the FPV market is flooded with low cost systems; Sadly DiY FPV video projects are now rarely discussed.

RC-CAM.com (main site and forum) will be closing down August 2021. This was announced several months ago (March 2021) to allow our members ample time to download any information that is important to them. After the site is shutdown the information will no longer be available here.

We appreciate every member's involvement with advancing the FPV hobby. It is indeed sad to say goodbye to all our online friends. Be safe and stay healthy.

YouTube Live Stream :: Turtle Camera


Recommended Posts

Perhaps you've noticed the growing popularity of personal live streaming video channels. Thanks to YouTube and some connected webcams there's plenty of romping kittens, wilderness animals, and vacation beaches to watch in real-time.

My interest in video camera projects isn't just FPV/drone related and it was only natural for me to get on the live stream bandwagon. That is to say, now our family pet turtle (named Polly) has the starring role on a reptile's version of The Truman Show. Family and friends can now spy on Polly-the-turtle whenever they want.


Here's a YouTube video from the PollyCam webcam: (Click Image Below)

Live Stream Video

Being a DiY guy, I rolled up my sleeves and built my own video streaming system called PollyCam. The project's hardware (WiFi IP camera & video encoder) is under $150 US and the software is free. A reliable broadband internet connection with a generous monthly data usage plan is needed too.

In case any of you are interested in the technical aspects of this project then you're in luck. Stick around and I'll do my best to explain how to build it.

Link to comment
Share on other sites

There's a number of ways to connect your personal camera to YouTube Live. A typical installation uses a USB webcam attached to a computer running some encoding software. But my camera is installed outdoors in a weather exposed area near the pond. So I needed a weatherproof WiFi IP security camera that would communicate to a remotely mounted computer installed inside my house.

There are plenty of outdoor security cameras to choose from which can make selecting one a daunting task. I took a chance on a low cost ($80 US) Chinese brand. The camera is a Foscam FI9900P that is rated for 1080P resolution. I'm using its 720p resolution mode and the image quality is nice; The 720p bandwidth requirements are an acceptable match for my encoding hardware and broadband connection.


The Foscam camera supports RTSP (Real Time Streaming Protocol) over its WiFi connection. But YouTube Live needs RTMP encoding (Real-Time Messaging Protocol). So this created a square peg and round hole conundrum. Fortunately a $40 US computer module and some free software provides the necessary transcoding that converts RTSP to RTMP.

The computer I'm using is a RaspBerry PI 3 (RPI3) Model B. I already have two of these handling my VoIP phone system (freepbx) and home automation (openhabian).


Rather than add another RPI3 dedicated for the video encoding task, I installed the encoding software on my home automation RPI3. It was a risky decision because the video encoding task consumes a lot of CPU resources.

With video encoding and home automation running the CPU loading can vary (depending on amount of motion in the video image) from 50% to 90% utilization. Because of the demands on CPU processing the RPI3's temperature can get quite hot, so a heatsink/fan kit is necessary. Plus operating current is greater than a typical RPI3 installation, so a high current power supply is necessary. I purchased a $17 case / accessory kit that had all these items in it.


I should mention that a dedicated RPI3 for YouTube streaming is perhaps a better way to go. I have plans to do that when time permits. But so far running the video encoder and home automation on the same RPI3 is working OK, so I'm in no hurry to upgrade it.

I appreciate the RPI3's low cost and tiny size. I use them in headless mode, which means I don't install a keyboard or monitor. So the overall footprint is not much larger than a deck of cards. It has built-in Wi-Fi too, but to ensure reliable connectivity it is wired with a CAT5 cable to a Ethernet hub that is plugged into a 2.4GHz WiFi router.

The router, hub, and RPI3 are shelf mounted in a coat closet inside the house. It's about 150 feet to the wireless IP camera that is hiding in a "birdhouse" above our backyard pond.


Link to comment
Share on other sites

A micro SD memory card is needed for the RPI3's operating system. My experience with running RPI (Raspberry Pi) based systems has taught me to avoid regular SD cards. For reliability I've switched to "high endurance" rated cards. My go-to choice at the moment is the Transcend 16GB TS16GUSDHC10V.

The SD Card needs the Raspian operating system. As I mentioned earlier, I am using an existing RPI3 that has been running my home automation system. It was built a couple years ago and has a Raspian OS that is based on Debian 8 ("Jessie"). There are newer OS versions available for download (all at no cost) that are slightly different. For example, the latest version is Debian 9  ("Stretch").

The Raspian OS version will make a difference. For example, RTSP to RTMP encoding is usually done with a program called ffmpeg. It's available on some Raspian releases. But my Debian 8 OS was released with an alternate encoder called avconv, so that is what I used in this project.

The two programs (ffmpeg & avconv) are said to be identical but I found that there are some nuances that can get in the way. If you are attempting to duplicate this project, and want to avoid unexpected frustrations, then install Raspbian Debian 8 (because it supports the avconv encoder that is used by PollyCam).

There's no need for me to explain how to install Raspian on the SD card. It's well documented online, plus YouTube is full of helpful videos.

After you have installed the OS, and setup the wired Ethernet connection, you can go "headless" by removing the keyboard and monitor. In their place I use two programs (to remotely access the RPI3) called WinSCP and PuTTY on a Windows PC. It's a very clever way to reduce the hardware clutter.

Link to comment
Share on other sites

Now that the RPI3 has an operating system it's time to install the video encoder software. As mentioned earlier, my RPI3 OS is Debian 8 (Jessie). It directly supports the encoder called "avconv" that is distributed in the apt-get package called libav-tools (libav is a fork of FFmpeg).

The avconv (libav-tools) encoder must be downloaded and installed.  My RPI3 is headless (without keyboard & monitor) so I use the PuTTY program on my WIN10 desktop PC to do this. But if you're not interested in trying out PuTTY then attach a keyboard and HDMI monitor and use them to access the RPI's command line (built-in console terminal).

To install libav-tools, enter the following text on the RPI3's command line:

apt-get install libav-tools 

Then hit Enter and wait a few minutes for the entire file package to download, unpack, and install.

All the hard stuff is out of the way. We're not done yet, but congratulations on getting this far.


Link to comment
Share on other sites

Before we can finish up the RPI3 installation the WiFi camera has to be configured. As mentioned, I am using a Foscam FI9900P. So all my camera setup instructions will be specific to it.

Because the camera will be connected by WiFi I installed its smart phone app (free download from Foscam/Google Play). The nice thing about this app is that it uses a P2P function so that you can scan the QR code (on the camera's printed label) to setup the WiFi connection.  You will be prompted to assign a user name and password. The built-in WiFi scanner function will find your router so your can enter its SSID password. Complete the camera's WiFi setup before proceeding.

At this point your camera is connected to your local network via a WiFi router.

Using your PC's browser (Windows or MAC), go to the Foscam site and download the Equipment Search Tool program. Run the tool and record the camera's IP address:port and 12-digit MAC ID. As an alternative to the Foscam tool you can also find the IP/MAC by accessing your router's DHCP Client table. Or use your favorite method to determine the IP and MAC of a new WiFi device. BTW, the Foscam camera's default port number is 88.

The camera supports direct access from a web browser. Internet Explorer is best, but you can use others. So launch your favorite browser and enter the camera's IP address and port number (IP:port) as the URL. The URL will look something like this (but revise it to match your values):

Install the Web Component add-on when prompted by your browser; Your browser needs it to access the camera. At this point your browser should be able to access your camera's live view and its settings page.

Click the Settings Page tab and choose the Video->Video Settings configuration screen. Use the Stream Type pulldown and choose the User-Defined entry. Change it to 720P resolution, 2M bit rate, 10 Frames, 30 Key Frames, VBR rate control. Click Save.

See screenshot below:



Now click the Live Video tab and choose Outdoor Mode, User-defined Stream, WDR On, NAA Off. The live video image is now configured for 720P video that will be used by your YouTube Live channel. See Screenshot below:


Now is a good time to access your router's administration function and reserve the DHCP IP address (create static IP) for the camera. Why do this? Configuring your router so that the camera uses a static local IP will ensure that the IP assignment does not change if the router is rebooted. It's not mandatory, but no doubt will reduce future frustrations.

There's a bit more to do, so don't relax yet. 

Link to comment
Share on other sites

It's time to setup your YouTube live streaming channel. If you're not currently a registered YouTube user then don't worry. All you need is a Google or Gmail account to access YouTube's free video hosting.

Instructions for setting up your YouTube Live Stream are posted here:

In case it helps, here's a random video I found on YouTube that explains how to set it up.

Keep in mind that I don't use the Live Stream Events feature that is discussed in the video. For PollyCam the Stream Now section is all that needs to be configured.

When you have completed setting it up you'll be provided a Server URL and Stream Name/Key (found in the Encoder Setup area of your Stream Now page). These are private text strings (do NOT share them). They are used to configure the RPI3's avcon program, so feel free to copy them into a text file for easy retrieval.

Link to comment
Share on other sites

All the necessary pieces to creating your YouTube Live Stream are now in place. It's time to stream!

Here's the avconv command for running the live stream video encoder on your Raspberry Pi3 (RPI3):

avconv -rtsp_transport tcp -y -i rtsp://FOSCAM_USERNAME:FOSCAM_PASSWORD@FOSCAM_IP:FOSCAM_PORT/videoMain -vcodec libx264 -preset veryfast -maxrate 2000k -bufsize 4000k -vf "format=yuv420p" -g 10 -acodec libmp3lame -b:a 128k -ar 44100 -f flv -s 1280x720 YOUTUBE_SERVER_URL/YOUTUBE_STREAM_NAMEKEY

But before you use the avconv command you must substitute the values for the following parameters:

FOSCAM_USERNAME: The admin login name for your Foscam camera.
FOSCAM_PASSWORD: The admin password.
FOSCAM_IP: The local IP to your camera.
FOSCAM_PORT: The port number to your camera (default is 88).
YOUTUBE_SERVER_URL: The server URL value provided by your Live Stream account.
YOUTUBE_STREAM_NAMEKEY: The stream name/key value provided by your Live Stream account.

Type the avconv command (with your specific camera and YouTube parameters) into your RPI3 and press Enter. Within 30 seconds the camera's real-time video should appear on your YouTube Live Stream web page. Congratulations, you're now broadcasting live video on your YouTube channel!

Since your live stream system is now up & running this could be the place where we go our separate ways. However, I encountered some unexpected streaming problems that will probably haunt you too. 

For example, broadband slowdowns (data throttling) may cause YouTube to terminate the current live stream connection and require you to restart it. Or maybe your broadband internet account has limited data usage allocations and live streaming is quickly eating it up. Or perhaps you're running your RPI3 in headless mode and you don't want a full time ftp connection to the RPI3.

These situations can be solved with some custom bash script files. I'll share the scripts I wrote in case they help you too.


Link to comment
Share on other sites

Several bash script files have been created to assist PollyCam's video stream process. They will be stored in the default pi user home directory.
The full path we will use is /home/pi/avconv.

Note: If you operate under a different user ID then please revise the home directory path (to suit your user name) and edit the bash files so that the paths referenced in them are accurate. Please be aware that the bash files are unix text formatted (linefeeds only, without carriage returns). Any future edits to them MUST use Unix style formatting. The Raspian "nano" editor is a typical choice for this. I use notepad++ with Edit->EOL Conversion set to Unix(LF).

Begin by creating the avconv directory:

mkdir /home/pi/avconv

Using your preferred method, copy the following bash script files to the /home/avconv directory:

  cpu_status: cpu_status
  pollycam_launch: pollycam_launch
  pollycam_run: pollycam_run
  pollycam_start: pollycam_start
  pollycam_stop: pollycam_stop

Use the chmod command to allow command execution of the bash files:

chmod 755 /home/pi/avconv/*

The bash files are now ready for use. As a test, run the cpu_temp program (display CPU temperature) and confirm it works. You must include the full path when you run it, as follows:


After you see it working you can end the program with CTRL-Z.


Link to comment
Share on other sites

The two main Live Stream scripts to use are:

pollycam_stop: Terminates ALL PollyCam Youtube Live Stream processes that may be running. Run this script to turn off live streaming whenever you are done broadcasting. Also, always run this script BEFORE making any changes to the other PollyCam scripts.

pollycam_launch: This is the main script that launches PollyCam streaming for unattended operation. It runs as a background process. You may exit the terminal command shell window (live streaming processes will continue to run without the terminal window).

The sub-scripts used by the main pollycam_launch processes are:

pollycam_run: This is a sub-script that is called by pollycam_launch. Its purpose is to restart the avconv process whenever the RTSP connection is lost due to random broadband data throttling, camera WiFi signal loss, or just about anything else that interferes with the YouTube video stream connection.  For useful debugging messages this script can be executed on its own. Note: run pollycam_stop BEFORE using pollycam_run.

pollycam_start: This is a sub-script that is called by pollycam_run. It starts the PollyCam Youtube Live Service using avconv. Runs as background process. BE SURE TO EDIT THE FILE AND ENTER YOUR FOSCAM CAMERA AND YOUTUBE LIVESTREAM PARAMETERS.


The utility scripts are:

cpu_status: Displays CPU temperature and CPU throttle state that is reported by raspian's vcgencmd function. Useful for determining if the RPI3's power supply has intermittent voltage sag problems or if the CPU cooling is adequate. This is especially critical when streaming due to the video encoder's high process loading. I suggest that you periodically run the cpu_status script while pollycam_launch is running to monitor your CPU's health.

Note: CPU Throttle status data should always be 0x0, otherwise you have under-voltage or over-heating problem (and video streaming will not be reliable). Details to the vcgencmd throttle value is found here: https://goo.gl/Dg1U2V

cpu_temp: Displays CPU temperature only.


Link to comment
Share on other sites

That's all the important details to building and running the PollyCam live stream system.  Hopefully the information has been helpful. But as a bonus I have a few more comments / tips to share:

Avoid Excessive Data Usage

Besides sending the live stream to YouTube, I had three computers continuously showing the YouTube feed. It was fun watching our turtle and live chatting with visitors.

After a few days of using the PollyCam I checked my broadband provider's site to see how much internet data our account was using. I discovered that data usage had wildly increased and was about to cost me a fortune if I didn't do something ASAP.

My solution? To reduce the daily data usage I changed the RTMP bit rate and cut hours of operation. I also stopped continuously showing the live stream on the three computers. These things combined made a dramatic reduction to data usage and avoided expensive data overage penalty fees.

Reduce Bit Rate

Reducing the RTMP bit rate will affect image quality. But many viewers are watching a small screen (smart phone or tablet) so they will rarely notice the lower resolution.

This is an easy adjustment. I ran pollycam_stop and terminated the stream. Then I edited the pollycam_start file and changed maxrate to 1000k (was 2000k). I also changed bufsize to 2000k (was 4000k). Then I ran pollycam_launch to restart the stream. No changes were made to the Foscam camera settings.

Schedule Hours of Operation

Instead of streaming 24 hrs a day I setup cron jobs to start and stop the stream so it only ran from 6AM to 8PM (daylight hours). As follows:

Begin by copying a new bash file to the RPI's /home/pi/avconv directory: pollycam_reboot

Next, edit the system's cron file by entering this command:

sudo crontab -e

In the file find this line at the bottom:

# m h  dom mon dow   command

And append / change as follows:

# m h  dom mon dow   command
 0 20  *   *   *   /bin/bash /home/pi/avconv/pollycam_stop   >> /home/pi/avconv/cron.log 2>&1
 0 06  *   *   *   /bin/bash /home/pi/avconv/pollycam_launch >> /home/pi/avconv/cron.log 2>&1
 @reboot           /bin/bash /home/pi/avconv/pollycam_reboot >> /home/pi/avconv/cron.log 2>&1

Save the cron file. It is a special "temporary" cached file that will be automatically applied to the system cron job scheduler. Two of the jobs will be run at the specified time of day. The third cron job is handled by pollycam_reboot and it is run during system reboot; Please view the file to understand what it does.

BTW, each executed cron job will add a timestamp to the text based cron.log file. The log is useful for troubleshooting cron problems.


Link to comment
Share on other sites

And one last thing. I'm happy to report that PollyCam can be easily adapted for use on systems that use ffmpeg. Here's the details to the validation:

A Raspberry PI 3 model B+ was loaded with the latest Raspian Debian 9 (Stretch) image. This OS version has ffmpeg instead of avconv. So I installed ffmpeg on it too.

But before installing the PollyCam bash files I changed EVERY instance of the word avconv to ffmpeg in them. The modified files were saved in a new user directory named /home/pi/ffmpeg

That's all it took and it works great. It's good to know that PollyCam is avconv and ffmpeg compatible. Enjoy!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...