Why is OBS so much more performant than ffmpeg?

herpaderppp

New Member
Hey everyone, I started messing around with ffmpeg recently and was wondering if anyone could help me out with a conceptual question.

My use case is simply recording a desktop screen (on Windows). Apart from basic quality baselines (30 fps, relatively good resolution, etc), I'm willing to sacrifice anything to minimize CPU usage as much as possible.

I would have expected OBS and ffmpeg to be relatively comparable (with OBS of course being more optimized) since both are native solutions. However, after trying a ton of configurations/codecs on ffmpeg, it seems I'm misunderstanding a piece of this problem conceptually. On my PC, OBS runs at 2-3% CPU with high quality and fps. Ffmpeg, on the other hand, averages around 20% and even with hardware acceleration, only reaches 11%.

Am I missing something here that accounts for the large difference?

For reference, I'm running commands along the lines of ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv.

Intuitively, an idea that crossed my mind is that in the limit, you can get minimal CPU if you just save the recording in a raw video format and do all the encoding afterward. However, that's not feasible since even though I don't care too much about memory, the memory consumption of using, say, a .yuv file is ridiculous. Maybe there's a middle ground?
 

zbang

New Member
Not a solid answer, but there are about 1800 ways to screen-scrape in windoze, all with different methods/paradigms/speeds/etc. With ffmpeg there doesn't seem to be much call windows screen grabbing and it doesn't appear that there's been much work on gdigrab.c in a while (I'm not going to look at all the diffs at the moment).

BTW, ffmpeg does support directshow grabbing, might be faster for you.

z!
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
OBS is specifically built and optimized around capturing and live encoding. FFmpeg not so much. Plus GDI (the capture method you're using with FFmpeg) has awful performance for capturing monitors.
 

EmErAJID

New Member
Well, I was fighting against ffmpeg for quite a while and here's what I've got. Using ffmpeg to record video will bring you less file size compared with OBS, plus usage of GPU is somewhat better, but usage of CPU is just awful. I think that it's because ffmpeg hasn't got any good screen capturers. Dshow is good enough, but it has not filters that could capture 1920x1080 and that's ridiculous, because all new monitors have this resolution. So the best that you can do is just let transcoder be transcoder. Ffmpeg says that it's good for video recording, well, maybe on Linux it's good, I've heard ffmpeg was put-up for Linux, but I never tried it on Linux, can't say anything, though what I can say definitely is that ffmpeg isn't any good for video recording on Windows.
 
Top