| Live Streaming Video using AVConv and the Raspberry Pi Live Streaming Video using AVConv and the Raspberry Pi –

Live Streaming Video using AVConv and the Raspberry Pi

The Raspberry Pi is a credit-card sized $35 computer that can be used to accomplish many tasks similar to what a desktop PC can do. This includes spreadsheets, word-processing, games, and even…live video broadcasting! By connecting a powered USB Hub and webcam to your Raspberry Pi, you can broadcast live video to an unlimited audience for free. I’ll show you how this is possible.

Please be patient and read through the entire tutorial before attempting.

What You NeedCredit:

Getting started requires a few peripherals. To start up your Raspberry Pi and do initial configuration, you will need an HDMI cable, USB keyboard, and USB mouse. In addition:


  • Use the raspberry pi “headless”. Do not run the desktop version of Rasbian on your Pi (xwindows). It uses an excess amount of RAM and precious CPU power that you need to reserve for your live video compression and streaming. Instead, use the command line interface or access via Secure Shell from another computer. (optional)

  • Assign a static local IP to the Raspberry Pi. (Configuration can be found in: /etc/network/interfaces). This is useful when accessing the Pi remotely. (optional)

  • Don’t use a Raspberry Pi enclosure that limits heat transfer and airflow.


Update your software repository to the latest version by running the following commands:

sudo apt-get update
sudo apt-get upgrade

Plug in your devices.  Webcam –> Powered USB Hub –> Raspberry Pi

Install Screen (optional):

apt-get install screen

Restart your Pi device:



To transcode and broadcast the video, you will need to use a Linux application called AVConv (similar to FFmpeg). It is a command line program for transcoding multimedia files using the Libav Multimedia Framework. FFmpeg will give you the same result, but I personally prefer AVConv for ease-of-use.

To Install AVConv, run the following command:

sudo apt-get install avconv

Find a Broadcasting Platform:

To broadcast live streaming video to the Internet, you will need to create an account with Ustream,, or similar. After creating an account, it’s important you find the “Stream Key” or “Stream URL”.

Find the Stream URL and Key in Ustream:

  • Login to

  • Open your “Dashboard”

  • Click “Remote”

  • Copy the “RTMP URL”. You will need this once you begin broadcasting, in the next step of this tutorial.

Here is an example of the final URL:


Find the Stream URL and Key in Justin.TV:

  • Login to

  • Go to the “Other” Broadcasting page:

  • Press “Show” beside “Stream Key”

  • Save this Key! You will need it in the next step.

  • Paste your “Stream Key” in immediately after this URL:  rtmp://

    • Note: The Default RTMP server is hosted in San Francisco. On the Justin.TV forum, you can find the RTMP address URLs for a server that is closer to you. (optional)

Here is an example of the final URL using the default URL:


Save these URLs for the next step!

Broadcast Configuration

Once you have everything set up, command-line access to the Raspberry Pi, and your Stream Key URL, you’re ready to initiate the broadcast! This is the fun part!

From this point forward, you only have to input TWO commands.

  • Open a new screen session:


  • Enter the AVConv command with ALL of the parameters attached.

Basic command:

Enter this single command inside the screen session to start broadcasting! Yes, it’s that easy!

avconv -f video4linux2 -s 640×360 -r 10 -b 350k -i /dev/video0 -f flv rtmp://

In the above example,

  • -s defines the broadcasting resolution. (Widescreen = 640×360)

  • -r defines the maximum frame-rate

  • -b defines the maximum bitrate (k= Kbps)

  • -i defines the location of your USB webcam. In most cases, if you only have one USB video device plugged in, use the /dev/video0 phrase.

  • -f defines the type of video stream and location. In this example it’s FLV transcoding (Flash video) to an RTMP server at

  • Don’t forget to replace the rtmp:// URL with your own Stream Key URL from the “Find a Broadcasting Platform” step.


An advanced example: (Warning: for experienced users only)

avconv -f video4linux2 -s 640×360 -r 10 -b 350k -i /dev/video0 -vf drawtext=”fontfile=/usr/share/fonts/truetype/freefont/FreeSansBold.ttf:text=’some text here ‘:fontsize=16:fontcolor=blue:x=2:y=360″ -acodec copy -metadata title=”24×7 Pi Cam” -f flv rtmp://

The above example is what I use on my “Eric’s Pets” live stream. You may notice a big difference from the original AVConv command. The -vf drawtext command allows you to define a font (download to your /freefont/ folder). Once a font is defined, you can add formatted text such as a “watermark” in the bottom left. The “-metadata title” allows me to tell Justin.TV what the broadcast page title should be. It can even get more advanced than this!

Please be very patient with AVConv and Raspbian. It takes time to perfect the stream quality. (My settings may not work for your camera or setup).

AVConv is very similar to FFmpeg in this sense. You can add many different features to your live video broadcast by simply putting new parameters in your initial command. You can learn more about these by reading AVConv/FFmpeg documentation.

AVConv will provide information while streaming, similar to the following string. If you see this, the stream should be broadcasting correctly.

Eric's Live Bunny Cam via Raspberry Pi

Eric’s Live Bunny Cam via Raspberry Pi

   Stream #0:0 -> #0:0 (rawvideo -> flv)

frame=215  fps=8   q=15.5   size=1001kB   time=29.20  bitrate=281.0kbits/s  dup=0   drop=3   

At any time, you can stop the stream by typing Ctrl-C, and exit the screen session by typing “exit”. To close the screen session but leave AVConv running, type Ctrl-A-D. To enter a screen session that’s already running, type “screen -r”.

Still hungry? Learn more at

Let me know what the next blog post should include!

25 comments on “Live Streaming Video using AVConv and the Raspberry Pi
  1. Awesome work! Now I have a use for my Pi! It’s just sitting in the closet gathering dust, but I have an unused webcam, so this will happen!

  2. This is just what I have been looking for … AFTER following another
    tutorial which did not work out .. it was/is outdated and was for
    Bambuser. Here is my problem … that tutorial said to do a GIT for
    FFmpeg which I did. I now have some kind of ‘hybrid'(?) FFmpeg. I
    really don’t want to install any more software … so this would be
    perfect IF it explained for FFmpeg rather than avconv. Any chance of
    that happening …. PLEASE?? I am a rookie w/ Linux, Raspberry, etc.

    • In my experience, AVConV works much better. FFMPeg uses the same commands though so you’re free to install and use it instead. What’s wrong with using avconv though?

      Good luck!

      • The only thing ‘wrong’ is my inexperience. I know from the other tutorial I have FFmpeg and I TRY to not install more than I actually need (storage space ‘phobia’). Thought it prudent to use what I have. I have no idea how much space AVConV takes up.

        Great tutorial. Would like to try it w/ FFmpeg … I have minimal needs for streaming. Not sure how … to use your tutorial but with FFmpeg/ustream. I assume by substituting avconv code with FFMpeg(?), but knowing my concerns, happy to take your advice. Let me know what you think (maybe you already have), and I will go with whatever you say. Thank you for your reply.

  3. “avconv -f video4linux2 -s 640×360 -r 10 -b 350k -i /dev/video0 -f flv rtmp://”

    for USB cam. How so for raspicam? Don’t see raspicam in /dev.

    • If your camera isn’t showing up in /dev/, you can change the location to match.

      Sorry, This tutorial is for USB webcams (such as the Logitech HD type). Good luck!!


      • Thank you, Mr. Eric. Sorry to be a pain. I have tried so many tutorials .. and failed. I did not know raspicam is not in /dev. I really don’t know where it is, but have asked in the raspicam forum. Hopefully I just need to point the command to it. I will also employ AVConV as advised. Thank you for your courtesy and patience.

    • There won’t be any sound using this tutorial.
      In the future, I hope to write a tutorial explaining how to add sound. If you check the LibAV docs, you can see the symbol that defines audio – I think you can easily loop a file, and hopefully play a stream. Good luck!

  4. Nice!! But what about if I have a video and I want to share it in lan (broadcast)?
    I use:
    avconv -i -c:v libx264 -f mpegts udp://DEST_IP:1234

    but if I want to specify a range of IP??

  5. Hi TechZany

    I follow you step but got this error from justin tv

    RTMP_Connect0, failed to connect socket. 110 (Connection timed out)

    rtmp:// Operation not permitted

  6. now I can fixed below error with this server rtmp://

    but I got new issue

    Attention! We are making changes to our video infrastructure. Your broadcast settings will be incompatible with this new system.

    Reason 1: Video codec must be set to h.264 (it is currently “CodecId_SorensonH263”). Click here to fix the problem.

    Reason 2: Audio codec must be set to MP3 or AAC (it is currently “unknown”). Click here to fix the problem.

    how can i solve this problem?


  7. Hey techzany
    please help me im facing this problem
    [video4linux2 @ 0x17c9740] ioctl(VIDIOC_STREAMON): Broken pipe

    /dev/video0: Broken pipe

Leave a Reply

Your email address will not be published. Required fields are marked *