mhsabbagh / green-recorder

A simple screen recorder for Linux desktop. Supports Wayland & Xorg
GNU General Public License v3.0
616 stars 118 forks source link

Cache resources exhausted when recording animated gif #48

Closed yuvilio closed 6 years ago

yuvilio commented 6 years ago

When recording a gif that's, say, more than 4 seconds, the resulting gif file never completes. This is what the command shows:

frame=  344 fps= 30 q=-0.0 size=  872175kB time=00:00:11.46 bitrate=623098.3kbitframe=  349 fps= 30 q=-0.0 Lsize=  884852kB time=00:00:11.63 bitrate=623098.3kbits/s speed=1.01x    
video:884852kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Exiting normally, received signal 15.
convert-im6.q16: DistributedPixelCache '127.0.0.1' @ error/distribute-cache.c/ConnectPixelCacheServer/244.
convert-im6.q16: cache resources exhausted `/home/yuvilio/Videos/2017-08-06 22:06:41.711477.gif.tmp' @ error/cache.c/OpenPixelCache/3945.
convert-im6.q16: no images defined `/home/yuvilio/Videos/2017-08-06 22:06:41.711477.gif' @ error/convert.c/ConvertImageCommand/3258.

Running green-recorder package (3.0.2) on an Ubuntu 17.04 gnome (Xwayland) on a decent laptop.

For comparison i tried peek as well and was able to record a gif with it.

This only happens for me with recording gifs. The other video formats record great.

Feel free to close this issue if this sounds too environment specific

mhsabbagh commented 6 years ago

May I ask how much free space do you have in your PC? And whether you were trying to record the whole screen or just an area?

mhsabbagh commented 6 years ago

And hold on for a second, did you say you are running on Xwayland? GIF image (and all the other formats) and not supported on Wayland session. You should be using the Wayland backend, which enables you only to record in WebM format.

When you run "green-recorder" from the terminal, what does it tell you when it begins? And what's the output of ps -cat?

yuvilio commented 6 years ago

Free space should be fine. I have a150+GB free.

Yep, running Xwayland.

$ ps -cat 
  PID TTY      STAT   TIME COMMAND
 1212 tty1     Ssl+   0:00 gdm-wayland-ses
 1216 tty1     Sl+    0:00 gnome-session-b
 1224 tty1     Sl+    0:04 gnome-shell
 1296 tty1     Sl+    0:00 Xwayland
 1353 tty1     Sl     0:00 ibus-daemon
...

Other formats i tried (mkv, mp4) saved just fine on this green-recorder version.

So is is the issue possibly that Xwayland gif export might not be supported? (i might have misunderstood you).

mhsabbagh commented 6 years ago

Weird. Recording video with ffmpeg doesn't work at all (or shouldn't work) under GNOME Wayland. It gives you a black screen due to Wayland API (which doesn't allow any application to see other applications or capture their image). Green Recorder should never allow you to record any format other than WebM on GNOME Wayland.

Even though those processes may be running in the background, it doesn't necessarily mean that you are using Wayland. What's the output of the following command?

echo $XDG_SESSION_TYPE

?

yuvilio commented 6 years ago
$ echo $XDG_SESSION_TYPE 
x11
$ gnome-shell --version
GNOME Shell 3.24.2
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=17.04
DISTRIB_CODENAME=zesty
DISTRIB_DESCRIPTION="Ubuntu 17.04"
$ uname -a
Linux totobooks 4.10.0-30-generic #34-Ubuntu SMP Mon Jul 31 19:38:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ 
mhsabbagh commented 6 years ago

It means you are running on Xorg. Not Wayland.

However, as for GIF, the method used in Green Recorder is to record a raw video for the selected area first, and then create a GIF image from the raw video. In this, the GIF size would be optimized, unlike when we just record it diretly with ffmpeg.

This requires creating a temporary raw video file which its size may reach hundreds of megabytes or even gigabytes. In your case, after it reached 872175kB (around 870MB), it told that there is no further cache to use. It means it couldn't find extra space to use for the raw file or there's another issue related to that on your system.

Here with me on Ubuntu 17.04 GNOME as well, it works just fine.

Please, try to use a smaller area and see if it works.

yuvilio commented 6 years ago

That makes sense. Restricting the size definitely seems to help in the export finishing.

Thanks for the explanations!

phw commented 6 years ago

Peek developer here. Since you mentioned peek, please note that Peek is plagued by the same resource limit issues. See https://github.com/phw/peek/issues/112 for details and information on how to configure ImageMagick to increase its resource limits.

mhsabbagh commented 6 years ago

@phw But this should be done from the user's side. Since it requires root. Isn't there a workaround to tell imagemagick to give more memory/space for the process? I haven't looked into it yet.

phw commented 6 years ago

@mhsabbagh: You can pass the resource limits via command line parameters. The problem is you will have both problems with ImageMagick: If the limits are too low it will fail like described, if they are too high it quickly eats up all resources (it can easily use multiple gigabyte of RAM if you let it, have seen it consume > 9GB for GIF optimization). I want to look into this in more detail as soon as I have more time again.

yuvilio commented 6 years ago

Confirmed, @phw . Bumping the "disk" and "memory" configurations in the ImageMagick policy.xml file allowed me to record longer gifs without the behind the screnes convert process crashing. It does indeed consume resources i give to it to the full and still takes a few to complete. But eventually that temp file of hundreds of megs disappears and instead, a gif file the size of a few 100kb appears instead. Good to see I can control it on my end for now and have two gif screen recorders at my beckoning. Thanks!