Journal

/A/ /M/A/G/N/I/F/I/C/E/N/T/ /P/L/A/C/E/ 

August 2014

It must be the effect of my new job, having finally escaping the mindless drudgery of factories and warehouses of the past ten years, I find myself working with computers, doing some fairly basic digital magazine layout work. I can't quite believe it yet; having frequently believed it would be necessary to resign myself to factory work. Luckily however, just in the nick of time, I'm out and landed a job which I'm actually enjoying!

So the night before last I decided to have a go at writing a Bash script to generate a video of scrolling text running from right to left. The script makes use of ImageMagick and FFmpeg to do this. To begin with, I used the Gimp to render an single image of the text I wanted, and my script processed it rendering frames as a directory of image files before FFmpeg pulled them into a video. Another toy I've recently been playing with is slowmoVideo (for example see: Aqua Cluck Spying Pan) which I used to add some noise to the otherwise stark black and white text, the image above is a still from the final video I uploaded to youtube.

While it was ok for a first experiment, there was obviously more that could be done. I recalled a scrolling text demo from my teens and Amstrad CPC days. The demo had text scrolling across stripes scrolling slightly slower to produce a parallax effect. My goal was to reproduce something similar. The first step was to get my script to render the initial text image rather than having to create the text image seperately. This turned out to be fairly simple.

The second step was to create the stripes, again, this wasn't too difficult, although there were a number of times where I continually stumbled around in the dark not really understanding how ImageMagick works. The third step, of course, was to do something a bit better with the text than that done on the Amstrad CPC, and due to my consultation with the ImageMagick documentation, I had a good idea of what to do there: a soft shadow effect.

Again, more stumbling around, but eventually got it working. Because it was getting late, and I was reasonably happy with the end result, I decided to not use slowmoVideo this time and upload it to youtube as it was. The image above is a still from the video. Below is the script itself:

#!/bin/bash
#
# scroll text - scrolls text
#   by james w. morris.
#
#   creates a video of text scrolling over moving stripes to
#   give slight parallax effect.
#
#------------------------------------

text="The quick brown fox jumped over the lazy dog"

# text properties:
TXTFONT="NewCenturySchlbk-BoldItalic"
TXTSIZE="200"
TXTFILLCOL="orange"
TXTLINECOL="SaddleBrown"
TXTSTROKE="8"

# number of pixels to move text each frame
STEP=4

# output image dimensions:
OW=640
OH=480

# output directory to render frames to:
ODIR="out"

# stripe properties:
STRIPECOL1="CornflowerBlue"
STRIPECOL2="LightSteelBlue4"
STRIPEW=32

# general background colour:
BGCOL="MidnightBlue"

# end of configurable options
#------------------------------------

function image_geometry
{
    IFS= set $(identify -format "%w %h" $1)
    W=$1
    H=$2
}

if [ -d $ODIR ]; then
    echo "Output directory '$ODIR' exists. Abort."
    exit
fi

mkdir -v $ODIR

if [ ! -d $ODIR ]; then
    echo "Failed to create output directory '$ODIR'. Abort."
    exit
fi

convert -pointsize   $TXTSIZE       \
        -font        $TXTFONT       \
        -strokewidth $TXTSTROKE     \
        -stroke      $TXTLINECOL    \
        -fill        $TXTFILLCOL    \
        -background none label:"${text}" \
        \( +clone -shadow 70x8-24+24 \) +swap -composite \
        text.png

image_geometry text.png
TW=$W
TH=$H

# make stripes...
SW=$((STRIPEW*4))
SH=$((TH*4))
SH=$((SH/3))
ASH=$((SH*3))
ASH=$((ASH/4))
SX1=$((STRIPEW*2))
SX2=$((SX1+STRIPEW))
convert -size ${SW}x${SH} xc:none \
        -fill $STRIPECOL1 -draw "rectangle 0,0    $STRIPEW,$ASH" \
        -fill $STRIPECOL2 -draw "rectangle $SX1,0 $SX2,$ASH" \
        \( +clone -background black -shadow 70x10-32+32 \) +swap -composite \
        stripe.png

until [ $SW -gt $TW ]; do
    convert stripe.png stripe.png +append stripe.png
    image_geometry stripe.png
    SW=$W
done

# create background
convert -size "${OW}x${OH}" xc:$BGCOL bg.png

N=0
F=1
S=0
MAX=$((TW+OW))
MAXFRAMES=$((MAX/STEP))
SY=$((OH-SH))
DY=$((SH-TH))
DY=$((DY/2))
TY=$((SY+DY))

until [ $N -gt $MAX ]; do
    echo Processing frame $F of $MAXFRAMES
    OF=$(printf "%s/frame_%06d.jpg" $ODIR $F)
    TX=$((OW-N))
    SX=$((0-S))
    convert bg.png \
        stripe.png -geometry +$SX+$SY -composite \
        text.png   -geometry +$TX+$TY -composite $OF
    N=$((N+STEP))
    F=$((F+1))
    S=$((S+1))
done

ffmpeg  -i "$ODIR/frame_%06d.jpg" -r 30 -vcodec h264 scrolltext.mov
    

21:29 Friday 8 August 2014

Aqua Cluck Spying Pan

Aqua Cluck Spying Pan
*********************


If the aqua cluck rendering spilled lying pan,
Ties semi deposited and tic-plied bottled shores,
Then pretty sizzling he has shammed ladled spores,
And witty eyes dazzle with claimed penetrative claws.

But if the lemon risk battle can rot tapered licks sly cord
God help the flack wrap transitioning pig bucks wry wing span.


The clan ring stationary trundle sucking clap sack,
Is raw crying plausible stabbing pick (it's got pissed talent),
Shouting "coleslaw raid enigma drains pies literature!",
And dual core oscillating gawping grannies rise twittering:
"Lord Patricia Lock Lucas in Gorrick drips semiotics".

But the stereo panel shortens when ducks drown.



Information

"Journal"

A page detailing new stuff and other random noise.

The journal is a general place for writing about what I am doing, or for making more official announcements concerning the things I do. It's also a place where I can write freely about my ideas, or just play with words and language.

DISCLAIMER: The opinions and attitudes of James W. Morris as expressed here in the past may or may not accurately reflect the opinions and attitudes of James W. Morris at present, moreover, they may never have.

this page last updated:29th April 2013 jwm-art.net (C) 2003 - 2014 James W. Morris

script time:0.0627