Installation

Conda

Due to the complexity of the dependencies, PyAV is not always the easiest Python package to install. The most straight-foward install is via conda-forge:

conda install av -c conda-forge

See the Conda quick install docs to get started with (mini)Conda.

Dependencies

PyAV depends upon several libraries from FFmpeg (version 3.0 or higher):

  • libavformat
  • libavcodec
  • libavdevice
  • libavutil
  • libswscale
  • libswresample:

and a few other tools in general:

  • pkg-config
  • Python’s development headers

Mac OS X

On Mac OS X, Homebrew saves the day:

brew install ffmpeg pkg-config

Ubuntu >= 14.04 LTS

On Ubuntu 14.04 LTS everything can come from the default sources:

# General dependencies
sudo apt-get install -y python-dev pkg-config

# Library components
sudo apt-get install -y \
    libavformat-dev libavcodec-dev libavdevice-dev \
    libavutil-dev libswscale-dev libswresample-dev libavfilter-dev

Ubuntu 12.04 LTS

On Ubuntu 12.04 LTS you will be unable to satisfy these requirements with the default package sources. We recommend compiling and installing FFmpeg from source. For FFmpeg:

wget http://ffmpeg.org/releases/ffmpeg-2.7.tar.bz2
tar -xjf ffmpeg-2.7.tar.bz2
cd ffmpeg-2.7

./configure --disable-static --enable-shared --disable-doc
make
sudo make install

See this script for a very detailed installation of all dependencies.

Windows

It is possible to build PyAV on Windows without Conda by installing FFmpeg yourself, e.g. from the shared and dev packages.

Unpack them somewhere (like C:\ffmpeg), and then tell PyAV where they are located.

PyAV

Via PyPI/CheeseShop

$ pip install av

Via Source

# Get PyAV from GitHub.
$ git clone git@github.com:mikeboers/PyAV.git
$ cd PyAV

# Prep a virtualenv.
$ source scripts/activate.sh

# Install basic requirements.
$ pip install -r tests/requirements.txt

# Optionally build FFmpeg.
$ ./scripts/build-deps

# Build PyAV.
$ make
# or
$ python setup.py build_ext --inplace

On Mac OS X you may have issues with regards to Python expecting gcc but finding clang. Try to export the following before installation:

export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

On Windows you must indicate the location of your FFmpeg, e.g.:

python setup.py build --ffmpeg-dir=C:\ffmpeg