Created
December 16, 2010 00:25
-
-
Save revmischa/742831 to your computer and use it in GitHub Desktop.
Build and install libx264, libav and rtmpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script fetches and builds libx264, libav, rtmpd and their dependencies. | |
# you may have to add /usr/local/lib to /etc/ld.so.conf | |
# BASEDIR = build directory (default current dir) | |
# PREFIX = install directory (default /usr/local) | |
if [ -z "$BASEDIR" ]; then | |
BASEDIR=`pwd` | |
fi | |
if [ -z "$PREFIX" ]; then | |
PREFIX="/usr/local" | |
fi | |
# install some deps | |
sudo aptitude -y install libmp3lame-dev libfaac-dev build-essential cmake subversion libtinyxml-dev \ | |
liblua50-dev libvorbis-dev libssl-dev || exit 1 | |
# grab YASM | |
cd $BASEDIR | |
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz | |
tar -xvf yasm-1.2.0.tar.gz | |
cd yasm-1.2.0 | |
./configure --prefix=$PREFIX && make && sudo make install | |
# grab librtmp | |
cd $BASEDIR | |
git clone git://git.ffmpeg.org/rtmpdump rtmpdump | |
cd rtmpdump | |
make && sudo make install | |
# grab libfaac (currently broken) | |
cd $BASEDIR | |
wget http://downloads.sourceforge.net/faac/faac-1.28.tar.bz2 | |
tar -xvf faac-1.28.tar.bz2 | |
cd faac-1.28 | |
./configure --prefix=$PREFIX && make && sudo make install | |
# grab libvpx | |
cd $BASEDIR | |
git clone http://git.chromium.org/webm/libvpx.git libvpx | |
cd libvpx | |
./configure --prefix=$PREFIX --enable-shared --enable-vp8 --enable-pic | |
make && sudo make install | |
# grab libtheora (need encoder, debian package doesn't provide it) | |
cd $BASEDIR | |
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 | |
tar -xjf libtheora-1.1.1.tar.bz2 | |
cd libtheora-1.1.1 | |
./configure --with-shared --prefix=$PREFIX && make && sudo make install | |
# fetch latest libx264 and build (ignoring installed libav) | |
cd $BASEDIR | |
echo "Fetching x264..." | |
git clone git://git.videolan.org/x264.git | |
cd x264 | |
echo "Building x264 without libav..." | |
./configure --prefix=$PREFIX --enable-pic --enable-shared --disable-lavf && make && sudo make install | |
# fetch libav and install | |
echo "Fetching libav..." | |
cd $BASEDIR | |
#wget http://libav.org/releases/libav-0.8.tar.gz | |
#tar -zxf libav-0.8.tar.gz | |
git clone git://git.libav.org/libav.git libav | |
#cd libav-0.8 | |
cd libav | |
echo "Building libav..." | |
sudo ldconfig | |
./configure --prefix=$PREFIX \ | |
--enable-libmp3lame --enable-librtmp --enable-libx264 \ | |
--enable-libfaac --enable-libvorbis \ | |
--enable-pic --enable-shared \ | |
--enable-gpl --enable-nonfree \ | |
--enable-libtheora \ | |
--enable-libvpx \ | |
&& make && sudo make install && echo "libav installed" | |
sudo ldconfig | |
# now we must rebuild libx264 with our version of libav | |
cd $BASEDIR/x264 | |
echo "Building x264 with libav..." | |
./configure --prefix=$PREFIX --enable-pic --enable-shared && make && sudo make install && echo "libx264 installed" | |
# RTMPD | |
BUILD_RTMPD_FROM_SRC=0 # build process is mega broken | |
if [ $BUILD_RTMPD_FROM_SRC ]; then | |
# fetch latest rtmpd and build | |
echo "Fetching rtmpd..." | |
cd $BASEDIR | |
RTMPD_REV=717 | |
wget http://www.rtmpd.com/assets/sources/crtmpserver-${RTMPD_REV}.tar.gz | |
tar -zxf crtmpserver-${RTMPD_REV}.tar.gz | |
mv crtmpserver-${RTMPD_REV} rtmpd | |
cd rtmpd | |
cd builders/cmake | |
# fix brain-dead 64-bit libopenssl path | |
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64 | |
cmake . && make && echo "rtmpd built" | |
# create script to run rtmpd | |
cd $BASEDIR | |
echo "#!/usr/bin/env bash | |
# run rtmpd | |
cd rtmpd/builders/cmake | |
rtmpserver/rtmpserver $BASEDIR/rtmpd_int80.lua | |
" > run_rtmpd.sh | |
chmod +x $HOME/run_rtmpd.sh | |
else | |
# get rtmpd binary | |
# get package built for 64-bit | |
echo "Fetching rtmpd..." | |
cd $BASEDIR | |
wget http://int80.biz/static/dist/rtmpd-747.tar | |
tar -vxf rtmpd-747.tar # extracts to rtmpd | |
# create script to run rtmpd | |
cd $BASEDIR | |
echo -e "# run rtmpd\ncd $BASEDIR/rtmpd\n./rtmpd $BASEDIR/rtmpd_int80.lua\n" \ | |
> $HOME/run_rtmpd.sh | |
chmod +x $HOME/run_rtmpd.sh | |
fi | |
# create rtmpd config | |
echo ' | |
configuration= | |
{ | |
daemon=false, | |
pathSeparator="/", | |
logAppenders= | |
{ | |
{ | |
name="console appender", | |
type="coloredConsole", | |
level=4, -- 0-6 | |
} | |
}, | |
applications= | |
{ | |
rootDirectory="applications", | |
{ | |
-- handles RTMP for clients | |
description="Client", | |
name="appselector", | |
protocol="dynamiclinklibrary", | |
mediaFolder="", | |
default=true, | |
validateHandshake=false, -- needed for rtmps | |
acceptors = | |
{ | |
{ | |
ip="0.0.0.0", | |
port=1935, | |
protocol="inboundRtmp" | |
}, | |
{ | |
ip="0.0.0.0", | |
port=1936, | |
protocol="inboundRtmpt" | |
}, | |
{ | |
ip="0.0.0.0", | |
port=1937, | |
protocol="inboundRtmps", | |
-- sslKey="srv.key", | |
-- sslCert="srv.crt" | |
} | |
} | |
}, | |
{ | |
description="FLV Playback", | |
name="flvplayback", | |
protocol="dynamiclinklibrary", | |
mediaFolder="", | |
aliases= | |
{ | |
"live", | |
}, | |
acceptors = | |
{ | |
{ | |
ip="0.0.0.0", | |
port=6666, | |
protocol="inboundLiveFlv", | |
waitForMetadata=true, | |
}, | |
{ | |
ip="0.0.0.0", | |
port=9999, | |
protocol="inboundTcpTs" | |
}, | |
{ | |
ip="0.0.0.0", | |
port=9999, | |
protocol="inboundUdpTs" | |
}, | |
--[[{ | |
ip="0.0.0.0", | |
port=7654, | |
protocol="inboundRawHttpStream", | |
crossDomainFile="/tmp/crossdomain.xml" | |
}, | |
{ | |
ip="0.0.0.0", | |
port=554, | |
protocol="inboundRtsp" | |
},]]-- | |
}, | |
} | |
} | |
} | |
' > $BASEDIR/rtmpd_int80.lua | |
# get some html/js/flash files | |
git clone git://github.com/revmischa/simplestream.git simplestream | |
./run_rtmpd.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment