Skip to content

How to get started in ffmpeg

Getting started with FFmpeg can be exciting but also very complex, as it’s a powerful command-line tool for handling multimedia data. Here’s a step-by-step guide:

LinkWhat is FFmpeg?

FFmpeg is an open-source multimedia framework for recording, converting, streaming, and playing multimedia files. It supports a vast range of formats and codecs. It’s used in many applications all across the Internet today.

It's main uses are to manipulate video files in a way to prepare them for viewing interactions in a plethora of web devices as well as some broadcast applications.

LinkInstall FFmpeg

LinkWindows

The easiest way to install in Windows is to:

  1. Download the latest static build from FFmpeg’s website.
  2. Extract the zip file.
  3. Add the bin folder to your system’s PATH.

LinkMacOS

If you have Homebrew installed, you can install FFmpeg by this one command.

bash
brew install ffmpeg

Alternatively, you can download the binaries for Mac as well from FFmpeg’s website and then add the ffmpeg binary to your desired location/path.

LinkLinux (Debian/Ubuntu)

bash
sudo apt update sudo apt install ffmpeg

LinkBuild from source

Building FFmpeg from source allows for customization of codecs, formats, and features, which can be essential for specific use cases. Or if you simply want to learn how it all comes together. Here’s how to build FFmpeg step-by-step.

Download the FFmpeg Source Code

Clone the repository:

bash
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg cd ffmpeg

Alternatively, download a release tarball:

bash
wget https://ffmpeg.org/releases/ffmpeg-<version>.tar.bz2 tar xjf ffmpeg-<version>.tar.bz2 cd ffmpeg-<version>

Configure FFmpeg

The configure script lets you customize your build. Common configuration options include enabling or disabling libraries, setting installation paths, and optimizing the build. There are some libraries that are not installed by default when using Homebrew or other package managers. This way gives you a ton more control.

Example configuration:

bash
./configure \ --prefix=/usr/local \ --enable-gpl \ --enable-nonfree \ --enable-libx264 \ --enable-libx265 \ --enable-libvpx \ --enable-libfdk-aac \ --enable-libopus \ --enable-libmp3lame \ --enable-libass \ --enable-shared \ --disable-static

Key Options:

• --prefix: Sets the installation directory (default is /usr/local).

• --enable-gpl: Enables GPL-licensed libraries (e.g., libx264).

• --enable-nonfree: Required for proprietary libraries (e.g., libfdk-aac).

• --enable-lib<name>: Enables specific libraries for encoding/decoding.

• --disable-static: Builds shared libraries only (useful for runtime linking).

• --enable-shared: Builds dynamic libraries for easier linking.

Run ./configure --help to see all available options.

Compile the Source

Start the build process:

bash
make

Install

Install the compiled binaries:

bash
sudo make install

Verify the Installation

Check if FFmpeg is installed correctly:

bash
ffmpeg -version

The output should display the compiled version and enabled features.

Optional Steps

a. Add FFmpeg to the PATH

If FFmpeg isn’t accessible globally, add its location to your PATH:

bash
export PATH="/usr/local/bin:$PATH"

Make this change permanent by adding the line to ~/.bashrc or ~/.zshrc.

b. Example for Minimal Build

If you only need basic features (e.g., H.264 support):

bash
./configure --prefix=/usr/local --enable-gpl --enable-libx264 make sudo make install

LinkUnderstand Basic Syntax

Since FFmpeg is a command line interface, commands can get quite lengthy very quickly. When supplying options and arguments, it's best to refer to the ffmpeg documentation if you're ever unsure.

General syntax

bash
ffmpeg [global options] [input options] -i [input file] [output options] [output file]

Example:

bash
ffmpeg -i input.mp4 -c:v libx264 output.mov

One thing to note here is that options supplied before the input file are input options so they mostly either time related (start time) or could be for raw video files and tell the decoder certain information that the auto detect wouldn't capture.

LinkDocumentation and Help

Some common options are:

-f format

Forces FFmpeg to use a specific input format (e.g., mp4, mkv).

-ss
Seeks to a specific time in the input file (e.g., -ss 00:01:30 for 1m30s).

-t
Processes only for a specific duration (e.g., -t 60 for 60 seconds).

-c or -codec (Set Codec)

Specifies the codec for streams (Use -c:v for video, -c:a for audio, and -c:s for subtitles)

-r (Frame Rate)

Sets the frame rate for the output video.

However, if you'd like view more of the options:

• Check the official FFmpeg Documentation.

• Use the -h flag to explore options: ffmpeg -h

LinkBest Practices

• Always back up your files.

• Experiment with small files to test commands.

• Read FFmpeg error messages carefully—they’re often descriptive.

LinkGoing Deeper

If you're looking for to go poke around how FFmpeg is built and the corresponding parts, be sure to check out their website and source code.

Arrow RightBack to Articles

No credit card required to start using Mux.