[FFmpeg-devel] [PATCH 00/15] OpenCL infrastructure, filters

Mark Thompson sw at jkqxz.net
Sun Nov 26 17:50:03 EET 2017

On 26/11/17 13:07, hydra3333 at gmail.com wrote:
> OK, the experimental -opencl_bench option has been removed by recent commits.
> Thank you for the updates to OpenCL.
> It cross-compiles OK, however I'm not sure about the replacement functionality.  So, 2 things.
> 1. may I enquire how one ascertains the numbers to use like this ?
>   -opencl_options platform_idx=1:device_idx=0

Most systems have a "clinfo" program which will list all the queryable properties of the available devices.

> The old -opencl_bench told me I have these devices - OpenCL using the nvidia 750Ti is the one I wish to use.
> platform_idx    device_idx    device_name    runtime
> 1    0    GeForce GTX 750 Ti    1801
> 0    0            Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz    11210
> 2. I must have misinterpreted -init_hw_device and -filter_hw_device as well for use in Windows 10 (please see the error below)
>   -opencl_options platform_idx=1:device_idx=0 -init_hw_device opencl -filter_hw_device opencl
> Advice would be most welcomed.

I've added documentation for the opencl device as an option to -init_hw_device in <http://git.videolan.org/?p=ffmpeg.git;a=commit;h=37c57df18e7c46436fa791abf40f4c3031ab56f4>.

> "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -opencl_options platform_idx=1:device_idx=0 -init_hw_device opencl -filter_hw_device opencl -i ".\test_01.mpg" -an -map_metadata -1 -sws_flags lanczos+accurate_rnd+full_chroma_int+full_chroma_inp -filter:v yadif=0:0:0,unsharp_opencl=lx=3:ly=3:la=0.5:cx=3:cy=3:ca=0.5,setdar=dar=16/9 -r 25 -c:v h264_nvenc -preset slow -bf 2 -g 50 -refs 3 -rc:v vbr_hq -rc-lookahead:v 32 -cq 22 -qmin 16 -qmax 25 -coder cabac -movflags +faststart -profile:v high -level 4.1 -pixel_format yuv420p -y ".\test_01.newest.MP4"
> ffmpeg version N-89088-gce001bb8fc Copyright (c) 2000-2017 the FFmpeg developers
>  built with gcc 7.2.0 (GCC)
>  configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --pkg-config=pkg-config --pkg-config-flags=--static --enable-gray --enable-version3 --disable-debug --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-w32threads --enable-nvenc --enable-cuda --enable-cuvid --enable-d3d11va --enable-libsoxr --enable-fontconfig --enable-libass --enable-libbluray --enable-iconv --enable-libtwolame --enable-libzvbi --enable-libcaca --enable-libmodplug --extra-libs=-lstdc++ --extra-libs=-lpng --extra-libs=-loleaut32 --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-libopus --enable-bzlib --enable-libopencore-amrnb --enable-libopencore-amrwb
> --enable-libvo-amrwbenc --enable-libvpx --enable-libilbc --enable-libwavpack --enable-libwebp --enable-libgme --enable-dxva2 --enable-gray --enable-libopenh264 --enable-libmysofa --enable-libflite --enable-lzma --enable-libsnappy --enable-libzimg --enable-libbs2b --enable-gmp --enable-libfribidi --enable-cross-compile --enable-pic --extra-libs=-lpsapi --extra-libs=-lspeexdsp --disable-schannel --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCACA_STATIC --enable-gpl --enable-avisynth --enable-frei0r --enable-filter=frei0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libmfx --enable-avresample --enable-libcdio --extra-cflags='-mtune=generic' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-decklink
> --enable-libfdk-aac --enable-opencl --enable-runtime-cpudetect --extra-libs=-lcrypt32 --extra-libs=-lshlwapi --extra-libs=-lstdc++ --extra-libs=-lass --extra-libs=-lfontconfig --extra-libs=-lexpat --extra-libs=-lfribidi --extra-libs=-lfreetype --extra-libs=-lharfbuzz --extra-libs=-lbz2 --extra-libs=-llzma --extra-libs=-liconv --extra-libs=-lcdio --extra-libs=-lcdio_paranoia --extra-libs=-lz --extra-libs=-lpsapi --extra-libs=-lspeexdsp --extra-libs=-lgdi32 --extra-libs=-lwinmm
>  Invalid device specification "opencl": unknown device type
> Failed to set value 'opencl' for option 'init_hw_device': Invalid argument
> Error parsing global options: Invalid argument
>From docs:

-init_hw_device type[=name][:device[,key=value...]]
    Initialise a new hardware device of type type called name, using the given device parameters. If no name is specified it will receive a default name of the form "type%d". 

-filter_hw_device name
    Pass the hardware device called name to all filters in any filter graph.

So, either give it a name explicitly or deduce what the name will be:

-init_hw_device opencl=arbitrary_name:1.0 -filter_hw_device arbitrary_name


-init_hw_device opencl:1.0 -filter_hw_device opencl0

(There is some thought of adding an option -opencl_device working like -vaapi_device to avoid the two steps for simple upload.  The most useful cases all use device derivation/mapping to keep things on the GPU side, though, so I'm not entirely sure whether it's actually wanted.)

- Mark

More information about the ffmpeg-devel mailing list