Skip to content

VLC and AMF

Huts, Roman edited this page Dec 13, 2022 · 1 revision

Advanced Micro Devices

AMF Encoder in VLC Media Player

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.

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


VLC media player supports AMF encoders by using the FFmpeg library.

To use AMF encoders in VLC, download the latest nightly builds from https://nightlies.videolan.org/ or compile VLC from sources.

Since VLC 4.0 nightly builds might be unstable, we recommend to use the stable VLC version from branch 3.0.18 by cherry-picking some commits from the master branch. AMF support is already integrated into the master branch, therefore cherry-picking commits is needed for older versions only.

git clone http://git.videolan.org/git/vlc.git vlc
cd vlc
git checkout 3.0.18
# The commits below are needed for enabling AMF support in VLC
git chery-pick f1a2665f609d9d5bd7e662a8a2519018e1d3f61c
git chery-pick dc1decb2609ca44c78b8bd2db77dd87a85dbcb92

Use the following instructions to build VLC from sources:

  1. Building for Windows OS
  2. Building for Linux OS

Note: If you are compiling VLC from sources, please make sure that you have compiled the FFmpeg library with AMF support (check the build logs from FFmpeg to confirm).

Using AMF Encoders in VLC

  1. Run VLC and navigate to the FFmpeg menu for video codecs:

    Tools -> Preferences -> Show settings (All) -> Input/Codecs -> Video Codecs -> FFmpeg

Settings

  1. Enter the h264_amf or hevc_amf encoder as the codec name inside the Encoding section.

Encoder

  1. By default, VLC uses the x264/x265 software encoders because they have a higher priority than the FFmpeg encoders in the VLC settings. To force using h264_amf / hevc_amf hardware encoders instead of x264/x265, you need to choose FFmpeg audio/video encoder in the stream output menu:

    Tools -> Preferences -> Stream Output -> Sout stream -> Transcode section.

Encoder

  1. AMF encoders can be used in VLC for transcoding and streaming. In VLC, transcoding is exactly the same as streaming across the network, except that the output is sent to a file instead of the network.

  2. You can refer to the following guides on how to transcode and stream video using VLC:

  1. To check that the AMF encoders work, you may increase the logging level in the messages menu:

    Tools -> Messages

    Choose Verbosity level 2 (debug). If the AMF encoder works, then during transcoding/streaming there will be something like this inside the VLC logs:

    avcodec debug: using FFmpeg Lavc58.134.100
    ....
    avcodec debug: found encoder H264 - MPEG-4 AVC (part 10)
    main debug: using encoder module "avcodec"
    
  2. If you need to pass options to the AMF encoders, then you can use the Advanced options field in the FFmpeg settings:

    Tools -> Preferences -> Show settings (All) -> Input/Codecs -> Video Codecs -> FFmpeg

    The full list of options for the AMF encoder can be seen with the following command:

    ffmpeg -h encoder=h264_amf
    

    Examples of passing options to the AMF encoder in FFmpeg:

    # transcode using the AMF H264 HW encoder and default encoding settings
    ffmpeg -i input.mp4 -codec:v h264_amf output.mp4
    
    # set the bitrate to 5000k
    ffmpeg -i input.mp4 -codec:v h264_amf -b:v 5000k output.mp4
    
    # use AMF HEVC HW encoder with the latency constrained variable bitrate method
    # for rate control, pre-analysis enabled, and AMF logging to the debug output
    ffmpeg -i input.mp4 -codec:v hevc_amf -rc 1 -preanalysis true -log_to_dbg true output.mp4
    
    # set the encoding usage to "ultra low latency" as the baseline template for encoder settings
    ffmpeg -i input.mp4 -codec:v hevc_amf -usage ultralowlatency output.mp4

Advanced options

More information about AMF encoder settings can be found in the AMF documentation:

  1. AMF_Video_Encode_API.pdf
  2. AMF_Video_Encode_HEVC_API.pdf