Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created October 7, 2018 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gibatronic/364c156e0e346783c1800ba9a3863769 to your computer and use it in GitHub Desktop.
Save gibatronic/364c156e0e346783c1800ba9a3863769 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Convert any webm video file inside the Downloads folder to mp4
#
# Usage:
# ./webm2mp4
main() {
local videos=$(find ~/Downloads -name '*.webm')
if [ -z "$videos" ]; then
return
fi
while read path_webm; do
local path_mp4=${path_webm/%.webm/.mp4}
echo "$path_webm" "$path_mp4"
ffmpeg -i "$path_webm" "$path_mp4"
local exit_code=$?
if [ "$exit_code" = '0' ]; then
echo -en "\033[32m✓\033[0m"
rm "$path_webm" &> /dev/null
else
echo -en "\033[31m✖\033[0m"
fi
local file_mp4=$(basename "$path_mp4")
echo " $file_mp4"
done <<< "${videos[@]}"
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment