Skip to content

Instantly share code, notes, and snippets.

@ravihara
Created November 10, 2017 09:55
Show Gist options
  • Save ravihara/75078bafee933bc91e0d57287c44d1ed to your computer and use it in GitHub Desktop.
Save ravihara/75078bafee933bc91e0d57287c44d1ed to your computer and use it in GitHub Desktop.
#!/bin/bash -e
# Shell script to convert videos in a folder to mp4 format
export IFS=$(echo -en "\n\b")
VID_LIST_FILE="/tmp/videos.txt"
## List out the videos first
rm -f $VID_LIST_FILE
for a in $(find . -iname "video*" -type d); do
find $a -name "*" -type f | grep -v "Thumbs.db" | sed -e 's/^.\///' >> $VID_LIST_FILE
sync
done
## Convert the videos to mp4
for a in $(cat $VID_LIST_FILE); do
b="$(echo $a | sed -e 's/.\w\+$/.mp4/')"
ffmpeg -i "$a" -vcodec libx264 -b 500k "$b" && sync
done
# Finally, remove the temporary video list file
rm -f $VID_LIST_FILE
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment