Beier Cai

Vancouver, BC, Canada
RSS icon Email icon Home icon
  • Accurate Counting with Graphite and Statsd

    Posted on March 7th, 2013 Beier Cai No comments

    (This is a re-post from my Employer HootSuite’s Devblog by Geordie Henderson)

    We have been using statsd and Graphite at HootSuite to get visibility into the frequency of events within our technology stack for over a year now. And to great effect.

    In real time we are able to see the health of the HootSuite dashboard, supporting services, the myriad APIs our product uses and get to better understand things like our payments systems. Visibility has reduced downtime, made us more responsive to performance problems and generally forced us to confront more technical debt than we otherwise might have.

    Continue…

  • Why we love and use ZeroMQ at HootSuite

    Posted on March 5th, 2013 Beier Cai No comments

    (This is a re-post from my Employer HootSuite’s Devblog)

    At HootSuite we are always on the lookout for technologies that will make our product better.

    Recently we started exploring ZeroMQ (aka. ØMQ, 0MQ, ZMQ). In this post, I will describe why ZeroMQ fits right into our technology stack.

    ZeroMQ is often bundled into a class of products with RabbitMQ and others that use Asynchronous Message Queuing Protocols (AMQP). After all, ZeroMQ has MQ in its name and both ZeroMQ and RabbitMQ were created by Pieter Hintjens. Be that as it may, grouping ZeroMQ with other AMQP products is not quite the right model for some key reasons.

    Continue reading…

  • Updated - Setup Red5 and FFMPEG on Ubuntu 8.0.4

    Posted on August 14th, 2009 Beier Cai No comments

    Red5 LogoThis an updated version of my previous post here. This version contains some of the latest software updates. Please note that this install may not work for 64bit system. If you can make it work for 64bit system, please let me know.

    Please note that a wrong software version could lead to compatibility issues, so I can’t guarantee it will work if you don’t download the version I specified in the instructions. This instruction is targeted to Ubuntu 8.04, but with some tweaks it should work for all linux O/S

    Setup Red5 v0.7.0 on Ubuntu Hardy 8.04

    Prerequisits

    Please note that while installing java-package, you need to force install and agree to Suns Java service agreement (F12 in command line, or click on yes if using package manager)

    sudo apt-get install java-package
    sudo apt-get install sun-java6-jdk
    sudo apt-get install sun-java6-jre
    export JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun/

    Download Red5 v0.7.0

    http://www.red5.fr/release/0.7.0/debian/red5_0.7.0_all.deb

    Install Red 5

    sudo dpkg -i red5_0.7.0_all.deb

    Once installed, you can start/stop/restart by:

    sudo /etc/init.d/red5 start|stop|restart

    Red5 is installed under the following directory by default:

    /usr/lib/red5

    To verify installation, use the port 5080 to test Red5:

    http://localhost:5080

    run some demo and make sure everything works

    Setup FFMPEG on Ubuntu Hardy 8.04

    First make sure the system is up to date

    sudo apt-get update
    sudo apt-get upgrade

    Prerequisites

    sudo apt-get install libjpeg-progs libjpeg62 libjpeg62-dev
    sudo apt-get install libsdl1.2-dev php5-dev build-essential
    sudo apt-get install unzip subversion ruby libcurses-ruby

    Make a dir for downloads and operations

    sudo mkdir /usr/local/ffmpegsource
    cd /usr/local/ffmpegsource

    Download software

    Unzip the downloaded files

    sudo tar zxvf lame-3.97.tar.gz
    sudo tar zxvf libogg-1.1.4.tar.gz
    sudo tar zxvf libvorbis-1.2.3.tar.gz
    sudo tar zxvf flvtool2-1.0.6.tgz
    sudo tar jxvf essential-20071007.tar.bz2
    sudo bzip2 -cd amrnb-7.0.0.2.tar.bz2 | sudo tar xvf -
    sudo bzip2 -cd amrwb-7.0.0.3.tar.bz2 | sudo tar xvf -
    sudo bzip2 -cd libtheora-1.0.tar.bz2 | sudo tar xvf -
    sudo tar jxvf ffmpeg-php-0.6.0.tbz2

    Use Subversion to checkout ffmpeg

    sudo svn co -r 19352 svn://svn.mplayerhq.hu/ffmpeg/branches/0.5 ffmpeg
    sudo svn co -r 29230 svn://svn.mplayerhq.hu/mplayer/branches/1.0rc3 mplayer

    Copy Codecs for mplayer

    sudo mkdir /usr/local/lib/codecs
    sudo mv /usr/local/ffmpegsource/essential-20071007/* /usr/local/lib/codecs/
    sudo chmod -R 755 /usr/local/lib/codecs/

    make tmp dir for mplayer
    sudo mkdir /usr/local/ffmpegsource/tmp
    sudo chmod 777 /usr/local/ffmpegsource/tmp
    export TMPDIR=/usr/local/ffmpegsource/tmp

    Install lame

    cd /usr/local/ffmpegsource/lame-3.97
    sudo ./configure
    sudo make && sudo make install

    Install  libogg

    cd /usr/local/ffmpegsource/libogg-1.1.4
    ./configure
    sudo make && sudo make install

    Install libvorbis

    cd /usr/local/ffmpegsource/libvorbis-1.2.3
    ./configure
    sudo make && sudo make install

    Install flvtool2

    cd /usr/local/ffmpegsource/flvtool2-1.0.6/
    sudo ruby setup.rb config
    sudo ruby setup.rb setup
    sudo ruby setup.rb install

    Install mplayer & mencoder

    cd /usr/local/ffmpegsource/mplayer
    sudo ./configure --enable-jpeg
    sudo make && sudo make install

    Install AMR

    AMRNB
    cd /usr/local/ffmpegsource/amrnb-7.0.0.2
    ./configure
    sudo make && sudo make install

    AMRWB
    cd /usr/local/ffmpegsource/amrwb-7.0.0.3
    ./configure
    sudo make && sudo make install

    Install libtheora (for ogg video encoding)

    cd /usr/local/ffmpegsource/libtheora-1.0
    ./configure
    sudo make && sudo make install

    Install ffmpeg

    cd /usr/local/ffmpegsource/ffmpeg/
    sudo ./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libtheora
    sudo make
    sudo make install
    sudo ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
    sudo ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
    sudo ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
    sudo ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
    sudo ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
    sudo ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
    sudo ln -s /usr/local/lib/libamrnb.so.3 /usr/lib/libamrnb.so.3
    sudo ln -s /usr/local/lib/libamrwb.so.3 /usr/lib/libamrwb.so.3

    Install ffmpeg-php

    cd /usr/local/ffmpegsource/ffmpeg-php-0.6.0/
    phpize
    ./configure
    make
    make install

    modify php.ini to load ffmpeg-php and restart apache
    sudo vim /etc/php5/apache2/php.ini
    extension=ffmpeg.so (add this line to the end of the file)
    sudo /etc/init.d/apachpe2 restart

    Test your ffmpeg setup

    There are many ways to test your ffmpeg setup such as using command line. But using the PHP class phpvideotoolkit to test your setup and quick and easy.

    You can download the toolkit at:

    http://www.buggedcom.co.uk/

    Run the examples provided and see if everything works as expected.

    Note that phpvideotoolkit may still use ‘mp3′ as -acodec option, you need to change it to ‘libmp3lame’

    That’s all. Hopefully this can help you save some time and any comment is welcomed!

    Resources

  • Setup Red5 and FFMPEG on Ubuntu 8.04

    Posted on February 20th, 2009 Beier Cai 3 comments

    Red5 Logo Recently my company asked me to work on a video related project that allows users to upload videos in various formats, record videos through a web cam, and of course play back those user generated videos. After some investigation I decided to use the combination of Red5 Flash streaming server and FFMPEG for video conversion (from different formats to FLV). Both are open source thus free of charge. However, setting up FFMPEG on Linux is nothing but a daunting task. Literally there are tens of software to install and their versions have to be the right combination. With some research and good tips from a few sources I was able to install it and compile this step-by-step instruction on setting up both Red5 and FFMEPG and hopefully it can save bunch of your time.

    Please note that a wrong software version could lead to compatibility issues, so I can’t guarantee it will work if you don’t download the version I specified in the instructions. This instruction is targeted to Ubuntu 8.04, but with some tweaks it should work for all linux O/S

    Setup Red5 v0.7.0 on Ubuntu Hardy 8.04

    Prerequisits

    Please note that while installing java-package, you need to force install and agree to Suns Java service agreement (F12 in command line, or click on yes if using package manager)

    sudo apt-get install java-package
    sudo apt-get install sun-java6-jdk
    sudo apt-get install sun-java6-jre
    export JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun/

    Download Red5 v0.7.0

    http://www.red5.fr/release/0.7.0/debian/red5_0.7.0_all.deb

    Install Red 5

    sudo dpkg -i red5_0.7.0_all.deb

    Once installed, you can start/stop/restart by:

    sudo /etc/init.d/red5 start|stop|restart

    Red5 is installed under the following directory by default:

    /usr/lib/red5

    To verify installation, use the port 5080 to test Red5:

    http://localhost:5080

    run some demo and make sure everything works

    Setup FFMPEG on Ubuntu Hardy 8.04

    First make sure the system is up to date

    sudo apt-get update
    sudo apt-get upgrade

    Prerequisites

    sudo apt-get install libjpeg-progs libjpeg62 libjpeg62-dev
    sudo apt-get install libsdl1.2-dev php5-dev build-essential
    sudo apt-get install unzip subversion ruby libcurses-ruby

    Make a dir for downloads and operations

    mkdir /usr/local/ffmpegsource
    cd /usr/local/ffmpegsource

    Download software

    Unzip the downloaded files

    tar zxvf lame-3.97.tar.gz
    tar zxvf libogg-1.1.3.tar.gz
    tar zxvf libvorbis-1.2.0.tar.gz
    tar zxvf flvtool2-1.0.6.tgz
    tar jxvf essential-20071007.tar.bz2
    tar jxvf ffmpeg-php-0.6.0.tbz2
    bzip2 -cd amrnb-7.0.0.2.tar.bz2 | tar xvf -
    bzip2 -cd amrwb-7.0.0.3.tar.bz2 | tar xvf -
    tar zxvf libtheora-1.0beta3.tar.gz

    Use Subversion to checkout ffmpeg

    svn co -r 17311 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
    svn co -r 28578 svn://svn.mplayerhq.hu/mplayer/trunk mplayer

    go to mplayer dir and run svn update:
    cd /usr/local/ffmpegsource/mplayer
    svn update

    Copy Codecs for mplayer

    sudo mkdir /usr/local/lib/codecs
    sudo mv /usr/local/ffmpegsource/essential-20071007/* /usr/local/lib/codecs/
    sudo chmod -R 755 /usr/local/lib/codecs/
    make tmp dir for mplayer
    sudo mkdir /usr/local/ffmpegsource/tmp
    sudo chmod 777 /usr/local/ffmpegsource/tmp
    export TMPDIR=/usr/local/ffmpegsource/tmp

    Install lame

    cd /usr/local/ffmpegsource/lame-3.97
    ./configure
    sudo make && sudo make install

    Install libogg

    cd /usr/local/ffmpegsource/libogg-1.1.3
    ./configure
    sudo make && sudo make install

    Install libvorbis

    cd /usr/local/ffmpegsource/libvorbis-1.2.0
    ./configure
    sudo make && sudo make install

    Install flvtool2

    cd /usr/local/ffmpegsource/flvtool2-1.0.6/
    ruby setup.rb config
    ruby setup.rb setup
    sudo ruby setup.rb install

    Install mplayer & mencoder

    cd /usr/local/ffmpegsource/mplayer
    ./configure --enable-jpeg
    sudo make && sudo make install

    Install AMR

    AMRNB
    cd /usr/local/ffmpegsource/amrnb-7.0.0.2
    ./configure
    sudo make && sudo make install

    AMRWB
    cd /usr/local/ffmpegsource/amrwb-7.0.0.3
    ./configure
    sudo make && sudo make install

    Install libtheora (for ogg video encoding)

    cd /usr/local/ffmpegsource/libtheora-1.0beta3
    ./configure
    sudo make && sudo make install

    Install ffmpeg

    cd /usr/local/ffmpegsource/ffmpeg/
    ./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libtheora
    sudo make
    sudo make install
    sudo ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
    sudo ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
    sudo ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
    sudo ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
    sudo ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
    sudo ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
    sudo ln -s /usr/local/lib/libamrnb.so.3 /usr/lib/libamrnb.so.3
    sudo ln -s /usr/local/lib/libamrwb.so.3 /usr/lib/libamrwb.so.3

    Install ffmpeg-php

    cd /usr/local/ffmpegsource/ffmpeg-php-0.6.0/
    phpize
    ./configure
    make
    make install

    modify php.ini to load ffmpeg-php and restart apache
    vim /etc/php5/apache2/php.ini
    extension=ffmpeg.so (add this line to the end of the file)
    sudo /etc/init.d/apache2 restart

    Test your ffmpeg setup

    There are many ways to test your ffmpeg setup such as using command line. But using the PHP class phpvideotoolkit to test your setup and quick and easy.

    You can download the toolkit at:

    http://www.buggedcom.co.uk/

    Run the examples provided and see if everything works as expected.

    That’s all. Hopefully this can help you save some time and any comment is welcomed!

    Resources