Since FFMPEG 2 is there OpenCL Support

Website, builds, or other suggestions.
nille02
Posts: 24
Joined: Tue Aug 14, 2012 3:47 pm

Since FFMPEG 2 is there OpenCL Support

Post by nille02 » Wed Jul 10, 2013 12:12 pm

Since FFMPEG 2 is there OpenCL Support but ffmpeg has to compiled with --enable-opencl

Ajaja
Posts: 69
Joined: Fri Mar 08, 2013 2:00 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by Ajaja » Thu Jul 11, 2013 7:37 pm

I made some tests.
Deshake:

Code: Select all

>ffmpeg.exe -i "Sam and Cocoa - shaky original.mp4" -vf deshake -b:v 3000 a1.mpeg
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 11 2013 21:58:14 with gcc 4.8.1 (rev2, Built by MinGW-builds project)
  configuration: --enable-lto --disable-shared --enable-static --prefix=/mingw/x86_64-w64-mingw32 --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libvpx --enable-libopus --enable-bzlib --enable-zlib --enable-frei0r --enable-libgsm --enable-gpl --extra-cflags='-DPTW32_STATIC_LIB -DLIBTWOLAME_STATIC' --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libvo-aacenc --enable-libschroedinger --enable-libbluray --enable-libxavs --enable-libsoxr --enable-libfreetype --enable-fontconfig --enable-libass --enable-libopenjpeg --enable-avisynth --enable-libtwolame --enable-libilbc --enable-libcaca --enable-libmodplug --enable-avresample --enable-libcdio --disable-w32threads --enable-gnutls --enable-libvidstab --enable-libnut --enable-dxva2 --enable-opencl --extra-libs=-lstdc++ --disable-runtime-cpudetect
  libavutil      52. 39.100 / 52. 39.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.101 / 55. 12.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 80.100 /  3. 80.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Sam and Cocoa - shaky original.mp4':
...
frame=  625 fps= 79 q=24.8 Lsize=    2438kB time=00:00:20.86 bitrate= 957.4kbits/s
video:2088kB audio:326kB subtitle:0 global headers:0kB muxing overhead 0.997919%

Code: Select all

>ffmpeg.exe -i "Sam and Cocoa - shaky original.mp4" -vf deshake=opencl=1 -b:v 3000 a2.mpeg
...
frame=  625 fps= 57 q=24.8 Lsize=    2438kB time=00:00:20.86 bitrate= 957.4kbits/s
Desahke: 79fps with CPU and 57fps with OpenCL.

Unsharp:

Code: Select all

>ffmpeg.exe -i "Sam and Cocoa - shaky original.mp4" -vf unsharp -b:v 3000 b1.mpeg
...
frame=  625 fps=385 q=24.8 Lsize=    3574kB time=00:00:20.86 bitrate=1403.5kbits/s

Code: Select all

>ffmpeg.exe -i "Sam and Cocoa - shaky original.mp4" -vf unsharp=opencl=1 -b:v 3000 b2.mpeg
...
frame=  625 fps= 50 q=24.8 Lsize=    3574kB time=00:00:20.86 bitrate=1403.5kbits/s
385fps with CPU vs 50fps with OpenCL.

What am I doing wrong?
My hardware: Intel Core i5-2450P, 8Gb, GeForce GTS 250 1Gb. Software: WIn7 x64, Nvidia Drivers v320.18

nille02
Posts: 24
Joined: Tue Aug 14, 2012 3:47 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by nille02 » Thu Jul 11, 2013 7:46 pm

i guess your GPU is to weak and it waist many time for copy the data to the GPU and back.

Where do you get the 2.0 build with opencl?

Ajaja
Posts: 69
Joined: Fri Mar 08, 2013 2:00 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by Ajaja » Thu Jul 11, 2013 7:57 pm

I build ffmpeg 2.0 with OpenCL by myself.

Checked in GPU-Z. Deshake - ~34% GPU load, unsharp ~79% GPU in this case. BTW, it it possible to use OpenCl with x264 in ffmpeg 2.0?

nille02
Posts: 24
Joined: Tue Aug 14, 2012 3:47 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by nille02 » Thu Jul 11, 2013 8:07 pm

Ajaja wrote:I build ffmpeg 2.0 with OpenCL by myself.

Checked in GPU-Z. Deshake - ~34% GPU load, unsharp ~79% GPU in this case. BTW, it it possible to use OpenCl with x264 in ffmpeg 2.0?
Then i think the most time is waist for data copy or the gpu has problems with the kernels.

for x264 you need to build x264 with the opencl patches. i never tried this because i was to lazy to compile everything and fontconfig make as cross compile some troubles .....

Ajaja
Posts: 69
Joined: Fri Mar 08, 2013 2:00 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by Ajaja » Thu Jul 11, 2013 8:25 pm

nille02 wrote:for x264 you need to build x264 with the opencl patches
I built latest git version of libx264 with opencl support, but can't find the way to apply new x264's --opencl option in ffmpeg with -v:c libx264 encoding. Looks like it's not implemented yet.

nille02
Posts: 24
Joined: Tue Aug 14, 2012 3:47 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by nille02 » Thu Jul 11, 2013 8:42 pm

do you tried "-x264opts opencl"?

e.g. -x264opts ref=9:opencl:crf=16.0

Ajaja
Posts: 69
Joined: Fri Mar 08, 2013 2:00 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by Ajaja » Thu Jul 11, 2013 8:54 pm

nille02 wrote:do you tried "-x264opts opencl"?
Thank you! It's works.

Code: Select all

>ffmpeg.exe -i skiing6-shaky-original.avi  -b:v 2000 -c:v libx264 -x264opts opencl -y a2.mp4
ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul 11 2013 21:58:14 with gcc 4.8.1 (rev2, Built by MinGW-builds project)
  configuration: --enable-lto --disable-shared --enable-static --prefix=/mingw/x86_64-w64-mingw32 --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libvpx --enable-libopus --enable-bzlib --enable-zlib --enable-frei0r --enable-libgsm --enable-gpl --extra-cflags='-DPTW32_STATIC_LIB -DLIBTWOLAME_STATIC' --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libvo-aacenc --enable-libschroedinger --enable-libbluray --enable-libxavs --enable-libsoxr --enable-libfreetype --enable-fontconfig --enable-libass --enable-libopenjpeg --enable-avisynth --enable-libtwolame --enable-libilbc --enable-libcaca --enable-libmodplug --enable-avresample --enable-libcdio --disable-w32threads --enable-gnutls --enable-libvidstab --enable-libnut --enable-dxva2 --enable-opencl --extra-libs=-lstdc++ --disable-runtime-cpudetect
  libavutil      52. 39.100 / 52. 39.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.101 / 55. 12.101
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 80.100 /  3. 80.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'skiing6-shaky-original.avi':
  Metadata:
    encoder         : transcode-1.1.1
  Duration: 00:00:36.00, start: 0.000000, bitrate: 6692 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 22050 Hz, mono, s16p, 128 kb/s
[libx264 @ 00000000024d7240] using SAR=1/1
[libx264 @ 00000000024d7240] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 00000000024d7240] OpenCL acceleration enabled with NVIDIA Corporation GeForce GTS 250 
[libx264 @ 00000000024d7240] Compiling OpenCL kernels...
[libx264 @ 00000000024d7240] OpenCL: kernel build errors written to x264_kernel_build_log.txt
[libx264 @ 00000000024d7240] profile High, level 3.1
[libx264 @ 00000000024d7240] 264 - core 135 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=2 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
....
But it creates x264_kernel_build_log.txt with:

Code: Select all

(0) Error: unsupported operation
And I do not see any differences in encoding fps with opencl and without.
Looks like something wrong with my video card, maybe it's too old.

nille02
Posts: 24
Joined: Tue Aug 14, 2012 3:47 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by nille02 » Fri Jul 12, 2013 6:02 am

Try to make an 2 Pass encoding (Only the first pass is important) with a high lookahead value.

Ajaja
Posts: 69
Joined: Fri Mar 08, 2013 2:00 pm

Re: Since FFMPEG 2 is there OpenCL Support

Post by Ajaja » Fri Jul 12, 2013 4:55 pm

nille02
GPU load = 0% with -rc_lookahead 25. My GeForce GTS 250 has OpenCl v1.0 native support only, and v1.1 with latest Nvidia drivers. x264 seems to need v1.2.

Post Reply
'