FFmpeg provides a subsystem for hardware acceleration.
Hardware acceleration allows to use specific devices (usually graphical card > or other specific devices) to perform multimedia processing. This allows to use dedicated hardware to perform demanding computation while freeing the CPU from such computations. Typically hardware acceleration enables specific hardware devices (usually the GPU) to perform operations related to decoding and encoding video streams, or filtering video.
When using FFmpeg the tool, HW-assisted decoding is enabled using through the
-hwaccel option, which enables a specific decoder. Each decoder may have specific limitations (for example an H.264 decoder may only support baseline profile). HW-assisted encoding is enabled through the use of a specific encoder (for example nvenc_h264). Filtering HW-assisted processing is only supported in a few filters, and in that case you enable the OpenCL code through a filter option.
There are several hardware acceleration standards API, some of which are supported to some extent by FFmpeg.
"-hwaccel auto" option allows you to select the hardware-based accelerated decoding to use for the encode session.
You can add this param with "auto" before input (if your x264 is compiled with OpenCL support you can try to add -x264opts param), for example:
ffmpeg -hwaccel auto -i input -vcodec libx264 -x264opts opencl output
Sorry, but I can't remember how to list all available options for "-hwaccel".
Also you can try this: