wulkano / Aperture

Record the screen on macOS
MIT License
1.23k stars 111 forks source link

ran some ffmpeg tests #30

Closed hanayik closed 7 years ago

hanayik commented 7 years ago

Hi aperture team, I know you've put in a lot of work on the swift screen capture code. Neat stuff btw. I only found the project because I was googling around to see if anyone else had made an electron app for camera and screen recording. I'm currently working on my own version.

I wanted to share my ffmpeg tests with you guys. I've been working on simultaneous webcam and screen recording and haven't encountered any CPU hogging like you guys report in the main readme file for aperture. I started investigating to see what our differences were.

It looks like the main difference is with the preset used for encoding. By default ffmpeg will use a value of -preset medium

However, I have been using a value of -preset ultrafast

This gives larger files, but worth it if you're concerned about CPU usage. The presets control the encoding speed-to-compression ratio. So the medium preset is compressing more, and using more of your cpu.

Here are some ffmpeg commands I used for testing:

ScreenTest1.mp4 (preset ultrafast: cpu% = 80ish)

ffmpeg -y -thread_queue_size 50 -f avfoundation -framerate 30 -i 1:0 -c:v libx264 -preset ultrafast -r 30 ./ScreenTest1.mp4

ScreenTest2.mp4 (preset medium (default): cpu% 300ish)

ffmpeg -y -thread_queue_size 50 -f avfoundation -framerate 30 -i 1:0 -c:v libx264 -preset medium -r 30 ./ScreenTest2.mp4

ScreenTests.zip

Again, just wanted to share these tests in the hopes that I can help in some small way. It would be nice to use ONLY ffmpeg because then you'd have more cross platform opportunities.

Let me know if I can help with anything

sindresorhus commented 7 years ago

Thanks for sharing your findings. This will be very useful for when we add Linux and Windows support using ffmpeg. We still want to use our own binary on macOS though. It's fairly mature now and it gives us more flexibility for future features. It also consumes only 10% CPU on average compared to 90% with ffmpeg.

hanayik commented 7 years ago

Awesome. 10% is quite impressive! I look forward to seeing how Kap develops. I'll send you guys a link to "Duo" when I finish it. My aim is to use ffmpeg to do simultaneous camera and screen recording using a picture-in-picture effect. I'm going to package it all up as a menu bar app. If you or anyone else related to aperture or kap want to contribute in the future I'd welcome PR's or at least help testing/debugging in the distant future.

Cheers! 🍺