Whilst creating some lesson slides in Google recently I wanted to add some moving images to the slides. You can see an example of one the slides I am talking about embedded below. It is a session that I delivered with Dan Aldred at the ExaBytes17 conference about using the Raspberry Pi Sense Hat.
By using the Sense Hat Online Emulator over on Trinket, I could model what the program was going to do and then use a screen recording program to capture this back to an mp4 file. On my Windows PC at work I used the Snagit software to record my screen, but at home on my Ubuntu PC I used SimpleScreenRecorder.
So once I had my mp4 video file I wanted to use as my animated GIF, I needed to convert it somehow. As I am exclusively using Linux at home, I wanted a solution which used cross-platform Open Source software so that I could use the same process both at work and at home.
First off we need GIMP installed; download and install the correct version for your operating system from their site. Once you have done that and you are happy that GIMP runs correctly, we need to add another package to GIMP; the GIMP Animation Package. You can find a pre-compiled binary for GIMP GAP for Windows here and to install GIMP GAP on Ubuntu simple type the following into your terminal:
sudo apt-get install gimp-gap
Now when you run GIMP you should see a new menu item entitled “Video…”. From here on out the steps should be the same no matter what operating system you are using!
- Click the “Video > Split Video into Frames > Extract Videorange” menu item
- Click the “…” to the right of the “Videofilename” text box and browse to your MP4 video saved earlier
- Click “Video Range” to preview the video that you just imported
- Use the slider to move the video preview to the first and last frames you want, making a note of the frame numbers
- Enter the first frame number you noted down into the “From Frame” box
- Enter the last frame number you noted down into the “To Frame” box
- Ensure that “Create only one multilayer image” is checked.You can see all the settings required in the image below:
- Click OK to create a new file in GIMP which will have your animation in it. If you get a warning about “frame.wav” already existing you can safely click “Overwrite File”
- To save your animated GIF select “File > Export As”
- Navigate to the folder you want to output to. Give the file a name appended with .gif at the end and click “Export”
- The “Export Image as GIF” window will then open; select “As animation” and “Loop forever” as shown below
- Click “Export” to save your animated GIF file
Once GIMP finishes exporting your GIF file you can then just drag and drop it onto your Google Slides to have an animated image running without the need to embed and launch videos.
Exactly what I was looking for, but Gimp failed to recognize .MP4 as a file type after I installed gimp-gap. What did I miss doing?
Jon