Skip to content

Instantly share code, notes, and snippets.

@luanlmd
Created October 10, 2014 19:54
Show Gist options
  • Save luanlmd/5dfab7a3f0da7b05b33d to your computer and use it in GitHub Desktop.
Save luanlmd/5dfab7a3f0da7b05b33d to your computer and use it in GitHub Desktop.
Convert avi files in a folder to webm
#!/bin/sh
COUNT=$(ps ax | grep avconv | wc -l)
if [ $COUNT -gt 1 ]; then
echo "running already"
exit 0
fi
i=1
while [ $i -le 3 ]; do
FILE=$(find /var/www/html/ -name "*.avi" | head -n $i | tail -n 1 )
WRITING=$(lsof | grep $FILE | wc -l)
if [ $WRITING -eq "0" ]; then
WEBM=$(echo $FILE | sed -e "s/avi/webm/g")
/usr/bin/avconv -i $FILE $WEBM -y
rm $FILE
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment