It is better to concentrate on using different ffmpeg options that will achieve the same result in a way that uses less resources. That said, there are ways to use less resources if you really need to accomplish a specific thing with ffmpeg and it is using too many resources.
You can decrease the priority of
ffmpeg's CPU process:
- Terminal method: Use the
nice command to change the process's priority:
nice -n 8 ffmpeg -y -r 15 -g 600 -s 1280x1024x24 -f x11grab -i :100 -vcodec libx264 /tmp/video.mov. In Linux, the priority number (the
nice command format is
nice -n <priority> <command>) ranges from -20 to 20. The greater the integer, the lower the priority is; neutral is 0. If you use the command I gave you and set it to 8, the CPU will give the process less time, which seems like less "power". If this number is too high or two low, of course, you can change it.
- GUI method: This isn't recommended because it gives you less control over the exact number and it doesn't take effect as soon as the process begins. However, it is more comprehensible. With
ffmpeg running, open the System Monitor. Scroll down to the process named
ffmpeg, left click it to select, right click it, and set the priority to "Low" or "Very Low".
If you're worried about memory usage, too, know that it is not possible to tell a process to only take so much memory and still run. The kernel automatically controls memory allocation for processes. There is a way to cage processes, with the
timeout script, so that when a process and any child processes take up too much memory (a limit set by you) they are terminated safely and a notification is displayed. However, if a process is only given so much memory (say by the kernel) and it requests more memory that it cannot have, it will crash.
Some helpful things to know about:
Using knowledge of Cgroups, you can do lots of fun things like controlling the swappiness of a process.