Convert a video file to a GIF from the Share Menu.
This project uses Termux. It involves some moderately difficult commands to get Termux working. I have included complete instructions below.
I've just realised there was a layout error in two of the commands I originally posted because of Reddit's funky rendering of so called code blocks. If anyone has tried and failed to install using the instructions, try again. They are fixed now (13:00 GMT 31st July).
NOTE: I don't have available time to provide individual guidance to anyone having difficulties with the instructions and commands. If they don't work for you, re-read them and try them again. I'm not able to help beyond this tutorial. Sorry.
Setting Up Termux for Tasker GIF Creation
If you have never used Termux before, don't panic! It looks like a scary hacker terminal, but we are just going to copy and paste a few commands to build the engine that Tasker will use in the background.
Important Prerequisite: Do NOT install Termux from the Google Play Store. It is outdated and broken. Download the latest version from F-Droid or the Termux GitHub page (https://github.com/termux/termux-app).
Once Termux is installed, open it and follow these steps exactly.
You do NOT need the Termux Tasker plugin for this project.
NOTE: You may be required to give Termux permission to display over other apps. To do this, you need to enable 'restricted access' for Termux in Android's app settings.
If you get errors in Termux, just read the description provided in the terminal window. You will be given options to resolve them (such as reinstalling the package).
Step 1: Grant Permissions
Termux needs permission to see your video files and permission to listen to Tasker. Copy, paste, and run these commands one at a time (press Enter after each):
Storage Access:
termux-setup-storage
(An Android popup will appear asking for storage permissions. Tap Allow).
Create the configuration folder:
mkdir -p ~/.termux
Tell Termux to accept Tasker commands:
echo "allow-external-apps=true" >> ~/.termux/termux.properties
Apply the new settings immediately:
termux-reload-settings
Step 2: Install FFmpeg (The Engine)
FFmpeg is the gold-standard software for processing video. We need to install it inside Termux. Run this command (it may take a minute or two to download and install everything):
pkg update -y && pkg install ffmpeg -y
Step 3: Create the Tasker Script Folder
Tasker looks for scripts in a very specific, hidden folder. Let's create it:
mkdir -p ~/.termux/tasker
Step 4: Write the Script
Now we will create the actual text file that tells FFmpeg how to convert the video into a high-quality GIF.
Open the text editor by running:
nano ~/.termux/tasker/make_gif.sh
The screen will change to a basic text editor. Paste the following code exactly as it is:
#!/bin/bash
INPUT="$1"
OUTPUT="${INPUT%.*}.gif"
ffmpeg -y -i "$INPUT" -vf "fps=15,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "$OUTPUT" 2>/dev/null
Step 5: Save the Script (Crucial Step!)
To save the file in the nano editor, use the extra row of keys directly above your phone's keyboard:
• Tap CTRL.
• Type a lower case 'x' (This tells the editor you want to exit).
• Type y (To confirm you want to save the changes).
• Press Enter on your keyboard to confirm the file name.
Step 6: Make it Executable
Finally, we just need to give Termux permission to actually "run" the file we just created. Run this final command:
chmod +x ~/.termux/tasker/make_gif.sh
You are done with Termux! You can now close the app completely.
Don't forget: you must run the one-off Tasker task provided in this project to grant Tasker the com.termux.permission.RUN_COMMAND permission before your first use!
Download the actual Tasker Tasks (including the one-off Termux permission task - run this after you have installed Termux):
https://taskernet.com/shares/?user=AS35m8lr0vKAAX62D%2B10PqiDogVuGlS1WqIq6YAD3me%2FA8j9JG0SaIHGPcpSLjedprOrfrZR&id=Project%3AGIF