[FFmpeg-user] Reducing CPU usage

Dan Mahoney dan at streemit.net
Wed May 7 20:20:14 CEST 2014

I'm running ffmpeg version N-62446-g9468e9e on a Centos box with an AMD 
Athlon 64 X2 dual core 4400+ chip. The machine has 1 GB of RAM. I've got 
a pair of video input cards (lspci says "Multimedia video controller: 
Internext Compression Inc iTVC16 (CX23416) Video Decoder (rev 01)"). The 
video stream is being read in by ffmpeg, reformatted, and sent out to a 
Wowza server in the same subnet.

The command I'm using is:

/usr/local/bin/ffmpeg -loglevel error -threads 1 -i /dev/video0 -f flv 
-vcodec h264 -acodec libfaac -b:a 64k -b:v 400k -ac 2 -ar 44100 -r 25 -g 
90 rtmp://wowza/live/channel1 2> /dev/null > /dev/null

and it's working quite nicely - I can watch the stream from the Wowza 
server and it plays with no skips, etc. But as soon as I launch a second 
instance of ffmpeg (with /usr/local/bin/ffmpeg -loglevel error -threads 
1 -i /dev/video1 -f flv -vcodec h264 -acodec libfaac -b:a 64k -b:v 400k 
-ac 2 -ar 44100 -r 25 -g 90 rtmp://wowza/live/channel2 2> /dev/null > 
/dev/null) the streams as played from Wowza start looking really bad - 
pixelation, pauses in audio stream, occasional buffering, etc.

"top" shows each instance of ffmpeg using about 100% of a CPU (95-99%), 
load average is sitting at about 4, around 12 MB of RAM free.

Any suggestions on how I can reduce the system load to allow this 
machine to handle these two streams? I'd rather not have to double the 
number of ffmpeg machines I'm going to have to use.

I had been using an older version (1.1.5) with "-preset ultrafast", but 
performance with that version and set of arguments didn't make a 
significant difference. I've checked the mailing list archives and 
looked for ideas to try, but some of what I've found (like the ultrafast 
preset) appear to not work with the latest version of ffmpeg.

More information about the ffmpeg-user mailing list