-
Notifications
You must be signed in to change notification settings - Fork 151
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.
© 2023 Advanced Micro Devices, Inc. All rights reserved.
© 2023 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) 2023 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/
-
Install MSYS2 from http://msys2.github.io. Suppose installed at 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, 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 -
Create an “AMF” folder in the directory in the MSYS2 system include path "C:\msys64\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.
-
In the Windows “Start” menu, from “Visual Studio 2022” run “x64 Native Tools Command Prompt for VS 2022”
-
In the “x64 Native Tools Command Prompt for VS 2022” prompt,
C:\Program Files\Microsoft Visual Studio\2022\Community>cd c:\msys64 C:\msys64>msys2_shell.cmd -mingw64 -use-full-path
This will launch a MinGW x64 Prompt.
-
In the MinGW x64 Prompt, clone the ffmpeg source code
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
-
Configure
cd ffmpeg ./configure --extra-cflags=-I/usr/local/include --toolchain=msvc --enable-amf
-
Make
make -j
-
The binary files are built in the ffmpeg folder.