dr-Styki / ScreenRec

A simple screen recorder app designed for elementary OS.
GNU General Public License v3.0
35 stars 14 forks source link

Support saving to GIF format #15

Open NathanBnm opened 4 years ago

NathanBnm commented 4 years ago

I was using the original Screen Recorder app from Mohelm97 which is supporting saving recordings to the GIF format. This is a handy format when recording short demos in order to upload them directly on GitHub or in any messaging apps like Slack, Discord or even Facebook Messenger and it would be great if you could support it back.

dr-Styki commented 4 years ago

That's already on my to do list. I need to find a way to do that with Gstreamer.

onsah commented 4 years ago

I am also interested in this feature. So I did some research and found that there is no gif encoder in GStreamer. They seem to purposely disabling gif encoder in here: https://github.com/GStreamer/gst-libav/blob/e1928898c8d49fe287d73db21c4ba5bed41bcf8e/ext/libav/gstavvidenc.c#L966-L970 So I thought one solution may be using ffmeg to convert from another video format. It is not the best solution but I can't think of a better solution.

onsah commented 4 years ago

I have somewhat working solution with ffmpeg. To try it out you can checkout my fork (gif-output branch). But it outputs huge sizes (~25mb per seconds for 1920x1080 screen). Also convert speed is very slow. Any tips on which flags to use with ffmpeg would be welcomed. Because I don't have much knowledge about ffmpeg. In the meantime I will learn more about ffmpeg and find out some better output configuration for speed and file size.

dr-Styki commented 4 years ago

Hi, using ffmpeg could be a solution. But effectively the output file size is huge. O_O

Also, the video to GIF conversion is async and give no information to the user about the process. A progress window like the one of the switchboard-plug-locale would be great for that.

onsah commented 4 years ago

I made some improvements afterwards (with finding some clues from https://github.com/phw/peek). Using a palette made great improvement on the gif size(~700KB per second on 1920x1080) and quality. It is not great but acceptable I think. For the processing time, I put GtkSpinner to video preview. Save button is also disabled during processing. When the conversion finishes callback hides the GtkSpinner and enables the save button. But a ProgressBar may be better solution because conversion may take long times for a recording longer than 30 seconds.

Also surprisingly video preview for gif works out of the box! However for some reason it doesn't work for large resolution gif videos. For example, a small area works but the entire screen record breaks the preview. Problem seems to be the player because it manages to display the first frame but fails to play.

Brin-o commented 3 years ago

If you still dont think file sizes are acceptable it could be worth looking into using gifski