Introduction

In a previous post, I described how you could set up the Beaglebone Black to capture video and process video using OpenCV with the Logitech C920 camera. In this post I am going to look at how you can begin streaming data using the camera and code that I had adapted previously. The previous post is here and the final instructional page is here. I hope to follow this post up with a video shortly as soon as I address all of the issues I would like. I have also just released a post on how to stream video using UDP unicast and multicasting. I am going to view the video using VLC on a Windows 7 PC.cameraC920

Acknowledgement

This post is based heavily on work by William C Boner and OZ9AEC and I would recommend that you read the work on their blogs as there is plenty of information there on getting video streaming to work. I have adapted their work with slightly different code and hopefully I have helped make it more accessible for everyone. I will also extend their work in the next few posts.

Getting Started

Download the source code for my boneCV repository. This has the source code for everything that is discussed from here on down. Use:

To clone the repository to your local file system. All of the code is in this repository and the scripts necessary to stream the video are listed there too.

Next, I will look at a few different ways of streaming the video using avconv (ffmpeg) and the code that I had previously distributed through this repository.

Starting the RTP Stream

Step 1: Running the streamVideoRTP Script

Once you have downloaded the repository you can build the code by executing ./build which will result in an executable capture program in the boneCV folder. These steps are discussed in the previous posts that are linked in the Introduction above.

Edit the script streamVideoRTP to specify the IP address of the machine that will be playing the video. In my case it is a Windows 7 PC and I am going to use VLC. Here is my script:

You can see that the IP address of my Window 7 PC is 192.168.1.4 and I have randomly chosen port 1234.

Then execute the script streamVideoRTP by typing ./streamVideoRTP which will result in an output like in Figure 1.

streamVideoRTPFigure 1. Executing the streamVideoRTP

Step 2: Kill It!

Using ctrl-c kill the stream. We need the values that are listed under “SDP:” in the output to create the SDP file for VLC on our Windows Machine.

Step 3: Copy the Data into a file called BeagleboneRTPStream.sdp

  • Type echo “ at the command prompt and then select the text at the Linux prompt as described in Figure 2.

SelectingTextforRTP2

Figure 2. Typo echo “ and then select the text (as highlighted)

  • Then click your middle mouse button to paste the text at the command prompt. Finish the string using a ” > BeagleboneRTPStream.sdp and hit enter. This is captured in Figure 3.

SelectingTextforRTP3

Figure 3. Creating the sdp using the ./streamVideoRTP output

I have left my sdp file in the git repository so that you can see it and even edit it.

Step 4. FTP this file to/from your windows machine

I just use psftp from the Windows command prompt in my case as I have PuTTY installed on the Windows 7 machine. Place the file anywhere – I’ll just use the desktop (you can see my usage in the bottom-left of figure 4 below).

 Step 5. Start the Server

Just execute ./streamVideoRTP again! You should see it running at about 3Mbit/sec as before and it should be stable, giving you a consistent frame rate (visible on the bottom-right of figure 4 below).

 Step 6. Start VLC on the Windows/Linux ‘client’ Machine

The easiest way to do this is probably to double-click the SDP file on your desktop as it is likely associated with VLC if that is on your machine. If everything goes well you should see exactly what I have in Figure 4.

 

RTPFinalOutput

 

Figure 4. The final output – Press for high-resolution version

You should be able to see various points in this image:

  • VLC is running in the window on the top left and you can see a live video of one of my Beaglebones. I would like to make a video so that you can see the quality of this video and the excellent frame rate. There is a latency of about 1 second.
  • On the bottom left you can see how I used psftp (running on my Windows PC) to upload the SDP file from the Beaglebone to my PC.
  • On the bottom right you can see the RTP server running using the streamVideoRTP script
  • On the top right you can see top running, which gives the overhead of the capture and avconv applications.

Conclusions

I hope to make a video on this shortly as there are other elements that I would like to discuss. One important feature of this type of streaming is that the C920 is taking care of all video coding, a computationally very expensive operation. This means that the load on the Beaglebone is very light, as displayed in Figure 4. The total cost is about 12% CPU and 4% of memory.

I will follow this post up very shortly with a post on using UDP unicasting and multicasting to stream the video data.