How to turn stills into moving objects.


This post is a follow up on this one: http://wp.me/pNJrg-4r

Step 1: Open up a terminal.
Step 2: Enter in something like the following. 😉

## This gives you a 3 second animation\! : - )
evolvotron -g 2 2 -f 24 -r 8 -j -a -m 2 -M -x FunctionKaleidoscopeZRotate
## So fiddle a bit with -f(rames) and -r(ate) to get your desired result.
## man evolvotron
## Or if you have konqueror\? Type: man:/(1) in the location bar. ; - )
## ctrl+f enter in evolvotron

Step 3: Just keep on clicking on the main evolvotron window until you get something you like.
Step 4: Rightclick on that which has your fancy and choose save function (as e.g.: evolved0.xml). [Simplify function is optional 😉 ]
Step 4: ctrl+shift+t will open up a new terminal tab.

## In there do something like.
evolvotron_render -f 24 -r 8 -j -a -m 4 -s 720 576 -spheremap evolved.ppm < evolved0.xml

Now if you have you nautilus open, pointed at the same folder as the terminal does (as in the example video and stills I’m gonna provide) then you should see a bunch of *.ppm files appear.

## When the rendering is complete\!
## Then either do. HD quality\!
ffmpeg -y -b 3000k -r 8 -f image2 -i evolved.f%6d.ppm -qscale 4 -qblur 1.0 -aspect 16:9 -g 300 -s hd720 test.avi
## Or... 720x576 PAL
ffmpeg -y -b 3000k -r 8 -f image2 -i evolved.f%6d.ppm -qscale 4 -qblur 1.0 -aspect 16:9 -g 300 test.avi

If you’re not so much into movies then perhaps a *.gif of those files would be more appropriate?
Scriptname: ppm2gif.sh

#!/bin/bash
# Modified: Today by E.L.F.
#
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 2 of the License, or (at your option) any later
## version.
#
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
#
## You should have received a copy of the GNU General Public License along with
## this program; if not, write to the Free Software Foundation, Inc., 51
## Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## http://www.gnu.org/copyleft/gpl.html
#
## Script-name - ppm2gif.sh
#
# evolvotron -g 1 2 -f 96 -planar -r 8 -j -a -m 2 -M
# for f in *ppm ; do convert -quality 100 "$f" `basename "$f" ppm`jpg; done && \rm "$f"
RED="\033[0;31m"
BLUE="\033[1;34m"
CYAN="\033[1;36m"
YELLOW="\033[1;33m"
NC="\033[0m"
if [ $USER = root ]; then
  echo -e $RED"Are you Insane!"
  echo -e $RED"Error: In order to use this script, one must NOT be $USER"
  echo -e $YELLOW"Exiting..."$NC
  exit 0
else
  echo ""
  echo "    $USER may proceed."  
  echo "    May peace be with you."  
fi
clear
echo -n "Enter filename: "
read OUTPUT
OUTPUT=$OUTPUT
OUTPUT+=".gif"
LS=$(echo "$(ls *.ppm | sort -n) $(ls *.ppm | sort -nr)")
convert $LS -quality 100 $OUTPUT # <-- HUGE file\!
exit 0

^^ While the script I’ve provided you with just now is nice. The one below however supersedes it! 😉
*HINT* Use the “quote.sh” script (or any other way of your choosing?) to rip from the media of your choice.
Extract the required images, think -t (duration) -ss (start position) etc. Then use the script below to flip, reverse, or “flop” (reverse and mirror) it and put (if you made more than 1 version) those back together again with the “cat.files.sh” script (or any other way of your choosing?)

Example code:

## I presume you're going to work with avi files!?
## I presume you've a set of variables defined somewhere before?
## To fill in the blanks so to speak here. : - )
## There's no such thing as 'a free ride' *smiles*
## Is there?
DRATE=25
DUR=600
DRES=hd720
DASP=16:9
echo -n "Enter filename: "
read INPUT
INPUT="$INPUT"
INPUT+=".avi"
## At 25fps one hour of footage would contain exactly 90.000 stills!!!
## In the example used here that would amount to: 15.000 stills!
## Something one should not think too long about. *smiles*
## Hence the ".%5d.ppm" ; - )
ffmpeg -y -i "$INPUT" -r "$DRATE"  -t "$DUR" -s "$DRES" -aspect "$DASP" -f image2 $(basename "$INPUT" .avi).%5d.ppm

Now that you’ve got the required images: 😉
Scriptname: ppm2avi.sh

#!/bin/bash
# Modified: Today by E.L.F.
#
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 2 of the License, or (at your option) any later
## version.
#
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
#
## You should have received a copy of the GNU General Public License along with
## this program; if not, write to the Free Software Foundation, Inc., 51
## Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## http://www.gnu.org/copyleft/gpl.html
#
## Script-name - ppm2avi.sh
#
## Inspired on:
#  http://ubuntuforums.org/archive/index.php/t-1353893.html
#  START=99999
#  i=$START
#  for f in *.jpg;do mv $f $i.jpg;i=$(($i -1));echo $i;done
RED="\033[0;31m"
BLUE="\033[1;34m"
CYAN="\033[1;36m"
YELLOW="\033[1;33m"
NC="\033[0m"
if [ $USER = root ]; then
  echo -e $RED"Are you Insane!"
  echo -e $RED"Error: In order to use this script, one must NOT be $USER"
  echo -e $YELLOW"Exiting..."$NC
  exit 0
else
  echo ""
  echo "    $USER may proceed."
  echo "    May peace be with you."
fi
DR=25
export DR
clear
echo "-------------------Ppm2avi.sh Script-------------------------"
echo
echo "    Provides the possibility to mass reorder/rename,         "
echo "    a set of images. And provides the option,                "
echo "    to mass edit those before putting them back together.    "
echo "    (Edit capabilities provided by convert -> imagemagick)   "
echo "    (Useful on extracted images of older videos).            "
echo
echo "    At this moment the script's current options are:         "
echo "    Make a movie out of a set of images which plays:         "
echo -e $BLUE"    | Forward          | Backward                 |  "$NC
echo -e $BLUE"    | Forward mirrored | Backward mirrored (flop) |  "$NC
echo "    After processing. ; - )                                  "
echo
echo "    Script is inspired on/based upon:"
echo "    http://ubuntuforums.org/archive/index.php/t-1353893.html "
echo "                              Or                             "
echo
echo -e "    Hit $CYAN"Ctrl+c"$NC or $CYAN"^c"$NC to stop now.     "
echo
echo "-------------------------------------------------------------"
  echo -e $BLUE"    Make your choice. : - )"$NC
  echo -e $YELLOW"    Simply hit enter to choose forward (DEFAULT)."$NC
  echo -e $BLUE"    "Usage:"$NC $CYAN"Hit Enter"$NC | $CYAN"Mirror \| M \| m"$NC | $CYAN"Backward \| B \|b"$NC | $CYAN"Flop \| F \| f"$NC"
  echo
  echo -n "Your choice?: "
  read Choice
  Choice=$Choice
  case "$Choice" in
  "Mirror" | "mirror" | "M" | "m")
  ## Forward/mirrored.
    START=1
    S=$START
    for i in *.ppm; do convert "$i" -quality 100 -flop $(basename "$i" .ppm).fl.ppm;done
    for m in *.fl.ppm; do mv "$m" $(basename "$m" .fl.ppm).ppm;done
    for P in *.ppm;do mv $P $S.ppm;S=$(($S +1));echo $S;done
    OUTPUT=Forward.Flop.avi
    OUTPUT=$OUTPUT
    ;;
  "Backward" | "backward" | "B" | "b")
  ## Reverse.
    END=$(ls *.ppm | wc -l)
    E=$END
    for P in *.ppm;do mv $P $E.ppm;E=$(($E -1));echo $E;done
    OUTPUT=Reverse.avi
    OUTPUT=$OUTPUT
    ;;
  "Flop" | "flop" | "F" | "f")
  ## Reverse/mirrored.
    END=$(ls *.ppm | wc -l)
    E=$END
    for i in *.ppm; do convert "$i" -quality 100 -flop $(basename "$i" .ppm).fl.ppm;done
    for m in *.fl.ppm; do mv "$m" $(basename "$m" .fl.ppm).ppm;done
    for P in *.ppm;do mv $P $E.ppm;E=$(($E -1));echo $E;done
    OUTPUT=Reverse.Flop.avi
    OUTPUT=$OUTPUT
    ;;
    *)
  ## Forward [DEFAULT].
    START=1
    S=$START
    for P in *.ppm;do mv $P $S.ppm;S=$(($S +1));echo $S;done
    OUTPUT=Forward.avi
    OUTPUT=$OUTPUT
    ;;
  esac
clear
echo "-------------------Edit option.------------------------------"
echo
echo -e $BLUE"    Do you wish to mass edit the images,             "$NC
echo -e $BLUE"    before putting those back together again? : - )  "$NC
echo
echo "    (You might want to fiddle with convert's settings first.)"
echo "    (Before continuing on?)                                  "
echo
echo -e $YELLOW"    Simply hit enter for no (DEFAULT)."$NC
echo -e $BLUE"    "Usage:"$NC $CYAN"Hit Enter"$NC | $CYAN"YES \| Yes \| yes \| Y \| y"$NC"
echo
echo "-------------------------------------------------------------"
  echo -n "To edit or not to edit?: "
  read Choice
  Choice=$Choice
  case "$Choice" in
  "YES" | "Yes" | "yes" | "Y" | "y")
  for i in *.ppm; do convert "$i" -quality 100 -enhance -auto-level -gamma 1.05,1.08,1.2 $(basename "$i" .ppm).al.ppm;done
  for j in *.al.ppm; do mv "$j" $(basename "$j" .al.ppm).ppm;done
  for k in *.ppm; do convert "$k" -quality 100 -colorspace HSL $(basename "$k" .ppm).csp.ppm;done
  for l in *.csp.ppm; do mv "$l" $(basename "$l" .csp.ppm).ppm;done
  for m in *.ppm; do convert "$m" -unsharp 0x1,414+2.0+0.0078 $(basename "$m" .ppm).us.ppm;done
  for n in *.us.ppm; do mv "$n" $(basename "$n" .us.ppm).ppm;done
  ;;
  *)
  ;;
esac
ffmpeg -y -r "$DR" -i %0d.ppm -an \
-vcodec libx264 -vpre lossless_ultrafast \
-aspect 16:9 -g 300 -s cif \
-vlang pol \
-metadata title="$(basename "$OUTPUT" .avi)." \
-metadata artist="$USER" \
-metadata date="$(date +"%A, %B %-d, %Y")" \
-metadata publisher="$(echo "Your specifics.")" \
-metadata copyright="$(echo "Your specifics")" \
"$OUTPUT"
\rm *.ppm 2>/dev/null
exit 0

^^ So why is that ‘convert‘ command in there, you say? Well, in short: One of the reasons why I wrote this script is to take a movie apart piece by piece. Basically a movie is nothing more then a collection of images played one after another. Did you ever see 21? Clean up the resulting images and put those back together again as ‘new’. 😆

Fyi: it took my computer approx. 20 minutes (I’ll use the ‘time‘ command next time though for a more accurate figure!) to tear apart one minute of footage, clean everything up and put all that back together. So while an encoding session usually takes less than half that time. I daresay that it beats having to open and edit all those pictures manually! 0_o

Please note the values I’ve used for the ‘convert‘ command are ‘negotiable‘. I.e. you’ll have to determine everything from scratch for any new project/movie you wish to ‘rejuvenate‘. In short: There’s no such thing as an: *One command to rule them all* The intent is to approximate my usage of The Gimp (on a per picture bases, I appear to use the same commands over and over again). 😉


In summary:

evolvotron_render [-f <frames> ] [-j] [-m <multisample> ] [-s <width> <height> ] [-spheremap] [-v] <imagefile.[png|ppm]> < <file.xml>
evolvotron_render -f 24 -r 8 -j -a -m 4 -s 720 576 -spheremap evolved_bg.png < evolved0.xml
evolvotron_mutate -g | tee evolved0.xml | evolvotron_render -f 24 -r 8 -j -a -m 4 -s 720 576 -spheremap evolved_bg.png

More examples:

evolvotron -f 24 -r 8 -X FunctionKaleidoscope | tee evolved0.xml | evolvotron_render -spheremap -j -a -m 4 -v -s 720 576 yourname.ppm
evolvotron -g 2 2 -f 24 -r 8 -j -a -m 2 -M -x FunctionKaleidoscopeZRotate
evolvotron -g 2 2 -f 24 -r 8 -j -a -m 2 -M -x FunctionKaleidoscope

Btw, if you don’t like to read then…?
Can I have coffee to go with that? 😆


PS: If however you do like to read? 😉 Then you’re going to love all this. 😆

THE END! 😆

2 thoughts on “How to turn stills into moving objects.

  1. Please note that my usage of the *.ext (*.sh): <name-of-script>.sh is merely for convention’s sake and not for the sake of convenience. 😉

    Though in this case: There is a plethora of ppm2name-of-tool tools, thus it becomes ambiguous.

    Like

Comments are closed.