brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -hwaccels lists the hardware acceleration your build has

Ffmpeg
~/tips/tip-ffmpeg-hwaccels-list-build

ffmpeg -hide_banner -hwaccels

Prints the hardware acceleration methods your ffmpeg build was compiled with.

Hardware decoding sounds nice, but it only works when your ffmpeg build includes it. One flag tells you what that build was compiled with, before you start debugging a command that will never work.

The ffmpeg manual describes -hwaccels as listing all hardware acceleration components enabled in this build of ffmpeg. It prints a list and exits.

ffmpeg -hide_banner -hwaccels

-hide_banner suppresses the banner, which the manual describes in exactly those words, so you only get the list. The names in it are what you can hand to the next option, -hwaccel, which the docs describe as using hardware acceleration to decode the matching streams:

ffmpeg -hwaccel <name> -i input.mp4 -f null -

Replace <name> with an entry from your own list. It is an input option, so it goes in front of -i. The -f null - at the end decodes and discards, which is a quick way to see whether decoding with that method works at all, without writing a file.

The caveat is in the manual’s wording: the list says what is enabled in the build, not what your machine can really do. A name can show up and still fail because the driver or the device is missing. If a Homebrew, apt or static build gives a different list than another one, that explains why the same command behaves differently on two machines.

Also note that -hwaccel only concerns decoding. Encoding with the GPU is a separate matter that uses its own encoder names. I have only checked the decode flags against the docs for this tip, so I would read the encoder part of the manual before I count on a speed gain.

My habit would be to run -hwaccels first, then try the decode test above on a short file, and only then touch the real command.

Further reading: ffmpeg documentation: -hwaccels, -hwaccel, -hide_banner

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a All Ffmpeg tips (38) All topics

Link