FFmpeg with OpenCL support - Ubuntu 18.04
OpenCL is not what you need.

In https://trac.ffmpeg.org/wiki/HWAccelIntro, see the section on “FFmpeg API Implementation Status” — Notice that OpenCL is not applicable for encoding and decoding, only for use in filters.

That's because OpenCL is a low level API used for writing code in such a way that it can be accelerated by GPUs or CPU SIMD instructions depending on the platform/driver. It is used in FFmpeg to implement various filters, but you aren't using any filters. If you really want to use OpenCL for encoding/decoding, you will have to start writing your own encoder/decoder first.

For your use case (encoding a video from source frames), you are better off using an API specifically designed for video encoding. These use the separate special purpose video encoding/decoding functionality found on most modern GPUs (including integrated GPUs). The best choice depends on your platform and use case, but for example this page has some examples for using VAAPI: https://trac.ffmpeg.org/wiki/Hardware/VAAPI. Usually this means selecting a different encoder, for example h264_vaapi instead of x264 (which is a purely CPU-based encoder). To ensure good performance, avoid copying frames between host/CPU memory and device/GPU memory as much as possible.