[FFmpeg-user] maximum CPU utilization with ffmpeg and libx264

George D Pylant III objectivecgdp at gmail.com
Tue Mar 22 02:41:03 CET 2011


Background:

Regarding the current Mac Pro Dual Dual Quad Core (2.4 ghz) Westmere Xeon:  My understanding is that these cores support hyperthreading allowing two threads to run simultaneously on each core. So OSX "sees" 16 cores when there are actually only eight physical cores.  iStat Menus or Activity Monitor shows sixteen cores. 

For encoding I use the following command:

ffmpeg -y -i video.m2ts -threads 0 -acodec ac3 -ab 448k -ar 48000 -vcodec libx264 -coder ac -level 41 -b 5000k -refs 2 -flags +loop -flags2 +mixed_refs+dct8x8-fastpskip -me_method umh -subq 9 -me_range 16 -qmin 10 -qmax 50 -g 24 -keyint_min 2 -copyts video.mp4"

I notice via iStat Menus or Activity Monitor that only eight cores are being used with threads 0 or threads 24.  The other eight "virtual" cores show very little activity.  With an analogous command using handbrakecli (x86_64) iStat Menus or Activity Monitor shows all sixteen cores being used almost 100% each.

My x264 configure line:  ./configure --prefix=${TARGET}

My ffmpeg configure line:  ./configure --prefix=${TARGET} --enable-nonfree --enable-gpl --enable-version3 --enable-libx264 --enable-pthreads --enable-libfaac --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-libgsm --enable-libopenjpeg --enable-libxvid --enable-libschroedinger --enable-libdirac --enable-libxavs --enable-librtmp --enable-avfilter --enable-filters --enable-postproc --target-os=darwin --arch=x86_64 --enable-runtime-cpudetect

My question(s):

I am trying to get the fastest ffmpeg encodes possible on my Mac Pro.  So why doesn't ffmpeg/libx264 use all "sixteen" cores, i.e. two threads per core like handbrakecli does?  I can use the same ffmpeg command line above on a PC that I have (corei7 quad 2.8 ghz hyperthreading capable) that shows all eight (i.e. two threads per core) being used almost 100% each.  So I know ffmpeg uses two threads per core on my PC but seems to only use one thread per core on my Mac Pro.  Is there a flag or flags I should be using when compiling x264 and/or ffmpeg that would allow maximum CPU usage on the mid 2010 Mac Pro, i.e. use all "sixteen" cores instead of just eight like HandbrakeCLI does?  Or is this a current limitation of ffmpeg/libx264 on the dual quad Westmere Xeon CPU's on a Mac Pro?

Thanks for any input.

George


More information about the ffmpeg-user mailing list