Posted on Leave a comment

Raspberry Pi Timelapse – Resequencing Images

Sometimes while taking timelapse video on the Pi, it misses frames, for no apparent reason. I have been playing with various combinations of disks/SATA cases to see what the bottleneck is. Oddly enough a faster drive actually made the problem worse!

Really Bad Frame Skipping
Really Bad Frame Skipping

Here’s an example of some really bad frame skipping, this is with a frame interval of 1250ms, which has worked fine in the past. The disk used is a 750GB WD Black 7200RPM, so disk access time shouldn’t be an issue.

Since frame skipping is rarely a problem in timelapse video I do, I’ve been searching for something to automatically renumber all the frames for processing into video – after writing my own script, which was a bit crusty, I came across a very handy script on SourceForge. It required a couple of small modifications to work correctly with what I want, but here’s the slightly modified version.

#!/bin/bash
################################################################################################
# Author:     	Paul Weibert (paul.weibert@gmail.com)
# Version:		0.1
# Dependencies: ls, sort, printf, mv, grep
# Features: 	Performs numbering of files from the specified input folder. 
#				Input files are sorted before numbering. Leading zeros can be added
# 				to the targetnumber (option -L <number of digits>).  Also a pre- and a suffix can be 
#				added to the target name (-p and -s). The sorting method can be specified (-o); 				
################################################################################################

PATHTOFOLDER=""
PREFIX=""
SUFFIX=".jpg"
SORT="modtime"
NUMBER=$(( 0 ))
LSCOMMAND="ls -1"
DIGITFORMAT="%d";
RENAME=0
GREPCMD="grep"
FILTER="\'.*\'" #match all by default

# define print function for error messages
echoerr(){ echo "$@" 1>&2;}

# prints usage information
printUsage(){ 
	echoerr "usage: numerate -d \"<path to filefolder>\" [-p \"<file prefix>\"] [-s \"<file suffix>\"] [-b <first number of target file>] [-o <order input={numerically/extension/modtime/none}>] [-L <number of digits in target number>] [-f <filename filter in grep syntax>]";
}

OPTIND=1 #Reset (just in case of prior usage)
while getopts "d:p:s:b:L:o:rf:" opt 
do
#Parse arguments
	case $opt in
		d) PATHTOFOLDER="$OPTARG";;
		p) PREFIX="$OPTARG";;
		s) SUFFIX="$OPTARG";;
		b) NUMBER="$OPTARG";;
		o) SORT="$OPTARG";;
		L) DIGITFORMAT="%0""$OPTARG""d";;
		r) RENAME=1;;
		f) FILTER="$OPTARG";;
		?) printUsage;
		   exit 1;;
	esac
done

#directory parameter is mandatory
if [ "$PATHTOFOLDER" == "" ] || [ ! -d "$PATHTOFOLDER" ]; then
	printUsage
exit 1;
fi

#parse sorting parameter for the input files
echo "Set file filter to: $FILTER"
case $SORT in 
	"modtime") 
		files=$($LSCOMMAND $PATHTOFOLDER -tr | $GREPCMD "$FILTER");;
	"extension") 
		files=$($LSCOMMAND $PATHTOFOLDER -X | $GREPCMD "$FILTER");;
	"none") 
		files=$($LSCOMMAND $PATHTOFOLDER -U | $GREPCMD "$FILTER");;
	"numerically") 
		files=$($LSCOMMAND $PATHTOFOLDER -U | $GREPCMD "$FILTER" | sort -n );;
	*) 
		echoerr "unvalid order parameter -o <param>!"
		printUsage;
		exit 1;;
esac


# save value before changing it
TMPIFS=$IFS
IFS=$( echo -en "\n\b")
# perform / simulate rename operations
for f in $files;
do
		## format number
		NUMBERSTR=$( printf "$DIGITFORMAT" $NUMBER ) 
		SOURCE="$PATHTOFOLDER/$f"
		TARGET="$PATHTOFOLDER/$PREFIX$NUMBERSTR$SUFFIX"
		PROCESSDESCRIPTION="simulating rename"
		
		if [ $RENAME == 1 ];
		then 
			PROCESSDESCRIPTION="performing rename"
			mv $SOURCE $TARGET
		fi
		
		echo "$PROCESSDESCRIPTION \"$SOURCE\" to \"$TARGET\"";
		
		NUMBER=$(( $NUMBER + 1 ))
done

IFS=$TMPIFS

With the small modifications, it renumbers the images correctly for processing by AVConv.

More scripting to come when I sort out an automatic transcode kludge!

73s for now

Posted on Leave a comment

USB-IDE/SATA Adaptor

Front
Front

This is a device to use an IDE or SATA interface drive via a USB connection. Here is the front of the device, IDE interface at the bottom, 2.5″ form factor.

PCB Top
PCB Top

PCB removed from the casing. USB cable exits the top, 12v DC power jack to the left.
SATA interface below the DC Jack.
Molex connector below SATA is the power output for the drive in use. This unit has a built in 5v regulator.

PCB Bottom
PCB Bottom

Bottom of the PCB showing the interface IC.

Drive Adaptor
Drive Adaptor

Adaptor to plug into the 44-pin 2.5″ form factor IDE interface on the adaptor, converts to standard 40-pin 3.5″ IDE.

Power Cable
Power Cable

Power pigtail with standard Molex & SATA power plugs.

Posted on Leave a comment

Western Digital 160GB 2.5″ HDD

Top Of Drive With Label
Top

This is a Western Digital drive recently removed from my laptop when it died of a severe head crash.
Top of drive can be seen here.

Top Removed From Drive
Top Removed

Here the cover has been removed from the drive, showing the platter, head arm & magnet. Yellow piece top left is head parking ramp.

Head Arm of Drive
Head Arm

The head assembly of the drive is shown here. The head itself is on the left hand end of the arm in the plastic parking ramp. The other end of the arm holds the voice coil part of the head motor, surrounded by the magnet.

Bottom Of Drive with PCB
Bottom Of Drive with PCB

Bottom of drive, with controller PCB. SATA interface socket at bottom.

PCB removed from bottom of drive. Spindle motor connections & connections to the head unit can be seen on the bottom of the drive unit.

Controller PCB. Supports the cache, interface & motor controller ICs.

Closeup of the motor driver IC, this controls the speed of the spindle motor precisely to 5,400RPM. Also controls the voice coil motor controlling the position of the head arm on the platters.

Interface IC closeup. This IC receives signals from the head assembly & processes them for transmission to the SATA bus. Also holds drive firmware, controls the Motor driver IC & all other functions of the drive.

Cache Memory IC.