How to Check Supported Codecs and Hardware Acceleration in FFmpeg
When working with video in FFmpeg, it's essential to know which encoding formats are supported and if your computer's hardware (such as the graphics card) can be used for hardware acceleration. Utilizing hardware acceleration can significantly speed up video processing. This article will show you how to check this information in a straightforward manner.
I. Check All Supported Codecs
The easiest way to find out which audio and video formats your FFmpeg can handle is to let it list them.
1. View All Codecs
Open your command-line terminal (CMD or PowerShell on Windows, Terminal on macOS or Linux) and enter the following command:
ffmpeg -codecs
After execution, you'll see a lengthy list. Each line has a similar format. The key is understanding the letters at the beginning:
Codecs:
D..... = Decoding supported
.E.... = Encoding supported
..V... = Video
..A... = Audio
..S... = Subtitle
...I.. = Intra frame-only
....L. = Lossy
.....S = Lossless
-------
D.V.L. h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
DEV.LS h264_amf AMD AMF H.264 Encoder (codec h264)
DEV.L. h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)
D.A.L. aac AAC (Advanced Audio Coding)
How to Interpret the List:
- The letters in the first column are the most important. For example,
D.V.L.
indicates a codec that supports decoding, is for video, and uses lossy compression. - If both
D
andE
are present, the format can both be decoded (read) and encoded (generated). - The second column is the codec's name, such as
h264
,h264_nvenc
,aac
. These names are used in FFmpeg commands to specify codecs. - The third column is a description to help you understand what the codec is.
2. View Only Encoders or Decoders
If the list is too long, you can view only the parts you're interested in.
View supported encoders:
bashffmpeg -encoders
View supported decoders:
bashffmpeg -decoders
This simplifies the search process.
II. Check Hardware Acceleration Support
Hardware acceleration usually has two aspects: whether FFmpeg itself supports a hardware acceleration technology and whether there are corresponding codecs that can utilize it.
Step 1: Check Which Hardware Acceleration Technologies FFmpeg Supports
This command tells you which hardware acceleration features were included when your FFmpeg version was compiled.
ffmpeg -hwaccels
You might see output like this:
Hardware acceleration methods:
vaapi
qsv
cuda
cuvid
d3d11va
videotoolbox
These names correspond to different technologies and manufacturers:
cuda
,cuvid
,nvenc
: Primarily used by NVIDIA graphics cards.nvenc
mainly handles encoding, andcuvid
mainly handles decoding.qsv
: Intel integrated graphics' Quick Sync Video technology.vaapi
,vdpau
: Commonly used video acceleration interfaces on Linux systems, potentially used by both Intel and AMD graphics cards.d3d11va
,dxva2
: Exclusive to Windows systems, DirectX-based acceleration technology, mainly for decoding.videotoolbox
: Exclusive to macOS systems.amf
: Used by AMD graphics cards.
If this list is empty, your FFmpeg version does not support any hardware acceleration.
Step 2: Find Codecs Corresponding to Hardware Technologies
Once you know which technology is supported, you can find the specific codecs that can utilize it. These codecs usually have a special suffix, like _nvenc
(NVIDIA encoding), _qsv
(Intel encoding), or _cuvid
(NVIDIA decoding).
You can use grep
(Linux/macOS) or findstr
(Windows) to quickly filter.
If you use an NVIDIA graphics card:
Search for hardware encoders:
bash# Linux or macOS ffmpeg -encoders | grep nvenc # Windows ffmpeg -encoders | findstr "nvenc" # Output similar to V....D av1_nvenc NVIDIA NVENC av1 encoder (codec av1) V....D h264_nvenc NVIDIA NVENC H.264 encoder (codec h264) V....D hevc_nvenc NVIDIA NVENC hevc encoder (codec hevc)
Search for hardware decoders:
bash# Linux or macOS ffmpeg -decoders | grep cuvid # Windows ffmpeg -decoders | findstr "cuvid" # Output similar to V..... av1_cuvid Nvidia CUVID AV1 decoder (codec av1) V..... h264_cuvid Nvidia CUVID H264 decoder (codec h264) V..... hevc_cuvid Nvidia CUVID HEVC decoder (codec hevc) V..... mjpeg_cuvid Nvidia CUVID MJPEG decoder (codec mjpeg) V..... mpeg1_cuvid Nvidia CUVID MPEG1VIDEO decoder (codec mpeg V..... mpeg2_cuvid Nvidia CUVID MPEG2VIDEO decoder (codec mpeg V..... mpeg4_cuvid Nvidia CUVID MPEG4 decoder (codec mpeg4) V..... vc1_cuvid Nvidia CUVID VC1 decoder (codec vc1) V..... vp8_cuvid Nvidia CUVID VP8 decoder (codec vp8) V..... vp9_cuvid Nvidia CUVID VP9 decoder (codec vp9)
If you use Intel integrated graphics:
- Search for QSV-related codecs:bash
# Linux or macOS ffmpeg -codecs | grep qsv # Windows ffmpeg -codecs | findstr "qsv" # Output similar to DEV.L. av1 Alliance for Open Media AV1 (decoders: libdav1d libaom-av1 av1 av1_cuvid av1_qsv) (encod : libaom-av1 librav1e libsvtav1 av1_nvenc av1_qsv av1_amf av1_vaapi) DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_qsv h264_cuvid) (encoders ibx264 libx264rgb h264_amf h264_mf h264_nvenc h264_qsv h264_vaapi h264_vulkan) DEV.L. hevc H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv hevc_cuvid) (encode libx265 hevc_amf hevc_d3d12va hevc_mf hevc_nvenc hevc_qsv hevc_vaapi hevc_vulkan) DEVIL. mjpeg Motion JPEG (decoders: mjpeg mjpeg_cuvid mjpeg_qsv) (encoders: mjpeg mjpeg_qsv mjpeg_vaa DEV.L. mpeg2video MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_qsv mpeg2_cuvid) (encoders: mpeg2vide peg2_qsv mpeg2_vaapi) D.V.L. vc1 SMPTE VC-1 (decoders: vc1 vc1_qsv vc1_cuvid) DEV.L. vp8 On2 VP8 (decoders: vp8 libvpx vp8_cuvid vp8_qsv) (encoders: libvpx vp8_vaapi) DEV.L. vp9 Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid vp9_qsv) (encoders: libvpx-vp9 vp9_vaapi _qsv) DEV.L. vvc H.266 / VVC (Versatile Video Coding) (decoders: vvc vvc_qsv) (encoders: libvvenc)
If you use macOS:
- Search for VideoToolbox-related codecs:bash
# macOS ffmpeg -codecs | grep videotoolbox
III. Comprehensive Example: A Complete Check Process
Let's say you have an NVIDIA graphics card and want to convert a HEVC (H.265) video to H.264 format using hardware acceleration.
1. Check if HEVC can be hardware-decoded:
Run ffmpeg -decoders | grep cuvid
. If you see hevc_cuvid
in the results, it's supported.
V..... hevc_cuvid Nvidia CUVID HEVC decoder (codec hevc)
2. Check if H.264 can be hardware-encoded:
Run ffmpeg -encoders | grep nvenc
. If you see h264_nvenc
in the results, it's supported.
V..... h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)
3. Use Hardware Acceleration
Since the checks confirm support, you can confidently use them in your FFmpeg command. A typical command might look like this:
# -hwaccel cuvid # Globally enable cuvid hardware decoding acceleration
# -c:v hevc_cuvid # Specify the hevc_cuvid decoder to process the input video
# -c:v h264_nvenc # Specify the h264_nvenc encoder to generate the output video
# -c:a copy # Directly copy the audio, without re-encoding
ffmpeg -hwaccel cuvid -c:v hevc_cuvid -i input.mkv -c:v h264_nvenc -c:a copy output.mp4
By using these simple commands, you can gain a comprehensive understanding of your computer's FFmpeg capabilities and write more efficient video processing commands.