Tested on Windows 8.1, Windows 10 1809 and Windows 10 20H2 (all amd64)
- Build Tools for Visual Studio 2019
- cmake
- ninja
- git
- nasm
- python (3.7+)
- pip
Ensure that every requirement is on the system path and Windows can find it:
> where cmake
C:\Program Files\CMake\bin\cmake.exe
> where ninja
C:\Windows\System32\ninja.exe
> where git
C:\Program Files\Git\cmd\git.exe
C:\Program Files\Git\mingw64\bin\git.exe
> where nasm
C:\Program Files\NASM\nasm.exe
> where python
C:\Python39\python.exe
> where pip
C:\Python39\Scripts\pip.exeYour paths can be different but if you get INFO: Could not find files for the given pattern(s). that means this executable is not in path.
Warning: The build steps are tested only on amd64 (x86_64) architecture.
Open the Native Tools Command Prompt for VS 2019
It will open command line window but from it you will be able to compile code.
Create a folder just to have everything in the same place:
mkdir C:\python-avifcd C:\python-avif
Now you can clone the repositories:
git clone https://github.com/Julian/avif.gitgit clone https://github.com/AOMediaCodec/libavif.git
The directory with python module will now appear as
avifand the official avif implementation written in c will be calledlibavifYou will also need to clone and compile the AOM repository.
It can be done using script included in
libavif\extdirectory:cd libavif\extaom.cmdcd ..
After that you can configure libavif with AOM support:
- Ensure that you are in the main libavif directory (
cdshould giveC:\python-avif\libavif) cd cmakecmake .. -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON
- Ensure that you are in the main libavif directory (
Now open a new Native Tools Command Prompt for VS 2019 window as Administrator.
Change current directory to cmake in this window too, then compile and install the project.
cd C:\python-avif\libavif\cmakemsbuild INSTALL.vcxproj /p:Configuration=Release
After the installation is complete,
C:\Program Files (x86)\libaviffolder should be created and you will find there all necessary libavif resources. You can close the window that you opened as Administrator and continue in the first window.Then you can change directory to this project and change
INCLUDEvariable.cd C:\python-avif\avifset INCLUDE=%INCLUDE%;C:\Program Files (x86)\libavif\include
You should also copy
avif.libfile to project's directory:xcopy "C:\Program Files (x86)\libavif\lib\avif.lib" .
Now you can install the
avifPython package:$ python -m pip install .In order to import the library you should copy
avif.dll(that you can find inC:\Program Files (x86)\libavif\bin) to the installed module directory. You can usepip show avifto know where the module is installed.In my case it says:
... Location: c:\python39\lib\site-packages\avif-0.0.0-py3.9-win-amd64.egg ...Then you can copy the .dll:
xcopy "C:\Program Files (x86)\libavif\bin\avif.dll" "c:\python39\lib\site-packages\avif-0.0.0-py3.9-win-amd64.egg"
You should now be able to import the library without any errors!
>>> import avif
You can also run the examples.