Created
May 3, 2017 08:45
-
-
Save alinradut/3b1e8768b7a754d38d19b73d03eead15 to your computer and use it in GitHub Desktop.
A script that will convert a regular video to a rotoscoped video. Requires autotrace, ffmpeg, imagemagick.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# rotoscope - auto rotoscope a video file with openSource Software on Linux | |
# needs ffmpeg, autotrace and ImageMagick | |
# usage: rotoscope videofile //will create videofile.rotoscoped.avi | |
# created by Honza Svasek : HonzaSvasek.nl | |
# edited by Joseph Riopelle finitelife[at]hotmail.com | |
set -x | |
export TMPDIR=/tmp/rotoscope$$ | |
export FILM=$1 | |
export CWDIR=$PWD | |
mkdir $TMPDIR; cd $TMPDIR | |
export AUDIO_CODEC=`ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 $CWDIR/$FILM` | |
ffmpeg -vn -i $CWDIR/$FILM -acodec copy audio.$AUDIO_CODEC | |
ffmpeg -an -i $CWDIR/$FILM %09d.bmp | |
export FILES=`ls -l *.bmp|wc -l` | |
for FILE in *.bmp; do | |
export COUNT=$(($COUNT+1)) | |
echo -n -e "\r$((($COUNT*100)/$FILES))% done tracing [$FILE]..." | |
autotrace $FILE -output-format svg -color-count 20 -despeckle-level 20 -filter-iterations 4 -output-file ${FILE}.svg | |
#-color-count 10 -despeckle-level 20 -filter-iterations 10 | |
# rm -f $FILE | |
# convert -density 300 -resize 1280x960 ${FILE}.svg $FILE | |
convert ${FILE}.svg $FILE | |
rm -f ${FILE}.svg | |
done | |
echo -e "\rDone! Successfully traced $FILES files." | |
ffmpeg -i audio.$AUDIO_CODEC -i %09d.bmp $CWDIR/$FILM.rotoscope.mp4 | |
cd $CWDIR; | |
rm -rf $TMPDIR | |
echo "Rotoscoped file created: $CWDIR/$FILM.rotoscoped.avi" | |
unset CWDIR TMPDIR FILM COUNT FILES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment