Advertisement
Onryo

Script Install ffmpeg and x264 for Ubuntu 10.10 by Onryo

Mar 25th, 2011
1,824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 15.11 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/erik/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=http://webm.googlecode.com/files/ffmpeg-HEAD-VP8_param_mapping-6.tar.gz
  21.  
  22. pkg_mkclean="mkclean-0.8.2.tar.bz2"
  23. #######################################################################################
  24.  
  25. clear
  26.  
  27. depends=0
  28. cpu_threads=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
  29.  
  30. if [ $# -eq 0 ]
  31.  
  32. then
  33.    echo
  34.    echo "           Install, Upgrading and Removing x264 and ffmpeg for Maverick"
  35.    echo "           ------------------------------------------------------------"
  36.    echo
  37.    echo " [1] INSTALL x264 and FFmpeg. Makes A Clean Install"
  38.    echo " [2] UPGRADE x264 and FFmpeg and Dependencies"
  39.    echo " [3] Install FFmpeg's qt-faststart and mkclean"
  40.    echo " [4] REMOVE Everything This Program Has Installed"
  41.    echo " [5] Exit"
  42.    echo
  43.    read pick
  44. fi
  45.  
  46. # makes sure a interger from 1 to 5 is used.
  47.  
  48. counter=1
  49. while [  $counter -eq 1 ]; do
  50.    if [ $pick -lt 1 -o $pick -gt 5 2>/dev/null ] || ! [ $pick -eq $pick 2>/dev/null ]; then
  51.       echo "Please enter 1-5 number ONLY"
  52.       read pick
  53.       counter=1
  54.    else
  55.       counter=0
  56.    fi
  57. done
  58.  
  59. clear
  60.  
  61. ########################### x264 #################################
  62. ##################################################################
  63.  
  64. # Checks it you have the newest version of x264 on your machine by
  65. # compairing with the x264 git server.
  66.  
  67. cd $homepath/x264
  68. x264Remote=$(git ls-remote $GITx264 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  69. x264Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  70. cd
  71.  
  72. ################ This will do a clean x264 install ################
  73. ###################################################################
  74.  
  75. # Installs everthing needed for making x264 and clones the git.
  76.  
  77. if [ $pick -eq 1 ]; then
  78.    sudo rm -r $homepath/x264
  79.    sudo apt-get update
  80.    sudo apt-get -y remove ffmpeg x264 libx264-dev qt-faststart
  81.    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
  82.    cd $homepath
  83.    git clone $GITx264
  84.    cd $homepath/x264
  85.    infox264="A clean install of x246 has been cloned to your system. System files installed. Git will be compiled in next step"
  86. fi
  87.  
  88. ################ This will update x264 if needed ##################
  89. ###################################################################
  90.  
  91. if [ $pick -eq 2 ] && [ "$x264Local" != "$x264Remote" ]; then
  92.    sudo apt-get update
  93.    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
  94.    
  95.    depends=1
  96.    
  97.    cd $homepath/x264
  98.    make -j $cpu_threads clean
  99.    git pull
  100.    infox264="A new x264 was found and downloaded for upgrade. Sytems files upgraded. Git will be compiled in the next step"
  101.    elif [ $pick -eq 2 ] && [ "$x264Local" == "$x264Remote" ]; then
  102.    infox264="You already had the newest x264 git so it does not need to be downloaded or compiled"
  103. fi
  104.  
  105. ############# Compiles and installs x264 if needed ################
  106.  
  107. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$x264Local" != "$x264Remote" ]; then
  108.    cd $homepath/x264
  109.    ./configure
  110.    make -j $cpu_threads
  111.    sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes --fstrans=no --default
  112.    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"
  113. fi
  114.  
  115. ########################### VP8 ##################################
  116. ##################################################################
  117.  
  118. # Checks it you have the newest version of VP8 on your machine by
  119. # compairing with the VP8 git server.
  120. cd $homepath/libvpx
  121. vp8Remote=$(git ls-remote $GITvp8 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  122. vp8Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  123.  
  124. ##############" This will install VP8 encoding ####################
  125. ###################################################################
  126.  
  127. if [ $pick -eq 1 ]; then
  128.    sudo apt-get remove -y libvpx0 libvpx-dev
  129.    cd $homepath
  130.    sudo rm -r libvpx
  131.    git clone $GITvp8
  132.    cd $homepath/libvpx
  133.    infovp8="VP8 has be cloned for a fresh install. VP8 wil be compiled in the next step."
  134. fi
  135.  
  136. ################# This will update VP8 if needed ##################
  137. ###################################################################
  138.  
  139.  
  140. if [ $pick -eq 2 ] && [ "$vp8Remote" != "$vp8Local" ] && [ "$depends" == 0 ]; then
  141.    cd $homepath/libvpx
  142.    sudo apt-get update
  143.    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
  144.  
  145.    depends=1
  146. fi
  147.  
  148. # This will clean the old VP8 build and then pull a new git to be
  149. # merged if VP8 needs to be updated.
  150.  
  151.  
  152. if [ $pick -eq 2 ] && [ "$vp8Remote" != "$vp8Local" ]; then
  153.    cd $homepath/libvpx
  154.    make -j $cpu_threads distclean
  155.    git pull
  156.    infovp8="A newer version of VP8 was found and downloaded. VP8 will be compiled in the next step."
  157.    elif [ $pick -eq 2 ] && [ "$vp8Remote" == "$vp8Local" ]; then
  158.    infovp8="You already have the newest VP8 git so it does not need to be downloaded or compiled"
  159. fi
  160.  
  161. ######### This will compile and install VP8 if needed ###########
  162.  
  163. cd $homepath/libvpx
  164. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$vp8Remote" != "$vp8Local" ]; then
  165.    ./configure
  166.    make -j $cpu_threads
  167.    sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default
  168.    makevp8="VP8 has been compiled and installed on your system. This only happens if you had an old VP8 or did a fresh install"
  169. fi
  170.  
  171. ############## This will install ffmpeg if needed #################
  172. ###################################################################
  173.  
  174. # Checks it you have the newest version of x264 on your machine by
  175. # compairing with the x264 git server.
  176.  
  177. cd $homepath/ffmpeg
  178. ffmpegRemote=$(git ls-remote $GITffmp | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  179. ffmpegLocal=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  180.  
  181. if [ $pick -eq 1 ]; then
  182.    cd $homepath
  183.    sudo rm -r ffmpeg
  184.    git clone $GITffmp
  185.    cd $homepath/ffmpeg
  186. ### this will patch for VP8 presets
  187. rm -r $homepath/FFmpeg_patches
  188. mkdir $homepath/FFmpeg_patches
  189. cd $homepath/FFmpeg_patches
  190. wget $vp8presets
  191. tar -xf ffmpeg-HEAD-VP8_param_mapping-6.tar.gz
  192. cp $homepath/FFmpeg_patches/ffmpeg-HEAD-VP8_param_mapping.diff $homepath/ffmpeg/
  193. cd $homepath/ffmpeg
  194. git apply --verbose ffmpeg-HEAD-VP8_param_mapping.diff
  195. # patch -p1 < ffmpeg-HEAD-VP8_param_mapping.diff
  196. ### end of patch
  197. infoffmpeg="FFmpeg has been cloned for a fresh install. FFmpeg wil be compiled in the next step."
  198. fi
  199.  
  200. ############### This will update ffmpeg if needed #################
  201. ###################################################################
  202.  
  203. # This will make sure you don't upgrade the dev files needed if
  204. # x264 just did it during an upgrade. Looks at flag depends.
  205.  
  206. if [ $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" ] && [ "$depends" == 0 ]; then
  207.    sudo apt-get update
  208.    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
  209. fi
  210.  
  211. # This will clean the old ffmpeg build and then pull a new git to be
  212. # merged if ffmpeg needs to be updated.
  213.  
  214. if [ $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" ]; then
  215.    cd $homepath/ffmpeg
  216.    make -j $cpu_threads distclean
  217.    git pull
  218.    infoffmpeg="A newer version of FFmpeg was found and downloaded. FFmpeg will be compiled in the next step."
  219.    elif [ $pick -eq 2 ] && [ "$ffmpegRemote" == "$ffmpegLocal" ]; then
  220.    infoffmpeg="You already have the newest FFmpeg git so it does not need to be downloaded or compiled"
  221. fi
  222.  
  223. ######### This will compile and install ffmpeg if needed ###########
  224.  
  225. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" -o "$vp8Remote" != "$vp8Local" ]; then
  226.    cd $homepath/ffmpeg
  227.    # Configures, makes and installs ffmpeg for your system.
  228.    ./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
  229.    make -j $cpu_threads
  230.    sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default
  231.    hash x264 ffmpeg ffplay ffprobe
  232.    makeffmpeg="FFmpeg has been compiled and installed on your system. This only happens if you had an old ffmpeg or did a fresh install"
  233. fi
  234.  
  235. ####### This will install ffmpegs qt-faststart if wanted ##########
  236. ###################################################################
  237.  
  238. # Installs ffmpegs included tool qt-faststart. Allows web movies to
  239. # start playing before they are completely downloaded.
  240. if [ $pick -eq 3 ]; then
  241.    cd $homepath/ffmpeg
  242.    make -j $cpu_threads tools/qt-faststart
  243.    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
  244.  
  245.  
  246.  
  247. # Installs mkclean (qt-faststart analog for webm):
  248. cd $homepath
  249. wget http://downloads.sourceforge.net/project/matroska/mkclean/$pkg_mkclean
  250. tar jxvf mkclean-0.8.2.tar.bz2
  251. cd mkclean-0.8.2
  252. ./configure
  253. make -j $cpu_threads
  254. sudo checkinstall --pkgname=mkclean --pkgversion="0.8.2" --backup=no --deldoc=yes --fstrans=no --default
  255. cd $homepath
  256. rm *bz2
  257.    qtfaststart="qt-faststart and mkclean was compiled and installed."
  258. fi
  259.  
  260. ######### This will adding lavf support to x264 if needed ###########
  261.  
  262.  
  263. if [ $pick -eq 1 -o $pick -eq 2 ] && [ "$ffmpegRemote" != "$ffmpegLocal" -o "$vp8Remote" != "$vp8Local" ]; then
  264.     cd $homepath/x264
  265.     make -j $cpu_threads distclean
  266.     ./configure
  267.     sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes --fstrans=no --default
  268.     lavf="lavf support added for x264"
  269. fi
  270.  
  271. ####### Removes everything ffmpeg and x264 have installed #########
  272. ###################################################################
  273.  
  274. if [ $pick -eq 4 ]; then
  275.    echo "[y/n] Warning everything this program has installed will be removed"
  276.    read confirm
  277. fi
  278.    
  279. if [ $pick -eq 4 ] && [ "$confirm" == "y" -o "$confirm" == "Y" ]; then
  280.    sudo apt-get autoremove x264 ffmpeg qt-faststart build-essential git-core 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 mkclean
  281.    sudo rm -r $homepath/x264 $homepath/ffmpeg $homepath/libvpx $homepath/mkclean* $homepath/FFmpeg_patches
  282.    elif [ $pick -eq 4 ] && [ "$confirm" != "y" -o "$confirm" != "Y" ]; then
  283.    echo "Nothing was removed."
  284.    exit 0
  285. fi
  286.  
  287. ############################ Exits ################################
  288. ###################################################################
  289.  
  290. # Exits program if 5 is picked.
  291. if [ $pick -eq 5 ]; then
  292.    echo "Bye..."
  293.    exit 0
  294. fi
  295.  
  296. ########################## Feed Back ##############################
  297. ###################################################################
  298. if [ ! -d "$homepath/x264" ]; then
  299.    x264Local="You don't have the x264 source code on your machine!"
  300. fi
  301.  
  302. if [ ! -d "$homepath/ffmpeg" ]; then
  303.    ffmpegLocal="You don't have the ffmpeg source code on your machine!"
  304. fi
  305.  
  306. if [ ! -d "$homepath/libvpx" ]; then
  307.    vp8Local="You don't have the VP8 source code on your machine!"
  308. fi
  309.  
  310. echo ""
  311. echo "    The versions & date of programs you have "
  312. echo "    -----------------------------------------"
  313. echo ""
  314.  
  315. if [ -d "$homepath/x264" ]; then
  316. cd $homepath/x264
  317. x264Remote=$(git ls-remote $GITx264 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  318. x264Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  319. fi
  320.  
  321. if [ -d "$homepath/ffmpeg" ]; then
  322. cd $homepath/ffmpeg
  323. ffmpegRemote=$(git ls-remote $GITffmp | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  324. ffmpegLocal=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  325. fi
  326.  
  327. if [ -d "$homepath/libvpx" ]; then
  328. cd $homepath/libvpx
  329. vp8Remote=$(git ls-remote $GITvp8 | grep -m 1 HEAD | sed -e s/HEAD//g -e 's/[[:space:]]//g')
  330. vp8Local=$(git log | head | grep -m 1 commit | sed -e s/commit//g -e 's/[[:space:]]//g')
  331. fi
  332.  
  333. if [ -d "$homepath/x264" ]; then
  334. cd $homepath/x264
  335. echo "Browse the x264 git source: http://git.videolan.org/?p=x264.git;a=summary"
  336. echo "    $x264Remote Remote (git server) x264"
  337. echo "    $x264Local Local (your machine) x264"
  338. git log | head | grep -m 1 Date:
  339. fi
  340. echo ""
  341. if [ -d "$homepath/ffmpeg" ]; then
  342. cd $homepath/ffmpeg
  343. echo "Browse the ffmpeg git source: http://git.videolan.org/?p=ffmpeg.git"
  344. echo "    $ffmpegRemote Remote (git server) ffmpeg"
  345. echo "    $ffmpegLocal Local (your machine) ffmpeg"
  346. cd $homepath/ffmpeg
  347. git log | head | grep -m 1 Date:
  348. fi
  349. echo ""
  350. if [ -d "$homepath/libvpx" ]; then
  351. cd $homepath/libvpx
  352. echo "Browse the VP8 git source http://review.webmproject.org/gitweb?p=libvpx.git"
  353. echo "    $vp8Remote Remote (git server) VP8"
  354. echo "    $vp8Local Local (your machine) VP8"
  355. cd $homepath/libvpx
  356. git log | head | grep -m 1 Date:
  357. fi
  358. echo ""
  359. echo "    Report of what this script has done"
  360. echo "    -----------------------------------"
  361. echo ""
  362. echo "    $infox264"
  363. echo "    $makex264"
  364. echo "    $infoffmpeg"
  365. echo "    $makeffmpeg"
  366. echo ""
  367. echo "    $infovp8"
  368. echo "    $makevp8"
  369. echo ""
  370. echo "    $qtfaststart"
  371. echo "    $lavf"
  372. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement