# Linux

## Multimedia From Scratch

“Multimedia From Scratch” (MFS) is a set of Makefiles and patches to automatically build FFmpeg from scratch. FFmpeg is one of the most powerful tools to convert audio and video files under Linux. Due to licensing issues with multimedia codecs or legal issues the version of FFmped shipped with your Linux distribution might have limited functionality or it might just be outdated. MFS assists you in building a more recent version of FFmpeg with several useful libraries from scratch.

MFS up to version 0.1.0 has been successfully run on a x86_64 (64-bit Intel) system under Debian 5.0.

#### WARNING

Make sure you are allowed to download, compile, and use the tools built by MFS in your country. Also make sure that there are no licensing issues when using FFmpeg or the libraries built by MFS, especially, when publishing multimedia files generated by them in the internet or when passing such files to others.

It is published under the terms of the GNU GPL v3 (see http://www.gnu.org/licenses/).

### Prerequisites

Note: It is strongly recommended to create a new user for running MFS and FFmpeg, respectively. This way the risk of damaging the build system due to bugs in either MFS or FFmpeg/a library can be minimized.

MFS requires several tools installed on the build system, beyond others, the GCC C compiler, bash, and make etc. A minimalist test for required tools is run at the very beginning of MFS. The list of these tools is stored in $(TOOLS_HOST) in make.config. Furthermore, MFS requires source packages of the programs that shall be built. These packages have to be downloaded from the respective project websites either as .tar.gz or .tar.bz2 file and stored in $(TOOLS_SRCDIR) (defaults to sources directory in the directory with MFS Makefiles; see make.config). The required packages are defined by the variables named $(TOOL_PACKAGENAME) in the respective section headed "MFS VERSION --- files and patches" in make.config. All the required patches are shipped with MFS and stored in the $(TOOLS_PATCHDIR) directory (defaults to patches in the directory with TFS Makefiles). There is no need to change this directory.

During the build, the sources will be unpacked and compiled in directories under $(TOOLS_TEMPDIR)/build and temporarily installed and packaged under $(TOOLS_TEMPDIR)/packages. $(TOOLS_TEMPDIR) defaults to the directory with TFS Makefiles. You might want to change this directory (see below). The installation directory for the toolchain is defined by $(TOOLS_INSTDIR) in make.config. It defaults to /opt/mfs/VERSION/BUILDSYSTEM/ and must be writable by the user running MFS. As it is strongly discouraged to run MFS as root, you will have to create $(TOOLS_INSTDIR) (or at least /opt/mfs) beforehand as root and chown it for the user running MFS. WARNING: Do not use /, /usr, /usr/local, or any other default filesystem tree as installation directory of MFS! Use a new, empty directory as basis of the toolchain installation. ### Build of FFmpeg with libraries MFS can be run on i686 and x86_64 system. The build system is configured by the variable $(TOOLS_BUILD).

Valid build system names are:

i686-pc-linux-gnu
for a i686 system (32-bit Intel)
x86_64-unknown-linux-gnu
for x86_64 system (64-bit Intel); this is the default build system

After fulfilling all prerequisites, MFS can be started. Change to the directory with MFS Makefiles and run make.

Example 1: build on a x86_64 build system.

$make TOOLS_TEMPDIR=/scratch_dir \ TOOLS_BUILD=x86_64-unknown-linux-gnu Example 2: build on an i686 build system. $ make TOOLS_TEMPDIR=/scratch_dir \
TOOLS_BUILD=i686-pc-linux-gnu

If the build is successful, the tools will be installed in $(TOOLS_INSTDIR) and packages can be found in $(TOOLS_PACKDIR) (= $(TOOLS_TEMPDIR)/packages). The packages can be used to install the packages on other systems. ### Installation of FFmpeg with libraries (This section may be skipped, if the toolchain has been built and installed before.) The installation directory $(TOOLS_INSTDIR) must not coincide with an existing directory tree (especially / or /usr). Change to the root directory / and untar the packages.

# cd /
# tar -xjf ffmpeg-....tar.bz2
# tar -xjf ...

At this point you can chown the toolchain for root.

### Usage of FFmpeg with libraries

First, set the variable ${TOOLS_INSTDIR} to the correct directory under your shell. Second, the directory ${TOOLS_INSTDIR}/lib with the shared libraries must be added to ${LD_LIBRARY_PATH}. Before running FFmpeg, you can also add ${TOOLS_INSTDIR}/bin and ${TOOLS_INSTDIR}/sbin to your $PATH environmental variable:

$export LD_LIBRARY_PATH="${TOOLS_INSTDIR}/lib:${LD_LIBRARY_PATH}"$ export PATH="${TOOLS_INSTDIR}/bin:${TOOLS_INSTDIR}/sbin:\${PATH}"

Now you should be able to run ffmpeg as usual.