Skip to content

Build FFmpeg with AMF Support

Huts, Roman edited this page Jul 16, 2025 · 3 revisions

Advanced Micro Devices

Build FFmpeg with AMF Support

Usage Guide


Disclaimer

The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions, and typographical errors. The information contained herein is subject to change and may be rendered inaccurate for many reasons, including but not limited to product and roadmap changes, component and motherboard version changes, new model and/or product releases, product differences between differing manufacturers, software changes, BIOS flashes, firmware upgrades, or the like. Any computer system has risks of security vulnerabilities that cannot be completely prevented or mitigated. AMD assumes no obligation to update or otherwise correct or revise this information. However, AMD reserves the right to revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes. THIS INFORMATION IS PROVIDED ‘AS IS.” AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS, OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION. AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO ANY PERSON FOR ANY RELIANCE, DIRECT, INDIRECT, SPECIAL, OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.

© 2025 Advanced Micro Devices, Inc. All rights reserved.


Copyright Notice

© 2025 Advanced Micro Devices, Inc. All rights reserved

Notice Regarding Standards. AMD does not provide a license or sublicense to any Intellectual Property Rights relating to any standards, including but not limited to any audio and/or video codec technologies such as MPEG-2, MPEG-4; AVC/H.264; HEVC/H.265; AV1; AAC decode/FFMPEG; AAC encode/FFMPEG; VC-1; and MP3 (collectively, the “Media Technologies”). For clarity, you will pay any royalties due for such third party technologies, which may include the Media Technologies that are owed as a result of AMD providing the Software to you.

MIT license

Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Table of Contents

1 Introduction

FFmpeg uses the AMD Advanced Media Framework (AMF) library for accelerated H.264, HEVC, and AV1 encoding on AMD GPUs.

The executables released by the FFmpeg officially support AMD AMF by default. You can go directly to the official FFmpeg website https://ffmpeg.org/download.html to download these executables.

In some cases, users like to build FFmpeg with AMF. In the following part we will give methods on how users can build FFmpeg. General instructions on how to build FFmpeg can be found at https://trac.ffmpeg.org/wiki/CompilationGuide/Generic.

To enable AMF support, you need to download the AMF framework header files(version 1.4.29+) from https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git and use the --enable-amf configuration when building FFmpeg.

2 Build FFmpeg with AMF for Linux

We will use Ubuntu to show how to build FFmpeg on the Linux operating system.

  1. Create an “AMF” directory in the system include path /usr/local/include

  2. Download AMD AMF from https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git . Copy the contents of AMF/amf/public/include/ to the above “AMF” directory.

  3. Install supporting packages

    sudo apt-get install install yasm
    
    sudo apt-get install pkg-config
    
    sudo apt-get install gcc
    
    sudo apt-get install make
    
    sudo apt-get install diffutils
    
    sudo apt-get install git
  4. Clone the FFmpeg source code

    git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
  5. Configure

    cd ffmpeg
    
    ./configure --enable-amf
  6. Make

    make -j
  7. The binary files are built in the ffmpeg folder

3 Build FFmpeg with AMF for Windows

To compile FFmpeg under Windows operating system, we use two typical compilers.

3.1 Using the MinGW Compiler

  1. Install MSYS2 from http://msys2.github.io . Suppose installed at C:\msys64

  2. Run C:\msys64\mingw64.exe, which will launch the “MSYS2 MinGW x64 Prompt”

  3. In the MSYS2 MinGW x64 Prompt, install all supporting packages

    pacman -S make pkgconf diffutils mingw-w64-x86_64-nasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2 mingw-w64-x86_64-gdb mingw-w64-x86_64-dlfcn git
    
  4. Inside your Windows Environment variables, add “C:\msys64\mingw64\bin” to the “Path” of “User variables for username”, here “username” should be replaced by the actual user of current Windows OS

  5. Create an “AMF” directory in the MSYS2 system include path "C:\msys64\usr\local\include\amd".

  6. Download AMD AMF from https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git . Copy the contents of AMF/amf/public/include/ to the above “AMF” directory

  7. Clone the FFmpeg source code

    git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
    
  8. Configure

    cd ffmpeg
    
    ./configure --enable-amf --extra-cflags=-I/usr/local/include/amd
    
  9. Make

    make -j
    
  10. The binary files are built in the ffmpeg folder

3.2 Using the MSVC Compiler

  1. Install Microsoft Visual Studio 2022 from https://visualstudio.microsoft.com/vs/

    1. When installing VS, under workloads select: "Desktop development with C++" and under individual components ensure "Windows 11 SDK (10.0.26100.3916)" or later is selected. Earlier versions may work as well.
  2. Install MSYS2 from http://msys2.github.io. Install in default location C:\msys64

  3. Run C:\msys64\mingw64.exe, which will launch MSYS2 MinGW x64 Prompt

  4. In the MSYS2 MinGW x64 Prompt, install all supporting packages:

    pacman -S make pkgconf diffutils nasm git
    
  5. Inside your Windows Environment variables, under User variables for <user>, edit the "Path" variable and add C:\msys64\mingw64\bin

  6. Create an "AMF" folder (from file explorer) in C:\msys64\usr\local\include\. You may need to create the "include" folder yourself as well. This is the MSYS2 system include path.

  7. Download AMD AMF from https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git. Copy the contents of AMF/amf/public/include/ to the "AMF" folder from step 6.

  8. In the Windows Start Menu, from the Visual Studio 2022 dropdown, run x64 Native Tools Command Prompt for VS 2022. You can also directly search for x64 Native Tools Command Prompt for VS 2022.

  9. In the x64 Native Tools Command Prompt for VS 2022 prompt, run:

    cd c:\msys64
    msys2_shell.cmd -mingw64 -use-full-path
    

    This will launch a MinGW x64 Prompt. You can close the x64 Native Tools Command Prompt now. The remaining steps will be using this new prompt.

  10. In the MinGW x64 Prompt, clone the FFmpeg source code (your current location should be C:/msys64/home/<user>):

    git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
    
  11. Configure (still in the MinGW x64 Prompt). This step may take a few minutes, the command is done once the $ symbol appears on the new line.

    cd ffmpeg
    ./configure --extra-cflags=-I/usr/local/include --toolchain=msvc --enable-amf
    
  12. If you encounter failure/error in the build, the compiler may need you to manually specify paths to necessary files. If your configure succeeds you may skip this step.

    1. Find the error

      1. Run command explorer ffbuild or navigate to C:/msys64/home/<user>/ffmpeg/ffbuild manually (from file explorer)
      2. Find config.log, right click, and select Edit
      3. Scroll to the bottom to find the error. It should be something like fatal error C1083: Cannot open include file: 'ctype.h': No such file or directory
    2. Locate the file

      1. Using file explorer, from your C drive, search for filename:<missing file name> and copy the path to the file search file name
      2. If there are multiple versions of this file, choose the version with Program Files or msys64 as the parent folder. Choose the newest version if applicable (version should be part of the file path)
        • Example: C:\Program Files\Windows Kits\10\Include\10.0.19041.0\ucrt

      choose correct file

      choose correct version

    3. Add the path

      1. If the file has the .lib extension: add this path to the following command: export LIB="<path1>;<path2>;..."
      2. If the file has the .h extension: add this path to the following command: export INCLUDE="<path1>;<path2>;..."
      • You should end up with something like this (if you need to add multiple files):

      export LIB="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.26100.0/um/x64;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.44.35207\lib\onecore\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.26100.0\ucrt\x64"

      export INCLUDE="C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.44.35207\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared"

    4. Reconfigure

      1. Run your export commands
      2. Re-run ./configure --extra-cflags=-I/usr/local/include --toolchain=msvc --enable-amf
      3. Repeat steps 1-4 until configuration succeeds

      Keep track of all the paths you add, you may need these export commands for future builds

  13. Make

    make -j
    

    note: for future builds, running the ./configure command is not neccessary. you can just run the export commands and make

  14. The binary files are built in the ffmpeg folder msys64/home/<user>/ffmpeg These should include:

    • ffmpeg.exe
    • ffmpeg_g.exe
    • ffprobe.exe
    • ffprobe_g.exe
Clone this wiki locally