PDA

View Full Version : How to install X264 with pthreads support?


Redhat_doom
22nd January 2009, 02:30
Hi,
I want to use threads in the last version of x.264. It seems that I shoud install x264 with pthreads support. I downloaded pthreads for win32 but I don't know how to link (use) it with x.264. By default, x.264 uses only one single thread and it doesn't support multiple threads. But could please tell me how to do so? Thanks.

LoRd_MuldeR
22nd January 2009, 02:33
Do you want to compiler x264 (no dot in the name) yourself or do just want to use it?

In the latter case download the pre-compiled x264.exe here and you are done:
http://x264.nl/

No need to install pthreads separately. The x264 binary either was build with pthreads or not - most binaries you find on the net are :)

To enable multi-threading you simply need to pass the "--threads auto" switch to x264 ;)

Redhat_doom
22nd January 2009, 02:46
Do you want to compiler x264 (no dot in the name) yourself or do just want to use it?

In the latter case download the pre-compiled x264.exe here and you are done:
http://x264.nl/

No need to install pthreads separately. The x264 binary either was build with pthreads or not - most binaries you find on the net are :)

To enable multi-threading you simply need to set the "--threads auto" switch ;)

Thanks! Actually, I need to modify the source code as well. I tried the following instruction:

x264 --bitrate 700000 -v --threads auto output.264 input.yuv 352x288

but I got the following error: No output file!

Please note that I just compiled the source code of the latest version of x.264 and so I didn't use the pre-compiled version. I think, my current version doesn't support --threads auto. In other words, it cannot recognize "auto". Isn't it? If so, what is the wrong? Thanks

LoRd_MuldeR
22nd January 2009, 02:50
x264 --bitrate 700000 -v --threads auto output.264 input.yuv 352x288

but I got the following error: No output file!

Because output is missing indeed! You need to call it like this:
x264.exe --bitrate 700000 -v --threads auto --output output.264 input.yuv 352x288

Please note that I just compiled the source code of the latest version of x.264 and so I didn't use the pre-compiled version. I think, my current version doesn't support --threads auto. In other words, it cannot recognize "auto". Isn't it? If so, what is the wrong? Thanks

If you really build x264 (still no dot in the name) yourself, you'll need to have the pthread libs installed indeed. Then x264's configure script will find and include them automatically!

I personally use TDM's MinGW/GCC installer, which already includes the required pthreads libs:
http://downloads.sourceforge.net/tdm-gcc/tdm-mingw-1.812.0-f1.exe

Otherwise you can grab the pthreads sources and then simply build the binaries yourself:
ftp://sourceware.org/pub/pthreads-win32/sources/pthreads-w32-2-8-0-release/

Sharktooth
22nd January 2009, 02:58
--bitrate 700000 ?

Esurnir
22nd January 2009, 03:09
Thanks! Actually, I need to modify the source code as well. I tried the following instruction:

x264 --bitrate 700000 -v --threads auto output.264 input.yuv 352x288

try --crf 18 instead...

oh and I "think" that you need a --fps for yuv inputs too (else it doesn't know how many frame is a second)

kemuri-_9
22nd January 2009, 04:06
oh and I "think" that you need a --fps for yuv inputs too (else it doesn't know how many frame is a second)

when the fps rate is not determinable from the source and it is not provided by the --fps option, 25fps is used.

Redhat_doom
22nd January 2009, 04:32
Because output is missing indeed! You need to call it like this:
x264.exe --bitrate 700000 -v --threads auto --output output.264 input.yuv 352x288


Thanks, but how to choose the number of the threads now?

LoRd_MuldeR
22nd January 2009, 04:36
Thanks, but how to choose the number of the threads now?

The optimal number of threads (detected empirical) for x264 is "3/2 * number of cores" or simply the result of "--threads auto" :)

(of course the "--threads x" switch only works when your x264 binary was compiled with pthreads enabled)

Redhat_doom
22nd January 2009, 04:45
The optimal number of threads (detected empirical) for x264 is "3/2 * number of cores" or simply the result of "--threads auto" :)

(of course the "--threads x" switch only works when your x264 binary was compiled with pthreads enabled)

Ok, thanks :) Actually, I want to split the output bitstream of the encoder into multiple NAL units (just similar to Multislicing). Since x264 doesn't support multislicing anymore, so I think by using threads, we can simulate multislicing. But what is your opinion? As far as I know, each thread selects a portion of a frame for working with it and as the threads are processed in parallel, so I think their outputs are written into different NAL units. Isn't it? If so, if we could able to set the number of the threads, then we can control the number of the output NAL units. But what do you think? Thanks.

Dark Shikari
22nd January 2009, 04:46
Ok, thanks :) Actually, I want to split the output bitstream of the encoder into multiple NAL units (just similar to Multislicing). Since x264 doesn't support multislicing anymore, so I think by using threads, we can simulate multislicing. But what is your opinion? As far as I know, each thread selects a portion of a frame for working with it and as the threads are processed in parallel, so I think their outputs are written into different NAL units. Isn't it? If so, if we could able to set the number of the threads, then we can control the number of the output NAL units. But what do you think? Thanks.That isn't how multithreading works... at all. (http://akuvian.org/src/x264/sliceless_threads.txt) Each frame is encoded with only one thread.