Thursday, November 25, 2010

A Crumb for Later: ffmpeg runes to generate an animation

I found a faded post-it note from a friend who gave me the following incantation to convert a set of still images into an MPEG animation using ffmpeg. This note is a crumb for later investigation.

ffmpeg -r1 -f image2 -i <input> -vcodec mpg2video \
 -r 30000/1001 -b 25000k <outMovie.mpg>

If memory serves, the 30000/1001 may need to be changed to the decimal value, but I'll see if ffmpeg will parse and calculate on its own ;-)

Wednesday, November 24, 2010

Easily moving pictures from camera to hard drive

Getting files from the camera to hard drive is sometimes accompanied by confusion and consternation when custom actions are needed. Given powerful tools and a bit of facility with scripting, retrieving the files can be as simple as <fromDir> <toDir>

A special love note for my better half. For the old camera disk use

/DATA01/bin/ /media/disk/DCIM/101MSDCF /DATA01/Pictures 

For the new camera disk 1 use

/DATA01/bin/ /media/1A48-D026/DCIM/100D7000 /DATA01/Pictures

Love, your system administrator.

The heart of this solution is the perl exiftool ( that can interrogate, modify, and otherwise act on tags in image files. This article describes an application of the renaming functionality ( Specifically, when moving the files from the camera media (e.g. /media/1A48-D026/DCIM/100D7000) to the root of an images directory (e.g. /DATA01/Pictures) the requirements are:

  1. Separate pictures into directories by date
  2. Format of the directories are year/month/year-month-day where the date is given in digits only
  3. Create directories if they do not already exist
  4. Ensure that the extensions are lower case
    • The need for this was driven by the use of some web applications that do not display files with uppercase extensions
  5. The date information shall come from the original date and time in the image header

All these requirements are met in a single invocation

exiftool '-FileName<DateTimeOriginal' \
 -d /DATA01/Pictures/%Y/%m/%Y-%m-%d/%%f.%%le \

Two potentially tricky bits are the double percent (%%) for the file and extension formats (%%f and %%e respectively), and the lowercase modifier for the extension (%%le). The need for quotes around the first argument is because the exiftool syntax < would otherwise be interpreted by the shell instead of being sent to the script.

While the invocation is not terribly difficult, there is enough typing to make it worthwhile for a simple script (e.g. A minimal implementation that takes two arguments — a from and to directory — is written here in bash.

exiftool '-FileName<DateTimeOriginal' \
 -d $tgtdir/%Y/%m/%Y-%m-%d/%%f.%%le $srcdir