Advertisement
Onryo

Ubuntu 10.10 & 11.04 - ffmpeg , x264 , VP8 auto install

Apr 25th, 2011
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 13.24 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. #######################################################################################
  5. ##  By Erik Adler aka Onryo.                                                         ##
  6. ##  This bash script will install the newest git of x264, VP8, ffmpeg & qt-faststart ##
  7. ##  This is for Ubuntu Maverick 10.10 and Natty 11.04                                ##
  8. ##  License for this script is copyleft.                                             ##
  9. ##  Just change the name of the homepath where you want your gits to sit.            ##
  10. #######################################################################################
  11.  
  12. homepath=/home/Onryo/git-svn
  13.  
  14.  
  15. #######################################################################################
  16. # Where we are getting our sources from
  17. GITx264=git://git.videolan.org/x264.git
  18. GITffmp=git://git.videolan.org/ffmpeg.git
  19. GITvp8=git://review.webmproject.org/libvpx
  20. vp8presets=https://code.google.com/p/webm/downloads/list
  21. #######################################################################################
  22.  
  23. clear
  24.  
  25. depends=0
  26. cpu_threads=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
  27.  
  28. if [ $# -eq 0 ]
  29.  
  30. then
  31.    echo
  32.    echo "           Install, Upgrading and Removing x264 and ffmpeg for Maverick & Natty"
  33.    echo "           --------------------------------------------------------------------"
  34.    echo
  35.    echo " [1] INSTALL x264 and FFmpeg. Makes A Clean Install"
  36.    echo " [2] UPGRADE x264 and FFmpeg and Dependencies"
  37.    echo " [3] Install FFmpeg's qt-faststart. Needs FFmpeg"
  38.    echo " [4] REMOVE Everything This Program Has Installed"
  39.    echo " [5] Exit"
  40.    echo
  41.    read pick
  42. fi
  43.  
  44. # makes sure a interger from 1 to 5 is used.
  45.  
  46. counter=1
  47. while [  $counter -eq 1 ]; do
  48.    if [ $pick -lt 1 -o $pick -gt 5 2>/dev/null ] || ! [ $pick -eq $pick 2>/dev/null ]; then
  49.       echo "Please enter 1-5 number ONLY"
  50.       read pick
  51.       counter=1
  52.    else
  53.       counter=0
  54.    fi
  55. done
  56.  
  57. clear
  58.  
  59. ########################### x264 #################################
  60. ##################################################################
  61.  
  62. # Checks it you have the newest version of x264 on your machine by
  63. # compairing with the x264 git server.
  64.  
  65. cd $homepath/x264
  66. x264Remote=$(git ls-remote $GITx264 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  67. x264Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  68. cd
  69.  
  70. ################ This will do a clean x264 install ################
  71. ###################################################################
  72.  
  73. # Installs everthing needed for making x264 and clones the git.
  74.  
  75. if [ $pick -eq 1 ]; then
  76.    sudo apt-get update
  77.    sudo apt-get -y remove ffmpeg x264 libx264-dev qt-faststart
  78.    sudo apt-get -y install build-essential git checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
  79.    cd $homepath
  80.    git clone $GITx264
  81.    cd $homepath/x264
  82.    infox264="A clean install of x246 has been cloned to your system. System files installed. Git will be compiled in next step"
  83. fi
  84.  
  85. ################ This will update x264 if needed ##################
  86. ###################################################################
  87.  
  88. if [ $pick -eq 2 ] && [ "$x264Local" != "$x264Remote" ]; then
  89.    sudo apt-get update
  90.    sudo apt-get -y install build-essential git checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
  91.    
  92.    depends=1
  93.    
  94.    cd $homepath/x264
  95.    make -j $cpu_threads clean
  96.    git pull
  97.    infox264="A new x264 was found and downloaded for upgrade. Sytems files upgraded. Git will be compiled in the next step"
  98.    elif [ $pick -eq 2 ] && [ "$x264Local" == "$x264Remote" ]; then
  99.    infox264="You already had the newest x264 git so it does not need to be downloaded or compiled"
  100. fi
  101.  
  102. ############# Compiles and installs x264 if needed ################
  103.  
  104. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$x264Local" != "$x264Remote" ]; then
  105.    cd $homepath/x264
  106.    ./configure
  107.    make -j $cpu_threads
  108.    sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes --fstrans=no --default
  109.    makex264="x264 was compiled and installed on your system. The should only happen if you did not have the newest git already or did an install"
  110. fi
  111.  
  112. ########################### VP8 ##################################
  113. ##################################################################
  114.  
  115. # Checks it you have the newest version of VP8 on your machine by
  116. # compairing with the VP8 git server.
  117. cd $homepath/libvpx
  118. vp8Remote=$(git ls-remote $GITvp8 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  119. vp8Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  120.  
  121. ##############" This will install VP8 encoding ####################
  122. ###################################################################
  123.  
  124. if [ $pick -eq 1 ]; then
  125.    sudo apt-get remove -y libvpx0 libvpx-dev
  126.    cd $homepath
  127.    git clone $GITvp8
  128.    cd $homepath/libvpx
  129.    infovp8="VP8 has be cloned for a fresh install. VP8 wil be compiled in the next step."
  130. fi
  131.  
  132. ################# This will update VP8 if needed ##################
  133. ###################################################################
  134.  
  135. cd $homepath/libvpx
  136. if [ $pick -eq 2 ] && [ "$vp8Remote" != "$vp8Local" ] && [ "$depends" == 0 ]; then
  137.    sudo apt-get update
  138.    sudo apt-get -y install build-essential git checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
  139.  
  140.    depends=1
  141. fi
  142.  
  143. # This will clean the old VP8 build and then pull a new git to be
  144. # merged if VP8 needs to be updated.
  145.  
  146. cd $homepath/libvpx
  147. if [ $pick -eq 2 ] && [ "$vp8Remote" != "$vp8Local" ]; then
  148.    make -j $cpu_threads distclean
  149.    git pull
  150.    infovp8="A newer version of VP8 was found and downloaded. VP8 will be compiled in the next step."
  151.    elif [ $pick -eq 2 ] && [ "$vp8Remote" == "$vp8Local" ]; then
  152.    infovp8="You already have the newest VP8 git so it does not need to be downloaded or compiled"
  153. fi
  154.  
  155. ######### This will compile and install VP8 if needed ###########
  156.  
  157. cd $homepath/libvpx
  158. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$vp8Remote" != "$vp8Local" ]; then
  159.    ./configure
  160.    make -j $cpu_threads
  161.    sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default
  162.    makevp8="VP8 has been compiled and installed on your system. This only happens if you had an old VP8 or did a fresh install"
  163. fi
  164.  
  165. ############## This will install ffmpeg if needed #################
  166. ###################################################################
  167.  
  168. # Checks it you have the newest version of x264 on your machine by
  169. # compairing with the x264 git server.
  170.  
  171. cd $homepath/ffmpeg
  172. ffmpegRemote=$(git ls-remote $GITffmp | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  173. ffmpegLocal=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  174.  
  175. if [ $pick -eq 1 ]; then
  176.    cd $homepath
  177.    git clone $GITffmp
  178.    cd $homepath/ffmpeg
  179.    infoffmpeg="FFmpeg has been cloned for a fresh install. FFmpeg wil be compiled in the next step."
  180. fi
  181.  
  182. ############### This will update ffmpeg if needed #################
  183. ###################################################################
  184.  
  185. # This will make sure you don't upgrade the dev files needed if
  186. # x264 just did it during an upgrade. Looks at flag depends.
  187.  
  188. if [ $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" ] && [ "$depends" == 0 ]; then
  189.    sudo apt-get update
  190.    sudo apt-get -y install build-essential git checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
  191. fi
  192.  
  193. # This will clean the old ffmpeg build and then pull a new git to be
  194. # merged if ffmpeg needs to be updated.
  195.  
  196. if [ $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" ]; then
  197.    cd $homepath/ffmpeg
  198.    make -j $cpu_threads distclean
  199.    git pull
  200.    infoffmpeg="A newer version of FFmpeg was found and downloaded. FFmpeg will be compiled in the next step."
  201.    elif [ $pick -eq 2 ] && [ "$ffmpegRemote" == "$ffmpegLocal" ]; then
  202.    infoffmpeg="You already have the newest FFmpeg git so it does not need to be downloaded or compiled"
  203. fi
  204.  
  205. ######### This will compile and install ffmpeg if needed ###########
  206.  
  207. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" -o "$vp8Remote" != "$vp8Local" ]; then
  208.    cd $homepath/ffmpeg
  209.    # Configures, makes and installs ffmpeg for your system.
  210.    ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
  211.    make -j $cpu_threads
  212.    sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(./version.sh)" --backup=no --deldoc=yes --fstrans=no --default
  213.    hash x264 ffmpeg ffplay ffprobe
  214.    makeffmpeg="FFmpeg has been compiled and installed on your system. This only happens if you had an old ffmpeg or did a fresh install"
  215. fi
  216.  
  217. ####### This will install ffmpegs qt-faststart if wanted ##########
  218. ###################################################################
  219.  
  220. # Installs ffmpegs included tool qt-faststart. Allows web movies to
  221. # start playing before they are completely downloaded.
  222. if [ $pick -eq 3 ]; then
  223.    cd $homepath/ffmpeg
  224.    make -j $cpu_threads tools/qt-faststart
  225.    sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default install -D -m755 tools/qt-faststart /usr/local/bin/qt-faststart
  226.    qtfaststart="qt-faststart was compiled and installed."
  227. fi
  228.  
  229. ####### Removes everything ffmpeg and x264 have installed #########
  230. ###################################################################
  231.  
  232. if [ $pick -eq 4 ]; then
  233.    echo "[y/n] Warning everything this program has installed will be removed"
  234.    read confirm
  235. fi
  236.    
  237. if [ $pick -eq 4 ] && [ "$confirm" == "y" -o "$confirm" == "Y" ]; then
  238.    sudo apt-get autoremove x264 ffmpeg checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libvpx libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
  239.    sudo rm -r $homepath/x264 $homepath/ffmpeg $homepath/libvpx
  240.    elif [ $pick -eq 4 ] && [ "$confirm" != "y" -o "$confirm" != "Y" ]; then
  241.    echo "Nothing was removed."
  242.    exit 0
  243. fi
  244.  
  245. ############################ Exits ################################
  246. ###################################################################
  247.  
  248. # Exits program if 5 is picked.
  249. if [ $pick -eq 5 ]; then
  250.    echo "Bye..."
  251.    exit 0
  252. fi
  253.  
  254. ########################## Feed Back ##############################
  255. ###################################################################
  256. if [ ! -d "$homepath/x264" ]; then
  257.    x264Local="You don't have the x264 source code on your machine!"
  258. fi
  259.  
  260. if [ ! -d "$homepath/ffmpeg" ]; then
  261.    ffmpegLocal="You don't have the ffmpeg source code on your machine!"
  262. fi
  263.  
  264. if [ ! -d "$homepath/libvpx" ]; then
  265.    vp8Local="You don't have the VP8 source code on your machine!"
  266. fi
  267.  
  268. echo ""
  269. echo "    Report of what this script has done"
  270. echo "    -----------------------------------"
  271. echo ""
  272. cd $homepath/x264
  273. x264Remote=$(git ls-remote $GITx264 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  274. x264Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  275. cd $homepath/ffmpeg
  276. ffmpegRemote=$(git ls-remote $GITffmp | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  277. ffmpegLocal=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  278. cd $homepath/libvpx
  279. vp8Remote=$(git ls-remote $GITvp8 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  280. vp8Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  281. echo "Browse the x264 git source: http://git.videolan.org/?p=x264.git;a=summary"
  282. echo "    $x264Remote Remote (git server) x264"
  283. echo "    $x264Local Local (your machine) x264"
  284. cd $homepath/x264
  285. git log | head | grep -m 1 Date:
  286. echo ""
  287. echo "Browse the ffmpeg git source: http://git.videolan.org/?p=ffmpeg.git"
  288. echo "    $ffmpegRemote Remote (git server) ffmpeg"
  289. echo "    $ffmpegLocal Local (your machine) ffmpeg"
  290. cd $homepath/ffmpeg
  291. git log | head | grep -m 1 Date:
  292. echo ""
  293. echo "Browse the VP8 git source http://review.webmproject.org/gitweb?p=libvpx.git"
  294. echo "    $vp8Remote Remote (git server) VP8"
  295. echo "    $vp8Local Local (your machine) VP8"
  296. cd $homepath/libvpx
  297. git log | head | grep -m 1 Date:
  298. echo ""
  299. echo "    $infox264"
  300. echo "    $makex264"
  301. echo "    $infoffmpeg"
  302. echo "    $makeffmpeg"
  303. echo ""
  304. echo "    $infovp8"
  305. echo "    $makevp8"
  306. echo ""
  307. echo "    $qtfaststart"
  308.  
  309. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement