-
Notifications
You must be signed in to change notification settings - Fork 152
Build FFmpeg with AMF Support
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.
© 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.
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.
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.
We will use Ubuntu to show how to build FFmpeg on the Linux operating system.
-
Create an “AMF” directory in the system include path /usr/local/include
-
Download AMD AMF from https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git . Copy the contents of AMF/amf/public/include/ to the above “AMF” directory.
-
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
-
Clone the FFmpeg source code
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
-
Configure
cd ffmpeg ./configure --enable-amf
-
Make
make -j
-
The binary files are built in the ffmpeg folder
To compile FFmpeg under Windows operating system, we use two typical compilers.
-
Install MSYS2 from http://msys2.github.io . Suppose installed at C:\msys64
-
Run
C:\msys64\mingw64.exe
, which will launch the “MSYS2 MinGW x64 Prompt” -
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
-
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
-
Create an “AMF” directory in the MSYS2 system include path "C:\msys64\usr\local\include\amd".
-
Download AMD AMF from https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git . Copy the contents of AMF/amf/public/include/ to the above “AMF” directory
-
Clone the FFmpeg source code
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
-
Configure
cd ffmpeg ./configure --enable-amf --extra-cflags=-I/usr/local/include/amd
-
Make
make -j
-
The binary files are built in the ffmpeg folder
-
Install Microsoft Visual Studio 2022 from https://visualstudio.microsoft.com/vs/
- 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.
-
Install MSYS2 from http://msys2.github.io. Install in default location
C:\msys64
-
Run
C:\msys64\mingw64.exe
, which will launch MSYS2 MinGW x64 Prompt -
In the MSYS2 MinGW x64 Prompt, install all supporting packages:
pacman -S make pkgconf diffutils nasm git
-
Inside your Windows Environment variables, under User variables for <user>, edit the "Path" variable and add
C:\msys64\mingw64\bin
-
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. -
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. -
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.
-
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.
-
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
-
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
-
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.
-
Find the error
- Run command
explorer ffbuild
or navigate toC:/msys64/home/<user>/ffmpeg/ffbuild
manually (from file explorer) - Find config.log, right click, and select Edit
- 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
- Run command
-
Locate the file
- Using file explorer, from your C drive, search for
filename:<missing file name>
and copy the path to the file - If there are multiple versions of this file, choose the version with
Program Files
ormsys64
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
- Example:
- Using file explorer, from your C drive, search for
-
Add the path
- If the file has the .lib extension: add this path to the following command:
export LIB="<path1>;<path2>;..."
- 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"
- If the file has the .lib extension: add this path to the following command:
-
Reconfigure
- Run your export commands
- Re-run
./configure --extra-cflags=-I/usr/local/include --toolchain=msvc --enable-amf
- Repeat steps 1-4 until configuration succeeds
Keep track of all the paths you add, you may need these export commands for future builds
-
-
Make
make -j
note: for future builds, running the ./configure command is not neccessary. you can just run the export commands and make
-
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