Skip to content

Instantly share code, notes, and snippets.

@harryxu
Created September 19, 2012 11:13
Show Gist options
  • Save harryxu/3749101 to your computer and use it in GitHub Desktop.
Save harryxu/3749101 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
CURRENT_PATH=`pwd`
outdir="$CURRENT_PATH/out"
if [[ ! -d $outdir ]]; then
mkdir $outdir
fi
cd "$CURRENT_PATH/origin"
VIDEOS=`find . -name "*"`
#http://unix.stackexchange.com/questions/9496/looping-through-files-with-spaces-in-the-names
OIFS="$IFS"
IFS=$'\n'
for v in $VIDEOS
do
dirname=`dirname "$v"`
basename=`basename "$v"`
outname="${basename%.*}.flv"
if [[ $dirname != "." ]]; then
vdir="$outdir/$dirname"
if [[ ! -d $vdir ]]; then
echo "mkdir $vdir ..."
mkdir $vdir -p
fi
vout="$vdir/$outname"
else
vout="$outdir/$outname"
fi
#size=`ffmpeg -i $v 2>&1 | grep Stream | sed 's/\(\d+\)/\1/'`
size=`ffmpeg -i $v 2>&1 | grep Stream | perl -lane 'print $1 if /(\d{2,}x\d{2,})/'`
#size='1440x1080'
#echo $size
ffmpeg -i $v -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 -s $size $vout
#ffmpeg -i $v -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 -s 1920x1080 $vout
done
IFS="$OIFS"
# GistID: 3749101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment