Advertisement
Guest User

ffmpeg bash script

a guest
Jun 26th, 2016
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.01 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Fail on error
  3. set -e
  4.  
  5. # ------------------------------------------------------------------------------
  6. # Directories
  7. # ------------------------------------------------------------------------------
  8. # Root dir
  9. ROOT_DIR=$(cd $(dirname $0); pwd -P)
  10. YASM_DIR="$ROOT_DIR/yasm"
  11. X264_DIR="$ROOT_DIR/x264"
  12. X265_DIR="$ROOT_DIR/x265"
  13. FDK_AAC_DIR="$ROOT_DIR/fdk-aac"
  14. MP3LAME_DIR="$ROOT_DIR/lame-3.99.5"
  15. OPUS_DIR="$ROOT_DIR/opus"
  16. OGG_DIR="$ROOT_DIR/libogg-1.3.2"
  17. VORBIS_DIR="$ROOT_DIR/libvorbis-1.3.4"
  18. VPX_DIR="$ROOT_DIR/libvpx"
  19. FFMPEG_DIR="$ROOT_DIR/ffmpeg"
  20.  
  21. echo "Build root is '$ROOT_DIR'."
  22.  
  23. # ------------------------------------------------------------------------------
  24. # Yasm
  25. # ------------------------------------------------------------------------------
  26. # Update the code from the repository
  27. if [[ -d "$YASM_DIR" ]]; then
  28.   echo "Yasm directory found. Pulling latest changes."
  29.   cd $YASM_DIR
  30.   git pull origin
  31.  
  32. else
  33.   echo "Yasm directory not found. Cloning repository."
  34.   cd $ROOT_DIR
  35.   git clone --depth 1 git://github.com/yasm/yasm.git
  36.   cd $YASM_DIR
  37. fi
  38.  
  39. # Do the build
  40. autoreconf -fiv
  41. ./configure
  42. make
  43.  
  44. # Install
  45. make install
  46. make distclean
  47.  
  48. # ------------------------------------------------------------------------------
  49. # libx264
  50. # ------------------------------------------------------------------------------
  51. # Update the code from the repository
  52. if [[ -d "$X264_DIR" ]]; then
  53.   echo "x264 directory found. Pulling latest changes."
  54.   cd $X264_DIR
  55.   git pull origin
  56.  
  57. else
  58.   echo "x264 directory not found. Cloning repository."
  59.   cd $ROOT_DIR
  60.   git clone --depth 1 git://git.videolan.org/x264
  61.   cd $X264_DIR
  62. fi
  63.  
  64. # Do the build
  65. ./configure --enable-static --enable-shared --enable-pic
  66. make
  67.  
  68. # Install
  69. make install
  70. make distclean
  71.  
  72. # ------------------------------------------------------------------------------
  73. # libx265
  74. # ------------------------------------------------------------------------------
  75. # Update the code from the repository
  76. if [[ -d "$X265_DIR" ]]; then
  77.   echo "x265 directory found. Pulling latest changes."
  78.   cd $X265_DIR
  79.   hg update
  80.  
  81. else
  82.   echo "x265 directory not found. Cloning repository."
  83.   cd $ROOT_DIR
  84.   hg clone https://bitbucket.org/multicoreware/x265
  85.   cd $X265_DIR
  86. fi
  87.  
  88. # Do the build
  89. cd build/linux
  90. cmake ../../source -DENABLE_SHARED:bool=on
  91. make
  92.  
  93. # Install
  94. make install
  95.  
  96. # ------------------------------------------------------------------------------
  97. # libfdk_aac
  98. # ------------------------------------------------------------------------------
  99. # Update the code from the repository
  100. if [[ -d "$FDK_AAC_DIR" ]]; then
  101.   echo "fdk_aac directory found. Pulling latest changes."
  102.   cd $FDK_AAC_DIR
  103.   git pull origin
  104.  
  105. else
  106.   echo "fdk_aac directory not found. Cloning repository."
  107.   cd $ROOT_DIR
  108.   git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
  109.   cd $FDK_AAC_DIR
  110. fi
  111.  
  112. # Do the build
  113. autoreconf -fiv
  114. ./configure --enable-shared --enable-static --enable-pic
  115. make
  116.  
  117. # Install
  118. make install
  119. make distclean
  120.  
  121. # ------------------------------------------------------------------------------
  122. # libmp3lame
  123. # ------------------------------------------------------------------------------
  124. # Update the code from the repository
  125. if [[ -d "$MP3LAME_DIR" ]]; then
  126.   echo "mp3lame directory found. Skipping download."
  127.   cd $MP3LAME_DIR
  128.  
  129. else
  130.   echo "mp3lame directory not found. Downloading."
  131.   cd $ROOT_DIR
  132.   curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
  133.   tar xzvf lame-3.99.5.tar.gz
  134.   cd $MP3LAME_DIR
  135. fi
  136.  
  137. # Do the build
  138. ./configure --enable-nasm --enable-shared --enable-static --enable-pic
  139. make
  140.  
  141. # Install
  142. make install
  143. make distclean
  144.  
  145. # ------------------------------------------------------------------------------
  146. # libopus
  147. # ------------------------------------------------------------------------------
  148. # Update the code from the repository
  149. if [[ -d "$OPUS_DIR" ]]; then
  150.   echo "opus directory found. Pulling latest changes."
  151.   cd $OPUS_DIR
  152.   git pull origin
  153.  
  154. else
  155.   echo "opus directory not found. Cloning repository."
  156.   cd $ROOT_DIR
  157.   git clone http://git.opus-codec.org/opus.git opus
  158.   cd $OPUS_DIR
  159. fi
  160.  
  161. # Do the build
  162. autoreconf -fiv
  163. ./configure --enable-static --enable-shared --enable-pic
  164. make
  165.  
  166. # Install
  167. make install
  168. make distclean
  169.  
  170. # ------------------------------------------------------------------------------
  171. # libogg
  172. # ------------------------------------------------------------------------------
  173. # Update the code from the repository
  174. if [[ -d "$OGG_DIR" ]]; then
  175.   echo "ogg directory found. Skipping download."
  176.   cd $OGG_DIR
  177.  
  178. else
  179.   echo "ogg directory not found. Downloading."
  180.   cd $ROOT_DIR
  181.   curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
  182.   tar xzvf libogg-1.3.2.tar.gz
  183.   cd $OGG_DIR
  184. fi
  185.  
  186. # Do the build
  187. ./configure --enable-static --enable-shared --enable-pic
  188. make
  189.  
  190. # Install
  191. make install
  192. make distclean
  193.  
  194. # ------------------------------------------------------------------------------
  195. # libvorbis
  196. # ------------------------------------------------------------------------------
  197. # Update the code from the repository
  198. if [[ -d "$VORBIS_DIR" ]]; then
  199.   echo "vorbis directory found. Skipping download."
  200.   cd $VORBIS_DIR
  201.  
  202. else
  203.   echo "vorbis directory not found. Downloading."
  204.   cd $ROOT_DIR
  205.   curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
  206.   tar xzvf libvorbis-1.3.4.tar.gz
  207.   cd $VORBIS_DIR
  208. fi
  209.  
  210. # Do the build
  211. ./configure --enable-static --enable-shared --enable-pic
  212. make
  213.  
  214. # Install
  215. make install
  216. make distclean
  217.  
  218. # ------------------------------------------------------------------------------
  219. # libvpx
  220. # ------------------------------------------------------------------------------
  221. # Update the code from the repository
  222. if [[ -d "$VPX_DIR" ]]; then
  223.   echo "vpx directory found. Pulling latest changes."
  224.   cd $VPX_DIR
  225.   git pull origin
  226.  
  227. else
  228.   echo "vpx directory not found. Cloning repository."
  229.   cd $ROOT_DIR
  230.   git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
  231.   cd $VPX_DIR
  232. fi
  233.  
  234. # Do the build
  235. ./configure --disable-examples --enable-static --enable-shared --enable-pic
  236. make
  237.  
  238. # Install
  239. make install
  240. make clean
  241.  
  242. # ------------------------------------------------------------------------------
  243. # FFmpeg
  244. # ------------------------------------------------------------------------------
  245. # Update the code from the repository
  246. if [[ -d "$FFMPEG_DIR" ]]; then
  247.   echo "FFmpeg directory found. Pulling latest changes."
  248.   cd $FFMPEG_DIR
  249.   git pull origin
  250.  
  251. else
  252.   echo "FFmpeg directory not found. Cloning repository."
  253.   cd $ROOT_DIR
  254.   git clone https://git.ffmpeg.org/ffmpeg.git
  255.   cd $FFMPEG_DIR
  256. fi
  257.  
  258. # Do the build
  259. PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --enable-static --enable-shared --enable-pic --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
  260. make
  261.  
  262. # Install
  263. make install
  264. make distclean
  265. hash -r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement