From 43d203457626867edc2ce46f0112dbfc70c34e9f Mon Sep 17 00:00:00 2001 From: litter Date: Tue, 11 Feb 2020 18:10:37 -0500 Subject: [PATCH] Add scripts --- scripts/calibration.sh | 23 +++++++++++++++++++++++ scripts/export.sh | 29 +++++++++++++++++++++++++++++ scripts/pages.sh | 22 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 scripts/calibration.sh create mode 100755 scripts/export.sh create mode 100644 scripts/pages.sh diff --git a/scripts/calibration.sh b/scripts/calibration.sh new file mode 100644 index 0000000..f1c3a6b --- /dev/null +++ b/scripts/calibration.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Script to change the generated calibration tif files to +# properly scaled files that is a lossless png. The resulting +# file should be massively smaller--100's of MBs to KBs. + +#Requires ImageMagick + +#Printer DPI +DPI=1440 +#Location of calibration files +CALIBRATION_FILES="../filmless_calibration/*.tif" + +echo "Changing calibration files to ${DPI}dpi and converting to .png..." + +for f in $CALIBRATION_FILES +do + name=$(basename "$f" .tif) + #echo $name + echo "Converting $f -> ../filmless_calibration/${name}.png..." + convert $f -units PixelsPerInch -density $DPI "../filmless_calibration/${name}.png" + rm $f +done diff --git a/scripts/export.sh b/scripts/export.sh new file mode 100755 index 0000000..abd4395 --- /dev/null +++ b/scripts/export.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +WITH_SOUND=true #change to false for a silent film + +#changes based on printer DPI, this is for 1440 +#check the output of the calibration script +AUDIO_RATE=10296 + +#Either use the script by passing in a path, ie: +#sh export.sh /path/to/my/video.mov +#or hardcode it by changing VIDEO=${1} to VIDEO=/path/to/my/video.mov +VIDEO=${1} + +# change these to directory where you will store your frames and audio +FRAMES_DIR=~/Desktop/frames/ +AUDIO_DIR=~/Desktop/audio/ + +mkdir -p "$FRAMES_DIR" +mkdir -p "$AUDIO_DIR" + +echo "Exporting ${VIDEO}..." + +rm "${FRAMES_DIR}*.png" +ffmpeg -y -i "${VIDEO}" -f image2 -r 24 "${FRAMES_DIR}image-%04d.png" + +if [ "$WITH_SOUND" == "true" ]; then + echo "Exporting audio from ${VIDEO}..." + ffmpeg -y -i "${VIDEO}" -y -acodec pcm_s16le -ac 1 -ar $AUDIO_RATE -ss "$START" -t 15 "${AUDIO_DIR}audio.wav" +fi diff --git a/scripts/pages.sh b/scripts/pages.sh new file mode 100644 index 0000000..66dd623 --- /dev/null +++ b/scripts/pages.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Script to properly scale generated page_#.tif files +# to your desired DPI. + +#Requires ImageMagick + +#Printer DPI, same as in filmless_processing.pde +DPI=1440 +#Location of generated pages +PAGE_FILES="~/Desktop/page_*.tif" + +echo "Changing calibration files to ${DPI}dpi..." + +for f in $PAGE_FILES +do + name=$(basename "$f" .tif) + #echo $name + echo "Converting $f..." + mogrify $f -units PixelsPerInch -density $DPI + rm $f +done \ No newline at end of file