From 5dc78932d7fee29e35f38e7479f435a38b583c84 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Mon, 1 Jun 2015 15:44:10 +0300
Subject: [PATCH] instructions for building ffmpeg added

---
 MSVC.md      | 47 ++++++++++++++++++++++++++---------------------
 QTCREATOR.md | 23 ++++++++++-------------
 README.md    | 18 +++++-------------
 XCODE.md     | 43 +++++++++++++++++++++++++++----------------
 4 files changed, 68 insertions(+), 63 deletions(-)

diff --git a/MSVC.md b/MSVC.md
index dc6db0c6d..e84b6a673 100644
--- a/MSVC.md
+++ b/MSVC.md
@@ -39,7 +39,7 @@ Extract to **D:\TBuild\Libraries**
 
 http://www.zlib.net/ > Download [**zlib source code, version 1.2.8, zipfile format**](http://zlib.net/zlib128.zip)
 
-Extract to **D:\TBuild\Libraries\**
+Extract to **D:\\TBuild\\Libraries\\**
 
 #####Building library
 
@@ -87,35 +87,40 @@ to have **D:\TBuild\Libraries\openal-soft\CMakeLists.txt**
   * OpenAL32 Properties > C/C++ > Code Generation > Runtime Library = **Multi-threaded (/MT)** – **OK**
   * common Properties > C/C++ > Code Generation > Runtime Library = **Multi-threaded (/MT)** – **OK**
 
-####libogg 1.3.2
-
-Get sources from http://xiph.org/downloads/ – in [ZIP](http://downloads.xiph.org/releases/ogg/libogg-1.3.2.zip) and extract to **D:\TBuild\Libraries\**
-
-#####Building library
-
-* Open in VS2013 **D:\TBuild\Libraries\libogg-1.3.2\win32\VS2010\libogg_static.sln** > One-way upgrade – **OK**
-* Build Debug configuration
-* Build Release configuration
-
-####Opus codec, opusfile
+####Opus codec
 
 Get sources by git – in [Git Bash](http://git-scm.com/downloads) go to **/d/tbuild/libraries** and run
 
-    git clone git://git.opus-codec.org/opus.git
-    git clone git://git.xiph.org/opusfile.git
+    git clone https://github.com/telegramdesktop/opus.git
 
 to have **D:\TBuild\Libraries\opus\win32**
 
 #####Building libraries
 
-* Open in VS2013 **D:\TBuild\Libraries\opus\win32\VS2010\opus.sln** > One-way upgrade – **OK**
+* Open in VS2013 **D:\TBuild\Libraries\opus\win32\VS2010\opus.sln**
 * Build Debug configuration
-* Build Release configuration
-* Open in VS2013 **D:\TBuild\Libraries\opusfile\win32\VS2010\opusfile.sln** > One-way upgrade – **OK**
-* For **Debug** and **Release** configurations
-  * opusfile > C/C++ > General > Additional include directories > Add **../../../libogg-1.3.2/include;**
-* Build Debug configuration
-* Build Release configuration
+* Build Release configuration (it will be required in **FFmpeg** build!)
+
+####FFmpeg
+
+https://www.ffmpeg.org/download.html > Download [ffmpeg-2.6.3.tar.bz2](http://ffmpeg.org/releases/ffmpeg-2.6.3.tar.bz2)
+
+Extract to **D:\\TBuild\\Libraries**
+
+http://msys2.github.io/ > Download [msys2-x86_64-20150512.exe](http://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20150512.exe/download) and install to **D:\\msys64**
+
+#####Building libraries
+
+* Open **VS2013 x86 Native Tools Command Prompt.bat** (should be in **\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Tools\\Shortcuts\\** folder)
+* Go to **D:\\msys64\\** and launch **msys2_shell.bat**
+* Run command **PATH="/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN:$PATH"** to get link.exe from VS2013 ahead of link.exe from /usr/bin in PATH and run
+
+  cd /c/TBuild/Libraries/ffmpeg-2.6.3
+  pacman -S msys/make
+  pacman -S mingw64/mingw-w64-x86_64-opus
+  ./configure --toolchain=msvc --disable-programs --disable-everything --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-parser=aac --enable-parser=aac_latm --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=wav --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=mov --enable-muxer=ogg --enable-muxer=opus --extra-ldflags="-libpath:/d/TBuild/Libraries/opus/win32/VS2010/Win32/Release celt.lib silk_common.lib silk_float.lib"
+  make
+  make install
 
 ####Qt 5.4.0, slightly patched
 
diff --git a/QTCREATOR.md b/QTCREATOR.md
index acf4eda4e..b1832afd4 100644
--- a/QTCREATOR.md
+++ b/QTCREATOR.md
@@ -34,27 +34,24 @@ Install dev libraries
 
 Install audio libraries
 
-####libogg-1.3.2
-
-[Download libogg-1.3.2 sources](http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz) from http://xiph.org/downloads, extract to **/home/user/TBuild/Libraries**, go to **/home/user/TBuild/Libraries/libogg-1.3.2** and run
-
-    ./configure
-    make
-    sudo make install
-
 ####Opus codec 1.1
 
-[Download opus-1.1 sources](http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz) from http://www.opus-codec.org/downloads, extract to **/home/user/TBuild/Libraries**, go to **/home/user/TBuild/Libraries/opus-1.1** and run
+Download [opus-1.1 sources](http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz) from http://www.opus-codec.org/downloads, extract to **/home/user/TBuild/Libraries**, go to **/home/user/TBuild/Libraries/opus-1.1** and run
 
     ./configure
     make
     sudo make install
 
-####opusfile-0.6
+####FFmpeg
 
-[Download opusfile-0.6 sources](http://downloads.xiph.org/releases/opus/opusfile-0.6.tar.gz) from http://www.opus-codec.org/downloads, extract to **/home/user/TBuild/Libraries**, go to **/home/user/TBuild/Libraries/opusfile-0.6** and run
+Download sources [ffmpeg-2.6.3.tar.bz2](http://ffmpeg.org/releases/ffmpeg-2.6.3.tar.bz2) from https://www.ffmpeg.org/download.html, extract to **/home/user/TBuild/Libraries** to have **/home/user/TBuild/Libraries/ffmpeg-2.6.3**, go to **/home/user/TBuild/Libraries/ffmpeg-2.6.3** and run
+
+    sudo apt-get update
+    sudo apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev
+    sudo apt-get install yasm
+
+    ./configure --prefix=/usr/local --disable-programs --disable-everything --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-parser=aac --enable-parser=aac_latm --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=wav --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=mov --enable-muxer=ogg --enable-muxer=opus
 
-    ./configure
     make
     sudo make install
 
@@ -72,7 +69,7 @@ In Terminal go to **/home/user/TBuild/Libraries** and run
 
     git clone git://repo.or.cz/openal-soft.git
 
-then go to **/home/user/TBuild/Libraries/openal-soft/build** and run 
+then go to **/home/user/TBuild/Libraries/openal-soft/build** and run
 
     sudo apt-get install cmake
     cmake -D LIBTYPE:STRING=STATIC ..
diff --git a/README.md b/README.md
index ff35ac7ab..012c0239a 100644
--- a/README.md
+++ b/README.md
@@ -6,17 +6,9 @@ Source code is published under GPL v3, license is available [here](https://githu
 
 ###Supported systems
 
-* Windows XP
-* Windows Vista
-* Windows 7
-* Windows 8 (**not** RT)
-* Windows 8.1 (**not** RT)
-* OS X 10.7
-* OS X 10.8
-* OS X 10.9
-* Ubuntu 12.04
-* Ubuntu 13.04
-* Ubuntu 14.04
+* Windows XP - Windows 8.1 (**not** RT)
+* Mac OS X 10.7 - Mac OS X 10.10
+* Ubuntu 12.04 - Ubuntu 14.04
 
 ###Third-party
 
@@ -27,8 +19,8 @@ Source code is published under GPL v3, license is available [here](https://githu
 * LZMA SDK 9.20 ([public domain](http://www.7-zip.org/sdk.html))
 * liblzma ([public domain](http://tukaani.org/xz/))
 * OpenAL Soft ([LGPL](http://kcat.strangesoft.net/openal.html))
-* Opus codec, opusfile ([BSD license](http://www.opus-codec.org/license/))
-* libogg ([BSD license](http://www.xiph.org/downloads/))
+* Opus codec ([BSD license](http://www.opus-codec.org/license/))
+* FFmpeg ([LGPL](https://www.ffmpeg.org/legal.html))
 * Open Sans font ([Apache License](http://www.apache.org/licenses/LICENSE-2.0.html))
 
 ###[Build instructions for Visual Studio 2013](https://github.com/telegramdesktop/tdesktop/blob/master/MSVC.md)
diff --git a/XCODE.md b/XCODE.md
index 8d7c5585c..f4bc15e22 100644
--- a/XCODE.md
+++ b/XCODE.md
@@ -87,21 +87,9 @@ In Terminal go to **/Users/user/TBuild/Libraries/openal-soft/build** and there r
     make
     sudo make install
 
-####libogg 1.3.2
+####Opus codec
 
-Get sources from http://xiph.org/downloads/ – in [ZIP](http://downloads.xiph.org/releases/ogg/libogg-1.3.2.zip) and extract to **/Users/user/TBuild/Libraries**
-
-#####Building library
-
-In Terminal go to **/Users/user/TBuild/Libraries/libogg-1.3.2** and there run
-
-    ./configure
-    make
-    sudo make install
-
-####Opus codec, opusfile
-
-Download sources [opus-1.1.tar.gz](http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz) and [opusfile-0.6.tar.gz](http://downloads.xiph.org/releases/opus/opusfile-0.6.tar.gz) from http://www.opus-codec.org/downloads/, extract to **/Users/user/TBuild/Libraries** and rename to have **/Users/user/TBuild/Libraries/opus/configure** and **/Users/user/TBuild/Libraries/opusfile/configure**
+Download sources [opus-1.1.tar.gz](http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz) from http://www.opus-codec.org/downloads/, extract to **/Users/user/TBuild/Libraries** and rename to have **/Users/user/TBuild/Libraries/opus/configure**
 
 #####Building libraries
 
@@ -119,9 +107,32 @@ then go to **/Users/user/TBuild/Libraries/opus** and there run
     make
     sudo make install
 
-then go to **/Users/user/TBuild/Libraries/opusfile** and there run
+####FFmpeg
+
+Download sources [ffmpeg-2.6.3.tar.bz2](http://ffmpeg.org/releases/ffmpeg-2.6.3.tar.bz2) from https://www.ffmpeg.org/download.html, extract to **/Users/user/TBuild/Libraries** to have **/Users/user/TBuild/Libraries/ffmpeg-2.6.3**
+
+#####Building libraries
+
+Download [libiconv-1.14](http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz) from http://www.gnu.org/software/libiconv/#downloading, extract it to **/Users/user/TBuild/Libraries**
+
+In Termianl go to **/Users/user/TBuild/Libraries/libiconv-1.14** and run
+
+    ./configure --enable-static
+    make
+    sudo make install
+
+Then in Terminal go to **/Users/user/TBuild/Libraries/ffmpeg-2.6.3** and run
+
+    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
+    brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 xvid yasm
+
+    CFLAGS=`freetype-config --cflags`
+    LDFLAGS=`freetype-config --libs`
+    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig
+
+    ./configure --prefix=/usr/local --disable-programs --disable-everything --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-parser=aac --enable-parser=aac_latm --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=wav --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=mov --enable-muxer=ogg --enable-muxer=opus --extra-cflags="-mmacosx-version-min=10.7" --extra-cxxflags="-mmacosx-version-min=10.7" --extra-ldflags="-mmacosx-version-min=10.7"
 
-    ./configure
     make
     sudo make install