Kap icon indicating copy to clipboard operation
Kap copied to clipboard

Significant slowdown, exporting to disk

Open davewhitley opened this issue 3 years ago • 18 comments

macOS version: Catalina (10.15) Kap version: 3.3.2

Steps to reproduce

No plugins installed

  • capture a short video
  • make sure "export to disk" is selected
  • click export
  • notice nothing happens, spinning beach ball
  • export window remains empty

Current behavior

I can't seem to get the "export to disk" function to work, it just slows down and stalls.

Copy to clipboard is working, MP4 also doesn't work

Expected behavior

To export the gif and not stall.

davewhitley avatar Sep 29 '20 19:09 davewhitley

I confirm, the ffmpeg is running in background, but the export process takes much more time than previously. Video length of 30seconds was previously exported in few seconds, now it takes couple of minutes. This make KAP un-usable :-\
Version: Version 3.3.2 (3.3.2.1718)

marlukcz avatar Oct 02 '20 06:10 marlukcz

Just noticed that the slow export is to AV1. Just export to H264 and it will be as fast as it used to be. It seems to me that the AV1 export is not using the full CPU capabilities, but it somehow limits its resources. Probably the command used to call ffmpeg?

carlosbaraza avatar Oct 13 '20 21:10 carlosbaraza

Could it be related to Hyperkit I/O being slow?

carlosbaraza avatar Oct 13 '20 21:10 carlosbaraza

OK, when the export is running, there is this process:

/Applications/Kap.app/Contents/Resources/app.asar.unpacked/node_modules/@ffmpeg-installer/darwin-x64/ffmpeg -i /var/folders/_6/mrdyrwds5f58_gjmyj5q6_pn8tl1qv/T/tmp-3634-juBINphQB3aH-.mp4 -r 10 -s 1200x602 -ss 0 -to 39.166667 -c:v libaom-av1 -c:a libopus -crf 34 -b:v 0 -strict experimental -cpu-used 4 -row-mt 1 -tiles 2x2 /private/var/folders/_6/mrdyrwds5f58_gjmyj5q6_pn8tl1qv/T/739ba4bfa1bdac1e86455f6191323d09/Kapture 2020-10-27 at 17.57.46.mp4

This process runs for ~4minutes in this sample. image

I copied the raw mp4 file from /var folder to input.mp4 and tried to convert it using different parameters. Note that in samples bellow, the ffmpeg command is a link to /Applications/Kap.app/Contents/Resources/app.asar.unpacked/node_modules/@ffmpeg-installer/darwin-x64/ffmpeg

  1. removed all parameters which I don't understand time ffmpeg -i input.mp4 -r 10 -s 1200x602 -cpu-used 4 export.mp4 real 0m15.228s user 0m33.103s sys 0m0.636s

  2. used all specified parameters as KAP application is using: time ffmpeg -i input.mp4 -r 10 -s 1200x602 -ss 0 -to 39.166667 -c:v libaom-av1 -c:a libopus -crf 34 -b:v 0 -strict experimental -cpu-used 4 -row-mt 1 -tiles 2x2 -cpu-used 4 export.mp4 real 4m4.358s user 9m22.288s sys 0m9.574s

  3. removed parameter -c:v libaom-av1 time ffmpeg -i input.mp4 -r 10 -s 1200x602 -ss 0 -to 39.166667 -c:a libopus -crf 34 -b:v 0 -strict experimental -cpu-used 4 -row-mt 1 -tiles 2x2 -cpu-used 4 export.mp4 real 0m14.339s user 0m32.456s sys 0m0.577s

so the root cause of the problem is ffmpeg parameter "-c:v libaom-av1".

I would suggest you to remove it.

marlukcz avatar Oct 27 '20 17:10 marlukcz

Hey @marlukcz

What format did you have selected when you did the export? From the options you've provided it looks like you had AV1 selected, which is a newer format (the newest we support) and is known to have long conversion times. Removing the -c:v libaom-a1 would mean we were converting to h264 instead of av1, which would be much faster, but would defeat the purpose by not resulting in a AV1 file. If you just want a h264 mp4 file as the result, you can select that option in the editor dropdown, which will indeed run only with the options you mentioned in your first conversion and will be much much faster.

We try to use the best options for each format we support, but some are inherently slower than others but provide different benefits. For AV1 specifically, the main benefit is the following:

Besides being royalty-free and open-source friendly, AV1 needs to actually offer advantages over already established technologies. Aomedia (the guardians of AV1 codec) claim it offers 30% better compression than H.265. That means it uses less data while offering the same quality for 4K UHD video.

So you sacrifice the conversion speed up front, in order to produce a smaller size result if file size is super important to you.

karaggeorge avatar Oct 30 '20 17:10 karaggeorge

Maybe we can do something to note the differences between h264 and av1 for users that don't necessarily know the difference, since both result in a .mp4 file. Not sure a good way to do that in the editor.

cc @skllcrn @sindresorhus

karaggeorge avatar Oct 30 '20 17:10 karaggeorge

@karaggeorge true, I was converting to av1 ... I didn't notice it at first. I am not aware to change it ever ... but maybe I did. What is default ?

Maybe you should make the title "AV1 - better but slower compression"

Conversion to h264 is much much faster. Like 100 times faster :-D

marlukcz avatar Oct 30 '20 19:10 marlukcz

I think we should show a Dialog the first time the user chooses AV1 that warns them how much slower AV1 is to encode.

sindresorhus avatar Oct 31 '20 01:10 sindresorhus

@marlukcz I feel like if it's your first time exporting AV1 would be on top alphabetically, but in general we sort formats by last used.

karaggeorge avatar Oct 31 '20 14:10 karaggeorge

I just installed Kap and converting a 0:40 screen recording to MP4 (AV1 or H264) Takes more than 30 mins.

apkoponen avatar Nov 10 '20 08:11 apkoponen

confirming the av1 issue speed. h264 is fine.

this article seems to indicate you may be able to shave down that compression time by bumping up the # of CPUs used https://www.streamingmedia.com/Articles/ReadArticle.aspx?ArticleID=130284

weisjohn avatar Dec 14 '20 23:12 weisjohn

I also noticed the long export time, which led me to this thread. A little 'warning' in the app would have helped here, because the long export time made me assume that something was wrong. :)

It's also worth noting that when I cancelled the export and quit Kap, ffmpeg kept running at 100% cpu utilization until I forced quit the process manually. Still, great application all in all, thank you for providing this useful tool. 😊

yannxaver avatar Feb 22 '21 11:02 yannxaver

I would suggest not making AV1 the default.

I just experienced this on a fresh install, on an M1 Mac. Initially I thought it had crashed but then I noticed the progress indicator was actually advancing, albeit extremely slowly. After 10 minutes it had gone ~20% and was showing 26 minutes left!

Then I switched to h264 and it exported as quickly as I was used to.

breadthe avatar Mar 02 '21 01:03 breadthe

I think this issue is two-split, AV1 exports are slow due to lack of upstream optimization, and it should not be the default setting for new installs.

The issue that @davewhitley originally described seems to indicate that the export process never begins, and the app freezes. If anyone is still experiences that issue, please let us know.

skllcrn avatar Mar 31 '21 18:03 skllcrn

Just installed Kap for the first time, did a 5 second test recording and tried to save and ran into this exact issue.. switching to h264 solved it.. why is AV1 the default? This should be considered a bug at this point.. the default option literally makes it seem like exporting is broken

vesper8 avatar Apr 30 '21 20:04 vesper8

Will be fixed in our next release @vesper8!

skllcrn avatar May 01 '21 12:05 skllcrn

Experiencing the same issue on latest Version 3.3.2 (3.3.2.1718), CPU usage bumps to 500%. Exporting a 1 minute recording to MP4(AV1), the default format, takes more than 1 hour (had to quit in the middle cause fan is spinning like crazy and laptop heats up to 100 celsius from 45 celsius). This continues even after I cancelled the export, had to force quit the ffmpeg background process. Manually switched to MP4(H264) significantly reduces export time, makes it usable(finishes in 30sec for 30sec recording ), however, CPU usages is still very high 900% while ffmpeg is running in the background.

KevinSource0 avatar Jul 01 '21 02:07 KevinSource0

I had the exact same experience as @KevinSource0 I think MP4(H264) should be made the default on KAP.

I'm on M1 macOS Big Sur

mesqueeb avatar Aug 01 '21 04:08 mesqueeb