0

I am struggling with something I thought would be a piece of cake. In my Android App (jetpack compose variant), I want to save some screenshots (not many, 10-20 of them), and then "packed them" into animated GIF file, and then user would be able to share this GIF to other users. I am having a hard time "creating" or "saving" GIF file from saved screenshots. The only thing I found on web was pretty old post here

1: How to create an animated GIF from JPEGs in Android (development) but I just can't get it to work. All the others posts are related to "displaying" GIF in android, which is not my problem currently. If someone can point me in the right direction, would be very nice.

I also try to make it to work with FFmpeg, but don't know how to either. https://proandroiddev.com/a-story-about-ffmpeg-in-android-part-i-compilation-898e4a249422

Thank you

Gregor Sotošek
  • 357
  • 1
  • 4
  • 22
  • The question you linked has good answers. If you couldn't get it to work, please show what you tried so we can suggest how to fix it. Otherwise, the best we can do is copy-paste the answers from that question. – Tenfour04 Mar 02 '22 at 14:48

1 Answers1

0

OK, better late than never. I managed to get achieve this with the help of a library:

implementation 'com.arthenica:ffmpeg-kit-full:4.5.1-1'

I needed to learn a few things about ffmpeg, and must say it's imppressive.

After making an screenshot of my camera every 500ms, I endeed up with a folder of cca 50 jpgs.

val commandString = "-framerate 10 -i $pathToFiles -c:v mpeg4 -vf scale=1000:-2 -r 10 $fullFileNameOut"

This is the command string for ffmpeg session that creates mp4 video. There's a reason they call ffmpeg a swiss army knife for audio/video. Great stuff.

Gregor Sotošek
  • 357
  • 1
  • 4
  • 22