Raymii.org
Quis custodiet ipsos custodes?Home | About | All pages | Cluster Status | RSS Feed
EasyConverter
Published: 23-12-2009 | Author: Remy van Elst | Text only version of this article
❗ This post is over fifteen years old. It may no longer be up to date. Opinions may have changed.
Table of Contents
Introduction
This is a Zentiy dialog script wrapper around ffmpeg. It was written for my father who wanted to convert FLAC and OGG files to MP3 for his media player.
Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below. It means the world to me if you show your appreciation and you'll help pay the server costs:
GitHub Sponsorship
PCBWay referral link (You get $5, I get $20 after you've placed an order)
Digital Ocea referral link ($200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!)
Features in v4:
- Extension select before folder.
- Filter on extension
- Check if files exist in folder.
- Added .flv to input format (Youtube ripped videos)
- Added .aac to input/output format
- Quality selector for ffmpeg
- Removed folder check.
- Added nautilus open when converting finished.
Note that you'll need zenity and ffmpeg:
sudo apt-get install zenity ffmpeg
Script
#!/bin/bash
####################################
## Script made by Raymii.org ##
####################################
# V0.4 new features:
# Extension select before folder.
# Filter on extension
# Check if files exist in folder.
# Added .flv to input format
# Added .aac to input/output format
# Quality selector for ffmpeg
# removed folder check.
# added nautilus open when converting finished.
# fixed the ogg big files problem, thanks http://identi.ca/habtool and http://identi.ca/lesp
padself=`pwd`/`basename $0`
function catch_errors() {
zenity --question --text="There is something wrong. Do you want to quit or restart the app?" --cancel-label="Quit" --ok-label="Restart";
[ "$?" = "0" ] &&&& ( bash -c $padself && );
exit 0;
}
function func_error2() {
echo `date +%h:%m:%s`
}
trap catch_errors ERR;
mapvraag=0
titel="EasyConverter v0.4g"
KBs=128;
FGOED=1;
opts="";
zenity --info --text="Hi, I'm **$titel** nI will help you with converting files to another format. n nIn the next window, please select the format of the files. After that please select the folder which has the audio files." --title="$titel"
vanform=$(zenity --list --title="Select a file extension" --height=270 --text "Which filetype do you want to convert?" --radiolist --column "Choose" --column "Original Format" TRUE flac FALSE ogg FALSE wav FALSE mp3 FALSE aac FALSE flv);
mapvraag=$(zenity --file-selection --directory --title="Please select a folder with $vanform files." --file-filter="*.$vanform" );
pushd "$mapvraag"
for f in ./*.$vanform; do
test -f "$f" || continue
echo "$f bestaat, mooi zo.";
FGOED=2;
done
popd
if [ $FGOED == 1 ]; then
zenity --error --text="Oops, the filetype you selected is not found in the folder you selected. nPlease try again." --title="$titel";
return 1;
fi
formaat=$(zenity --list --height=270 --text "And what should they become?" --radiolist --column "Choose" --column "Converted Format" TRUE mp3 FALSE ogg FALSE wav FALSE flac FALSE aac);
if [ $vanform = $formaat ]; then
zenity --error --text="You choose the same input and output format nI can't convert the files if you do that. nLets restart." --title="$titel"
return 1;
exit
fi
if [ $formaat == "ogg" ]; then
opts="-acodec libvorbis";
fi
KBs=$(zenity --list --height=380 --text "What output quality you want me to tell ffmpeg?n*64k*: nSmall filesnLow quality n*320k*: nBig filesnHigh quality." --radiolist --column "Choose" --column "kbps" TRUE 64 FALSE 96 FALSE 128 FALSE 192 FALSE 256 FALSE 320);
finalcheck=$(zenity --question --cancel-label="Don't" --ok-label="Lets Rock Baby!" --text="We're going to convert all files in: **$mapvraag** to ***$formaat*** at ***$KBs** kb/s*. Last check, Do or Don't?" --title="$titel")
trap func_error2 ERR;
pushd "$mapvraag"
for i in *.$vanform; do
mkdir -p "$mapvraag/converted/$formaat/"
ffmpeg -y -i "$i" -ab $KBs"k" $opts "$mapvraag/converted/$formaat/$i.$formaat" 2>&&1 | zenity --progress --text="Converting: **$i** from **$vanform** to **$formaat** at **$KBs** kb/s" --title="$titel" --auto-close --pulsate
echo $i gedaan
done
zenity --question --cancel-label="Nope, just quit." --ok-label="Yes, open it." --text="Done! nI've saved the converted files in this folder: **$mapvraag/converted/$formaat**. n nWould you like me to try and open Nautilus in the output folder? n n nThis little script is made by: **Raymii.org**." --title="$titel";
[ "$?" = "0" ] &&&& nautilus --no-desktop "./converted/$formaat";
popd
echo Done
Thanks to Andrew from webupd8 for posting it on http://webupd8.org
Tags: bash , ffmpeg , flv , loop , mp3 , ogg , software , wav , zenity