[FFmpeg-user] Build FFmpeg4.0 with opencl

Dennis Mungai dmngaie at gmail.com
Sat Apr 28 17:03:19 EEST 2018


Either way, for OpenCL enablement, all platforms require the following:

1. OpenCL headers.

2. The platform's OpenCL drivers (which provide the ICD, the installable
Client Driver Model).

3. An installed GPU driver. This is important because on Linux, with a
package manager, do not assume that installing either a device driver or an
ICD will instantly satisfy this dependency.

I'll provide an example:

Say you have a system containing an NVIDIA CUDA capable GPU that's also
supported by the mainline driver (as of the moment, Kepler+) on Ubuntu
Linux.

Here's what you would do:

1. Install the CUDA repo, as shown here:
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=debnetwork

2. Install the CUDA package, which automatically fetches the device driver
and the OpenCL ICD as a dependency.

Then install the OpenCL headers package:

sudo apt install opencl-headers

3. Then build FFmpeg with the appropriate flags enabled.


The scope of OpenCL enablement in FFmpeg:

OpenCL's enablement in FFmpeg comes in two ways:

(a). Some encoders, such as libx264, if built with OpenCL enablement, can
utilize these capabilities for accelerated lookahead functions. The
performance impact for this enablement will vary with the GPU on the
platform, and with older GPUs, may slow down the encoder. Lower power
platforms such as specific AMD APUs and their SoCs may see modest
performance improvements at best, but on modern, high performance GPUs,
your mileage may vary. Expect no miracles. The reason OpenCL lookahead is
available for this library in particular is that the lookahead algorithms
for OpenCL are easily parallelized.

For instance, you can combine the "-hwaccel auto" option which allows you
to select the hardware-based accelerated decoding to use for the encode
session with libx264. 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



(b). FFmpeg, in particular, can utilize OpenCL with *some* filters, namely
program_opencl <https://ffmpeg.org/ffmpeg-filters.html#program_005fopencl-1>
and opencl_src <https://ffmpeg.org/ffmpeg-filters.html#openclsrc> as
documented in the filters documentation, among others.

See this example
<https://stackoverflow.com/questions/47505257/ffmpeg-impossible-to-convert-between-the-formats-supported-by-the-filter>
on stackoverflow  on how to initialize the OpenCL platform before use.



On 25 April 2018 at 21:23, Dennis Mungai <dmngaie at gmail.com> wrote:

> With OpenCL enablement, I'd like to know what platform you're on.
>
> Wndows, a variant of Linux or Mac OSX.
>
> From there, we can assist with build issues.
>
> On 25 April 2018 at 19:44, Dong QingDan <dongqingdan at gmail.com> wrote:
> > Hello.
> > How are you?
> > I am trying to compile ffmpeg4.0 with  opencl.
> > but it failed with "Opencl not found"
> > I want to know the solution for this.
> > I appreciate you help me.
> > regards.
> > _______________________________________________
> > ffmpeg-user mailing list
> > ffmpeg-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-user mailing list