4

I am using FFMpeg for screen capturing. I am looking for a screen capturing tool that will run on 1000 of VMs (windows and mac).The VMs have limited CPU (1 core) and 2GB ram and No GPU.

Currently I invoke ffmpeg with

ffmpeg  -y -framerate 8 -f dshow -f gdigrab -i "desktop"  -c:v libx264  -crf 0 -preset ultrafast -threads 0 temp.mkv

I am using gdigrab to capture screen? Is there any better options that might reduce cpu usage? or changing the encoder or format?

I am aiming for 4-5% reduction in CPU usage.

Thanks in advance

wetjosh
  • 6,288
  • 4
  • 23
  • 32
Hardik Juneja
  • 377
  • 1
  • 2
  • 12

2 Answers2

4

Using -profile baseline and enabling -tune zerolatency to turn of some extra features should help a bit. Otherwise, you will need to use a different codec than h.264.

szatmary
  • 29,969
  • 8
  • 44
  • 57
  • I tried -profile baseline and -tune zerolatency but that didn't helped me much. what other codec do you suggest for low CPU? – Hardik Juneja Jun 17 '15 at 19:57
  • totally depends on your goals. YUV will take 0% CPU but the file will be huge. – szatmary Jun 17 '15 at 20:00
  • I am aiming for medium size, low quality, low cpu solution to record desktop. This tool needs to run on 1000's of windows machine and will record selenium tests for me which alone take 80% of cpu. I am happy to try other native tools instead of ffmpeg but I cant find any. – Hardik Juneja Jun 17 '15 at 20:09
  • 1
    MPEG2 will probably be a good candidate. I think you may need to experiment a little, Maybe Theora, xvid or mpeg4 part 2. Or maybe even mjpeg if the resulting file size works for you. You can run `ffmpeg -codec` to see what it supports. But I would stick to the ones I listed for compatibility. – szatmary Jun 17 '15 at 20:17
1

What is your source's resolution ? If it's big (like 1080p or 720p), have you considered downscaling first to 480p / 404p ?

Otherwise, it's better to just change the codec. I'd suggest you first try "-c:v mpeg4". If it is still too slow, go for "-c:v mpeg2video".

Ely
  • 1,189
  • 9
  • 12
  • Ely, I tried both of them, 'mpeg2video' seems to be using less cpu, but I am still looking for a better solution. Thanks for your answer. Reg. size I need different sizes, so small size is not an option. – Hardik Juneja Jun 20 '15 at 14:06
  • Your last solution is then to limit the framerate at which you record. I don't know what is your current fps, but if it's 30, try decreasing to 25 / 20 / 15 / 10 with the -framerate switch EDIT : nvm, I just saw -framerate 8 in your original comment. My bad. – Ely Jun 20 '15 at 14:13
  • Last idea, I saw that you're trying to encode a lossless stream with crf=0. You'll get a much better speed if you encode with something like crf=18 and still get a "visually lossless" quality. – Ely Jun 25 '15 at 12:41
  • I ended up selecting mpeg2 video, but it seems like there's no way to play it on web? any idea? @szatmary? – Hardik Juneja Jun 25 '15 at 16:27