Script to create slideshow from XMP files

A good starting point. Hopefully someone has some time to clean up my code :wink: This is from my latest episode where I cover my latest Milky Way processing with the equalizer module.

http://weeklyedit.com/animate-your-edit/

#!/bin/zsh

# usage: dt_movie.zsh file1.RAW file2.tif etc
# requires the use of sidecar xmp files
# make sure Darktable isn't running because only 1 instance is allowed at a time

frame_seconds=2.5
frame_width=1920
frame_height=1080
font_size=24
extra_frames=10
rm -fr /tmp/dt_movie*
mkdir /tmp/dt_movie &> /dev/null
typeset -Z4 index1 movie_index hist_index frame
index1=0; movie_index=1
first=$1
echo
echo "index \t hist \t enabled \t operation \t filename" |expand -t16
echo "---"
for file in "$@"; do
  index2=0
  grep -B1 'enabled=' $file.xmp |tr '\n' ' ' |sed -e 's/-- */!/g' |tr '!' '\n' |cut -d'"' -f2,4 |tr '"' ' ' |while read operation enabled; do
    echo "$index1 \t $index2 \t $enabled \t $operation \t $file" |expand -t16 >>/tmp/dt_movie.list
    ((index1++))
    ((index2++))
  done 
done
((index1--))
cat /tmp/dt_movie.list
echo
echo -n "starting point (1): "
read starting_point
echo
[ -z $starting_point ] && starting_point=0
seq $starting_point $index1 |while read hist_index; do
  grep "^$hist_index" /tmp/dt_movie.list |read a b c d e
  if [ $c -eq 1 ]; then
    ((index2++))
    rm /tmp/dt_movie.jpg &> /dev/null
    cp $e.xmp /tmp/dt_movie.xmp
    sed -i "s/darktable:history_end.*$/darktable:history_end=\"$b\">/" /tmp/dt_movie.xmp
    darktable-cli "$e" /tmp/dt_movie.xmp /tmp/dt_movie.jpg --width $frame_width --height $frame_height &> /dev/null
    echo "$a"/"$index1" $d |read text
    echo $text
    convert /tmp/dt_movie.jpg -pointsize $font_size -fill "#FFFFFF" -draw "text 10,32 '$text'" -background black -gravity center -extent "$frame_width"x"$frame_height" /tmp/dt_movie/$movie_index.jpg &> /dev/null
    ((movie_index++))
  fi
done
seq 1 $extra_frames |while read frame; do
  convert /tmp/dt_movie.jpg -pointsize $font_size -fill "#FFFFFF" -draw "text 10,32 '$text - finished'" -background black -gravity center -extent "$frame_width"x"$frame_height" /tmp/dt_movie/$movie_index.jpg &> /dev/null
  ((movie_index++))
  echo $frame
done
avconv -f image2 -r $((1/$frame_seconds)) -i /tmp/dt_movie/%04d.jpg -aspect 16:9 -b:v 15000k -y $first.avi &> /dev/null
rm -fr /tmp/dt_movie*

3 Likes