A (sorta) GIF player for ESP32/arduino
For this project you dont need really much stuff. Stuff you need:
- ESP32 (or any arduino compatible board that can handle JPG processing.)
- Display (any display supported by Bodmer's TFT_eSPI works.)
- SD card slot (can be internal and external module)
- Wires (obviously, unless...)
Important
Some other arduino compatible boards dont work with some libraries in this code, thus it will need a port.
For the code to upload and work properly you will need some extra libraries:
- TFT_eSPI , FS, TJpg_Decoder, SD, SPIFFS
Note
FS and SPIFFS are included in the ESP32/ESP8266 core, if you dont have one of these boards you might have to install them seperately.
I have developed a software for automatically turning GIFS to frames used by this program. You will need it unless you will do it manually. animplayer32converter
If using PlatformIO, go to platformio.ini and change the TFT_eSPI display settings. At the beginning of the code in the .ino file there is a special section where you can toggle different debug/optimisation settings. As of now they are:
SETTINGS FOR DEBUGGING AND GENERAL OPTIMIZATION
preloadCount = amount of frames to preload
showFPS = show FPS counter at the top left of the screen
showFramePassed = show what GIF frame its currently on
reset10thFrame = not very good optimisation method but im keeping it here, resets display (white screen) every 10th frame
resetAfterPlayback = SLIGHTLY better perfomance but at the end of the GIF a white screen flashes for a second
useLegacy = use legacy frame counting mode (defined in code)
useLegacy will have more docummentation here
Important
Wire the display and SD card module correctly, you can change the pins if you want to for the SD. The TFT has your config in the User_Setup.h file of the TFT_eSPI library. Dont forget to set up TFT_eSPI first.
After fiddling with the settings, it is time to flash. just use your ideal IDE to flash the code onto your board
I have made a program for automatizing that, as mentioned. It is really simple, just follow what it says.
- Download the program
Download it here.
-
You will have to input the drive letter of the SD card, or any folder if you want to save it to your PC.
- Input Y to confirm, N to exit.
- The program automatically converts the GIFs to .jpg format and renames them.
- Results
Warning
GIFs have alpha transparency, just like PNGs. So some GIF frames can be corrupted after conversion, if it happens try again with a similar GIF.
useLegacy is only useful for GIFs with many frames, as it will take long (depending on SD card and MCU speed) to count them all to make the program know how much frames to play.
-
Comment the variable with 0 and uncomment the one where it says legacy. put the amount of frames the GIF has there

After that frame counting will be instantaneous (as it doesnt need to go through the files to scan) , its unreliable if you hotswap GIFs through your SD card, and its only reccomended for large GIFs that will take a lot of time to count.
You can put these settings as true to get slight perfomance increase.
Note
Its only reliable for large GIFs, once again. But resetAfterPlayback can be a bit useful for lighter GIFs.
These are my tests that I have tested on specific hardware. Any little thing can impact perfomance, even the GIF used. If you want, you can post your own perfomance results at the issues section and tag it as "Perfomance test", dont forget to write your board, SD card slot model, TFT driver, SD card itself, SPI speeds used and a video showing the FPS.
- My tests:
ESP32, ST7735 display, random SD card slot, 128mb SD card and 80mhz SPI speed (not sure if some of that has gone to waste)\
- v1.0.0
Max: 15-ish FPS
Min: 13-ish FPS - v1.1.0
Max: 21-ish FPS
Min: 20-ish FPS
- v1.0.0
- Community tests: coming soon, hopefully








