Ffmpeg ustream broadcasting
A simple setup to see how well streaming from ffmpeg to ustream.tv works.
Tests are performed on a 32 bit Ubuntu Lucid machine:
First let's start clean but updated:
sudo apt-get remove ffmpeg x264 libx264-dev
sudo apt-get update
sudo apt-get install build-essential git-core checkinstall yasm texi2html libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev nasm libssl-dev
Get and install libx264
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --default --pkgversion="3:$(./version.sh | \
awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes
cd
git clone git://review.webmproject.org/libvpx
cd libvpx
#asm is out dated :(
./configure --disable-asm
make
sudo checkinstall --pkgname=libvpx --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no --default --deldoc=yes
Get and install rtmpdump
cd
svn co svn://svn.mplayerhq.hu/rtmpdump/trunk rtmpdump
cd rtmpdump
make
sudo checkinstall --pkgname=rtmpdump --pkgversion=2.3 --backup=no --deldoc=yes
Get and install libfaac
wget http://downloads.sourceforge.net/faac/faac-1.28.tar.bz2
Get and install lame
cd
wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz
tar xzvf lame-3.98.4.tar.gz
cd lame-3.98.4
./configure --enable-nasm --disable-shared
make
sudo checkinstall --pkgname=lame-ffmpeg --pkgversion="3.98.4" --backup=no --default --deldoc=yes
Get and install ffmpeg
cd
git clone git://git.videolan.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame --enable-librtmp
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(./version.sh)" --backup=no --deldoc=yes --default
Putting it all together
Ffmpeg support for Ustream is not supported. You'll need to go to your dashboard page in Ustream - Manage my channel - Advanced settings. You can download the Flash Media Encoder XML file. Inside this file you'll find the RTMP url and stream. From this you can create the command for ffmpeg. In order to stream without the webportal you can remove 'offair' from the RTMP stream. For example streaming a webcam with sound:
ffmpeg -v 5 -r 20 -s 320x240 -f video4linux2 -i /dev/video0 -f alsa -ac 2 -i pulse -acodec libmp3lame -ab 128k -ar 22050 -threads 0 -f flv $RTMPURL/$RTMPURL flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)
Here's my channel, it'll probably be offline most of the time, though
Streaming live video by Ustream
Notes
It works instantly in my setup to stream to Ustream.tv. However it quits after around 1700 frames. I don't know why but putting the command in a while loop works around the issue.
while true; do ffmpeg -v 5 -r 20 -s 320x240 -f video4linux2 -i /dev/video0 -f alsa -ac 2 -i pulse -acodec libmp3lame -ab 128k -ar 22050 -threads 0 -f flv $RTMPURL/$RTMPURL flashver=FMLE/3.0\20(compatible;\20FMSc/1.0); done
References
- http://ubuntuforums.org/showpost.php?p=9868359&postcount=1289
- http://blog.kyri0s.org/post/1406637341/free-live-video-streaming-with-http-live-streaming
- http://helpcenter.ustream.tv/content/broadcasting-higher-quality