Skip to content

Instantly share code, notes, and snippets.

@bmatherly
Created February 14, 2014 04:36
Show Gist options
  • Save bmatherly/8995878 to your computer and use it in GitHub Desktop.
Save bmatherly/8995878 to your computer and use it in GitHub Desktop.
deinterlace
#!/bin/sh
SRCFILE=$1
DSTFILE=$2
# Sanity checking, to make sure everything is in order.
if [ -z "$SRCFILE" -o -z "$DSTFILE" ]; then
echo "Usage: $0 <Source File> <Destination File>"
exit 5
fi
if [ ! -f "$SRCFILE" ]; then
echo "File does not exist: $SRCFILE"
exit 6
fi
vidinfo=`ffmpeg -i $SRCFILE 2>&1 | grep Video:`
width=`echo "$vidinfo" | sed "s/.* \([1-9][0-9]*\)x\([0-9]*\).*/\1/"`
height=`echo "$vidinfo" | sed "s/.* \([1-9][0-9]*\)x\([0-9]*\).*/\2/"`
if [ "$width" -gt 720 -o "$height" -gt 480 ]; then
ionice -c3 nice -19 ffmpeg -i $SRCFILE -vf yadif=1:1:1 -r 60000/1001 -pix_fmt yuv422p -vcodec dnxhd -acodec copy $DSTFILE
else
ionice -c3 nice -19 ffmpeg -i $SRCFILE -vf yadif=1:1:1 -r 60000/1001 -pix_fmt yuv422p -vcodec huffyuv -acodec copy $DSTFILE
fi
# Make sure the deinterlace succeeded.
if [ ! -f $DSTFILE ]; then
echo "Deinterlace Failed"
exit 7
fi
#!/bin/bash
SRCDIR=$1
DSTDIR=$2
# Sanity checking, to make sure everything is in order.
if [ -z "$SRCDIR" -o -z "$DSTDIR" ]; then
echo "Usage: $0 <Source Directory> <Destination Directory>"
exit 5
fi
if [ ! -d "$SRCDIR" ]; then
echo "Source directory does not exist: $SRCDIR"
exit 6
fi
if [ ! -d "$DSTDIR" ]; then
echo "Destination directory does not exist: $DSTDIR"
exit 6
fi
shopt -s nullglob
for srcfile in $SRCDIR/*.dv
do
# Cleanup the file name
dstfile=`echo $srcfile | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'`
dstfile=${srcfile%.*}
dstfile=${dstfile##*/}
dstfile="$DSTDIR/$dstfile.mkv"
echo "Deinterlace $srcfile to $dstfile"
./deinterlace.sh $srcfile $dstfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment