x264 Lookahead with OpenCL and Mediacoder

Discussing about advanced video encoding techniques including GPU encoding, distributive encoding and segmental encoding. Topics are not limited to MediaCoder.
2121
Amateur
Amateur
Posts: 36
Joined: Mon May 19, 2008 10:11 am

x264 Lookahead with OpenCL and Mediacoder

Post by 2121 » Thu Sep 20, 2012 10:04 am

Encoder x264 Lookahead with patch for soport OpenCL:
What happened to those OpenCL-accelerated video encoders we were all daydreaming about? Well, they're still in the works, believe it or not. The folks behind the popular x264 software encoder have been quietly plugging away at an OpenCL-accelerated version of their lookahead pipeline. Lookahead only accounts for 10-25% of the total encoding time, according to x264 lead developer Jason Garrett-Glaser, but the process allows for nearly unlimited parallelism and is relatively easy to implement in OpenCL. Re-writing all of the x264 encoder in OpenCL, by contrast, would be "very hard." Garrett-Glaser says the accelerated lookahead can increase performance by up to 40% on AMD's new Trinity APUs and by a factor of two on the latest Radeon graphics cards.
The x264 opencl lookahead patch has been tested for months on x264dev’s IRC, but it lacked too many features compared to currect x264, e.g., the weightp was still not supported at the beginning of May. However, it is glad to see the latest patch was released on doom10 yesterday, in which most features has been implemented (but only 8-bit, high bit-depth has not been supported). So a test build should be available here.

Based on tMod+MixAQ branch (rev2197+666+30). Compiled with fprofile and win32thread, and AMD APP v2.6, which may require OpenCL v1.1 runtime to enable opencl lookahead. Lavf/ffms/swscale/interlaced was disabled, and chroma format was set to 4:2:0. Tested on AMD HD6770M and NVidia GTX460, not sure if it can run on Ivy Bridge or not.
Download: http://astrataro.wordpress.com/2012/09/ ... 6688-tmod/
tMod/tMod-10bit/tMod+MixAQ/tMod+OreAQ:
Download:
x264_rev2216+688_tMod.7z : NMM、MediaFire
x264_rev2216+688_tMod-opencl.7z (test only) : NMM、MediaFire

By default uses old style progress indicator, and won’t break GUI’s progress parser. If you like r2204 style progress indicator, try --stylish, but keep careful if you are using GUIs. The difference between r2204 and this --stylish is that console title always uses old style indicator, so you won’t get meaningless raw numbers without labels on console title.

OpenCL version need --opencl to enable use of opencl lookahead. I did not test it, as it seems broken on my CCC 12.8. The last driver I successfully run it was CCC 12.3 ( or NVidia cards ), compiled with APP v2.6, but this version is compiled with APP v2.7.
http://forum.doom9.org/showthread.php?t=164960&page=5
http://doom10.org/index.php?topic=2247.0



Use Mediacoder with x264 Lookahead patch OpenCL

**
if mediacoder 32bit: rename file "x264_32_tMod+MixAQ-8bit-420-opencl.exe" to "x264.exe"
if mediacoder x64: rename "x264_64_tMod+MixAQ-8bit-420-opencl.exe" to "x264.exe"

** move file x264.exe to folder
mediacoder>codecs [mediacoder 32bit]
mediacoder>codecs64 [mediacoder 64bit]

** Open mediacoder, to TAB x264, boton ADVANCED-->MORE PARAMETERS, en EXTRA OPTIONS ADD comand --opencl

Image

** Config mediacoder to encode to h264 normality

example

<< encode video 1080p 1min to h264 with encoder x264 without comand --opencl [only CPU]

Image

time: 27 seg
fps: 122 average
CPU frecuency: 3500MHz [coretemp]
GPU frecuency: 100MHz [gpu-z]

<< encode video 1080p 1min to h264 with encoder x264 with comand --opencl [CPU+GPU]

Image

Time: 15seg
FPS: 131 average
CPU frecuency: 3500MHz [coretemp]
GPU frecuency: 900MHz [gpu-z]

n9ntje
Beginner
Beginner
Posts: 1
Joined: Thu Sep 27, 2012 8:32 pm

Re: x264 Lookahead with OpenCL and Mediacoder

Post by n9ntje » Thu Sep 27, 2012 8:41 pm

Seems I got it working, but there is no benefit :?:

Converted 1276x716 MP4 video to 854x480 x264; length ca 42 min

CPU: 862 sec

GPU: 880 sec
checked GPU-Z: load ~1% but freq from 157 Mhz -700 Mhz

System
AMD X2 550 unlocked to X4 @ 3,5Ghz
AMD HD5750 video card
4GB Ram

Oh btw, I reverted to Catalyst 12.3 drivers. You need opencl 1.1 driver, current AMD drivers has opencl 1.2 driver

dmitryrachkov1
Beginner
Beginner
Posts: 1
Joined: Sat Jan 26, 2013 8:15 pm

Re: x264 Lookahead with OpenCL and Mediacoder

Post by dmitryrachkov1 » Sat Jan 26, 2013 8:20 pm

Hi!

On the page http://astrataro.wordpress.com/2012/09/ ... 6688-tmod/ I can't download the files:
x264_rev2216+688_tMod.7z
x264_rev2216+688_tMod-opencl.7z (test only)

Error: 404 Not Found

Please, where I could still download them???

stanley
Site Admin
Site Admin
Posts: 4135
Joined: Mon May 15, 2006 7:43 pm
Location: Sydney

Re: x264 Lookahead with OpenCL and Mediacoder

Post by stanley » Mon May 06, 2013 3:05 am

The OpenCL option for x264 has been added in 0.8.21.5392. Two versions of x264 (one is built with OpenCL) are included in the distribution.
When things work together, things work.

flagpole
Modest
Modest
Posts: 259
Joined: Tue Jan 26, 2010 10:12 pm
Contact:

Re: x264 Lookahead with OpenCL and Mediacoder

Post by flagpole » Tue May 07, 2013 11:43 pm

do we know what the lookahead module actually does?

I'm getting mixed results. i'm wondering if there are some circumstances where using opencl has more or less banefit than others?
my quant puzzles http://puzzles.nigelcoldwell.co.uk go look :)

stanley
Site Admin
Site Admin
Posts: 4135
Joined: Mon May 15, 2006 7:43 pm
Location: Sydney

Re: x264 Lookahead with OpenCL and Mediacoder

Post by stanley » Thu May 09, 2013 1:14 am

I used x264 build from http://www.x264.nl/.
When things work together, things work.

flagpole
Modest
Modest
Posts: 259
Joined: Tue Jan 26, 2010 10:12 pm
Contact:

Re: x264 Lookahead with OpenCL and Mediacoder

Post by flagpole » Fri May 10, 2013 8:33 pm

yeah.

On some encodes it's maybe 10-20% faster. my feeling is that it's more about offloading from the cpu and freeing it up than the speed of GPU based encoding.

but sometimes it's been a bit slower. maybe 10%. I'm trying to workout under what parameters that is. it may well not be to do with x264 at all but rather what else is going on.
my quant puzzles http://puzzles.nigelcoldwell.co.uk go look :)

fredbe9300
Amateur
Amateur
Posts: 68
Joined: Fri Dec 21, 2012 6:56 am

Re: x264 Lookahead with OpenCL and Mediacoder -bug?

Post by fredbe9300 » Sun May 12, 2013 4:00 am

stanley wrote:The OpenCL option for x264 has been added in 0.8.21.5392. Two versions of x264 (one is built with OpenCL) are included in the distribution.
hi
I got a question about this :)

my system: Core2 Duo T9300 / Quadro FX 360M laptop (Vista 32bit + 32-bit mediacoder 5392).
I see "OpenCL" in the statusbar (which, per the blog article should mean my System is OpenCL capable). I did NOT enable "OpenCL" in the x264 advanced options (encoder: Auto, format: H.264)

Yet, I see my encode using the x264_opencl.exe codec.

Code: Select all

x264_opencl --no-progress --preset slower --weightp 2 --b-pyramid strict --keyint 250 --min-keyint 25 
--non-deterministic --bframes 3 --ref 5 --psy-rd 1:0 --crf 22 --sar 119:120 --threads 3 --demuxer raw 
--input-res 1280x714 --fps 2997/125 --input-csp i420 -o "C:\Users\admin\AppData\Local\Temp\mctemp15404ef3ffb730751.264" -


I read about some "--opencl" option, but I'm not sure if that relevant for the current versions (it's missing in the command - but perhaps the use of x264_opencl.exe means the option is irrelevant)

Question:
1) is it correct for mediacoder to use x264_opencl when "enable OpenCL ..." is not selected?
2) I notice the x264.exe is "x264 core:130 r2273 b3065e6" whereas x264_opencl.exe is "x264 core:132 r2309 3b1f1f7"

PS:
I did an uninstall (5360) + install (5392). 32-bit version

./codecs folder has
03/09/2013 06:08 AM 10,252,288 x264.exe
05/03/2013 11:00 AM 12,034,560 x264_10bpp.exe
05/03/2013 10:59 AM 12,179,456 x264_opencl.exe

x264.exe is "x264 core:130 r2273 b3065e6"
x264_opencl.exe is "x264 core:132 r2309 3b1f1f7"

kindly, fred


EDIT: I read this in the x264 changelog - and it made me wary of using openCL for now:

Because of data dependencies, the GPU must use an iterative motion search which
performs more total work than the CPU would do, so this is not work efficient
or power efficient. But if there are spare GPU cycles to spare, it can often
speed up the encode. Output quality when OpenCL lookahead is enabled is often
very slightly worse in quality than the CPU quality (because of the same data
dependencies).
http://mirror01.x264.nl/x264/changelog.txt (comment from Feb 2013)

stanley
Site Admin
Site Admin
Posts: 4135
Joined: Mon May 15, 2006 7:43 pm
Location: Sydney

Re: x264 Lookahead with OpenCL and Mediacoder

Post by stanley » Sun May 12, 2013 3:53 pm

To enable "--opencl", click "Advanced" button on x264 tab and tick "Enable OpenCL if possible".
There is a screenshot in the release note about this option.
When things work together, things work.

fredbe9300
Amateur
Amateur
Posts: 68
Joined: Fri Dec 21, 2012 6:56 am

Re: x264 Lookahead with OpenCL and Mediacoder

Post by fredbe9300 » Sun May 12, 2013 5:06 pm

thx
yeah, when I posted before, I had a long running 720p recode going on.

I've now also tested with "OpenCL enabled" and the x264 subprocess then has the extra --opencl. So the setting behaves correctly

Code: Select all

x264_opencl --no-progress --preset slower --weightp 2 --b-pyramid strict --opencl --keyint 250 --min-keyint 25 -
-non-deterministic --bframes 3 --ref 5 --psy-rd 1:0 --crf 22 --sar 119:120 --threads 3 --demuxer raw --input-res 1280x714 
--fps 2997/125 --input-csp i420 -o "C:\Users\admin\AppData\Local\Temp\mctemp1540405e139aebb8b.264" -
I guess I was just confused by the fact that there's x264.exe (dated March) and x264_opencl.exe (dated May) in the ./codecs folder.

Question
The Mediacoder console shows this - but I can't find the kernel build log file anywhere. Where could it be?

Code: Select all

x264 [info]: OpenCL acceleration enabled with NVIDIA Corporation Quadro FX 360M
x264 [info]: Compiling OpenCL kernels...
x264 [warning]: OpenCL: kernel build errors written to x264_kernel_build_log.txt

FYI / FWIW
For that 720p encode, the non-opencl recode had relative speed .18x ; with opencl it was .22x. Resulting file size was less than 1MB different (on 750MB). I still have to do a visual compare.

Post Reply