Termux is our favorite terminal emulator for Android. Yesterday, we saw, how to use Termux to download any video. And today, we'll take a look at how you can use it to convert any video on android with FFmpeg.
Why Termux?
There is no real advantage of using Termux over Video Converter apps for Android that you can find on Google Play Store. Though, using terminal definitely look geeky and you can FFmpeg support 100s of video format and image. Again, thanks to Gabi Tiplea, for providing all the source code. This method should work along with our previous YouTube-dl library. Related: Reduce File Size With These Video Compressor App For AndroidFollow the steps
1. Go to play store and download the termux app.
2. Next, open the termux app and copy paste the 4 commands in the same order. Just copy paste them it will run som commands to download the library.
wget https://pastebin.com/raw/qBV2u7Ey -O install.sh
dos2unix install.sh
chmod u+x install.sh
./install.sh

4. A popup box will open, enter the new file name and its extension and tap on Edit.
5. Termux will run series of commands. Once it's done, it'll prompt you to press the Enter key. Do that.
6. Now, go to the internal storage of your Android and look for the folder ConvertedFiles, open it and there you'll find all your converted files.
Here is the code for all those who are interested.
#!/data/data/com.termux/files/usr/bin/bash # 15/05/2017 Gabi Tiplea echo -e "Updating default packages\n" apt update && apt -y upgrade echo -e "Requesting acces to storage\n" termux-setup-storage sleep 5 echo -e "Installing ffmpeg\n" packages install -y ffmpeg echo -e "Creating bin directory\n" mkdir ~/bin echo -e "Creating convertedFiles directory\n" mkdir ~/storage/shared/convertedFiles echo -e "Downloading and installing termux-file-editor\n" wget http://pastebin.com/raw/JxKNaixQ -O ~/bin/termux-file-editor dos2unix ~/bin/termux-file-editor echo -e "Copyright 2017 Gabi Tiplea"
#!/data/data/com.termux/files/usr/bin/bash # 15/05/2017 Gabi Tiplea name=$(echo $1 | grep -Eo '[^/]+$') ffmpeg -i ~/downloads/"$name" ~/storage/shared/convertedFiles/"$name" rm ~/downloads/"$name" echo -e "Copyright 2017 Gabi Tiplea\n"
Updated: October 10, 2021