command line

Using Smugmug as a Photo Backup Location

I’ve finally gotten around to uploading my photo collection. I’ve decided to pay for a subscription to Smugmug.com and so far I’m happy with it. I chose not to use Flickr or other options because I wanted a site which I could use as a private one-to-one backup of my personal store of photos. I can make albums or photos public using other services or through Smugmug. I also wanted to be able to synchronize tags and metadata between the on-line store and my digikam-managed local version. If I ever lose my local copy, I should be able to download a full copy of everything in its original form. Smugmug appears to be able to do all of that (and has other good features, too).

To do the synchronization, I’m using the php uploader found here. It seems to be working, although I had some trouble at first pointing it at the right directory on my system. Running the upload program is simple:

php /path/to/multi-album-upload.php /path/to/pictures

NOTE: I initially had a little trouble because I was pointing to the wrong level in the hierarchy of my picture directory tree. The program assumes an arrangement something like this:

home
user
photo_library
category
album
image.jpg

My reading of the instructions implied that you could point to “/home/user/photo_library/category” but that doesn’t work. You need to point to “/home/user/photo_library.”

Scanning via USB from a Brother MFC-8500C

I’m still working on digitizing all my old media, including paper. I have an old Brother laser multi-function with an automatic document feeder that I’ve only ever used as a printer and fax. I tried to set it up for scanning years ago, but had no success. Times have changed and I had no problem getting it working this time around so I can scan all my old paper files.

Scanning only works for the root user at the moment, but I don’t care. Discussion here.

Step 1. Download and install the linux drivers which are now available from Brother here. The instructions provided worked flawlessly on Ubuntu Jaunty.

Step 2. As root, Install the sane-utils and libtiff-tools packages.

sudo apt-get install sane-utils libtiff-tools

Step 3. Scan. XSane worked fine for basic scans, but I want to be able to do double-sided scanning on a simplex scanner, so I decided to use the command line for this. There are other tools available if you prefer a gui.

To scan letter-size single sided:

scanimage -y 279 –format=tiff –batch –progress

The “-y 279″ is the page length in mm — without it, scanimage seemed to create legal size scans by default. To scan a pile of pages on both sides, start with side one:

scanimage -y 279 –format=tiff –batch –progress –batch-double

Then, flip over the pile and substitute the last page number (which the previous command will tell you) minus one for “[last page - 1]” below:

scanimage -y 279 –format=tiff –batch –batch-double –progress –batch-increment=-2 –batch-start [last page - 1]

Finally, put the whole thing together in one big tiff and convert to pdf:

tiffcp out*.tif out_all.tif;tiff2pdf out_all.tif -o filename.pdf;rm -f out*.tif

The final rm is added to the previous command so that you can continue scanning jobs without either getting your tiff files mixed up or inadvertently trying to include a finished multipage tiff in the next pdf conversion.

I have written a script which prompts the user for single or double-sided printing and an output filename, then scans and converts documents:

#!/bin/bash
#kk a script to scan a batch of pages on both sides, then combine and convert them to pdf

WORKDIR=”/tmp”
OUTPUTDIR=”/home/kevin/Dropbox/tmp/scans”
DATESTAMP=$(date ‘+%Y%m%d%H%M%S’)

#clean up
rm -f $WORKDIR/out*

#prompt for single or double-sided scanning
read -n 1 -p “How many sides ([1]/2)? ” SIDES
if [ "$SIDES" == "2" ]
then

#scan the first sides
#the end of this command sends progress output to both stdout and to a file
scanimage –format=tiff –batch=”$WORKDIR/out%d.tif” –progress –batch-double -y 279 3>&1 >&2 2>&3 3>&- | tee $WORKDIR/out_count.txt

#figure out what page to start the flip side scan on
LASTPAGE=`grep “Scanning page ” $WORKDIR/out_count.txt | tail -n 1 | sed ‘s/Scanning page //g’`
BATCHSTART=`echo $LASTPAGE – 1 | bc -l`

#give user a chance to flip and refeed the pages
read -n 1 -p “Flip over the pages (counting down from $BATCHSTART) and press any key to continue…”

#scan the second sides
scanimage –format=tiff –batch=”$WORKDIR/out%d.tif” –progress –batch-increment=-2 –batch-start $BATCHSTART -y 279

else

#scan the pages
scanimage –format=tiff –batch=”$WORKDIR/out%d.tif” –progress -y 279

fi

#combine all the tiff files into one document
tiffcp $WORKDIR/out*.tif $WORKDIR/out_all.tif

#prompt for a filename
read -p “What should I name the document (extension will be added automatically)? ” NAMER
if [ "$NAMER" == "" ]
then
NAMER=”scan$DATESTAMP”
fi

#convert to pdf
tiff2pdf $WORKDIR/out_all.tif -o $OUTPUTDIR/$NAMER.pdf

The script is pretty basic, but should be easily adaptable for your own purposes. You can save it as scan.sh, make it executable, and run it with “./scan.sh”

Capturing from Canon Vixia HV40 in Ubuntu

I am very pleased to report that capturing from my new camera works like a charm.  I hardly had to do any tweaking to get it to work.

Here are some commands that worked for me to begin with:

  • grab video
    sudo dvgrab –autosplit –frames 0 –size 0 –format hdv –buffers 1000 –showstatus –timestamp /home/video/foo-
  • convert to avi format for facebook, etc.
    ffmpeg -i foo.m2t video.avi
  • convert to dv format for editing
    ffmpeg -i /home/video/foo.m2t -target ntsc-dv foo.dv

Convert Raw MiniDV Footage to Upload to Facebook

I just shot a bit of footage I wanted to upload to Facebook. According to this Facebook question, mpeg4 video is a good choice.

This command seems to do the trick to convert my rawdv footage to a Facebook friendly format:

cat foo.dv | ffmpeg -f dv -i pipe: -acodec libfaac -vcodec libx264 -s 640×360 -aspect 16:9 foo.mp4

Note that the names of the codecs in this command seem to vary according to your version of ffmpeg.  If this version doesn’t work, you might try faac and h264 instead of libfaac and libx264, respectively.

Setting up/Moving a Cinelerra Project

I finally decided to reorganize my current video project to make things easier to find.  For starters, I realized that all the raw dv footage I’ve captured should not be in the same folder as the project itself.  That is a recipe for creating copies of the same footage later when I want to use it in another project.

Instead, I created a folder for my footage named by date and subject and stored it with the rest of my similar captured footage.  That way it is ready for me to grab for any project.  Next, I created a project folder (I called it “project_wbp” in my case).  Inside that I added another folder called “media_rawdv”.  Then I used this command in a terminal:

ln -s -t /path/to/media_rawdv /path/to/original/*.dv

That command creates symbolic links (i.e. shortcuts) to all the original files.  Cinelerra doesn’t care whether its resources are real files or links, so this works fine.  Later, if I move the original files, I can just recreate the links and I’m all set.

There are two important steps  you need to do when you move things around or rename them in your project:

1. You should edit your project .xml file and change the paths as necessary (note that Cinelerra doesn’t seem to like relative paths, so you should use absolute ones).  Don’t forget to change the path to the xml file itself if that has moved.  Any text editor can handle this.

2. To save a lot of processing on large projects with many resources, you should rename all the project’s index files (you can change the location in Cinelerra’s settings, but they’re usually in ~/.bcast”) and change the internal paths in each file.  The following program should do the trick:

#!/bin/bash
#first rename the files in .bcast
rename ‘s/home_video_oldname/home_video_project_wbp_media_rawdv/’ ~/.bcast/*.idx
#next use this to fix the internal paths in the index files
OLD=”\/home\/video\/oldname\/”
NEW=”\/home\/video\/project_wbp\/media_rawdv\/”
DPATH=”~/.bcast/*.idx”
BPATH=”~/.bcast/bak/”
TFILE=”/tmp/out.tmp.$$”
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
if [ -f $f -a -r $f ]; then
/bin/cp -f $f $BPATH
echo $f
sed “s/$OLD/$NEW/g” “$f” > $TFILE && mv $TFILE “$f”
else
echo “Error: Cannot read $f”
fi
done
/bin/rm $TFILE

The only things to change in the preceding script are the two paths in the rename command and the same in the OLD and NEW variables.  Note the the index files include real paths (hence the \ escapes to make the literal / characters work), but in their names they replace the / characters with underscores.

For smaller projects, you could probably skip this step, as Cinelerra will regenerate the files anyhow.  For my 40 minute video, which has hundreds of clips, it takes hours to do this.   The script does the job in a couple of minutes.

Capturing Video Over Firewire in UbuStu

Today I wanted to capture some video from mini-DV tapes using my camera, a Panasonic mini-DV model. I have done so in the past using a firewire cable, but this is the first time I’ve tried with my new Ubuntu Studio setup.

Here are the steps to follow:

1. In “Ubuntu Studio Controls,” check “enable raw1394 access.” If you try to use your firewire device now, it may crash the machine, so you should reboot before proceeding. I had the system freeze up on me two or three times before I had everything working reliably (this may be a result of the wonky firewire connection on my camera, which seems to be loose).

2. After the reboot, put the camera into VCR mode and press play. Then run Kino (from a terminal as root) and switch to capture mode. You should see the video playing in the Kino window. Rewind the tape again before you proceed. This step seems to be necessary in order to get Ubuntu Studio to recognize the camera as a firewire device (dvgrab may work just as well).

3. If you aren’t capturing a whole tape, you could just use Kino to control the camera and capture the clips. I actually prefer to do the capture from the command line using dvgrab.  To begin capture, enter this command (again as root):

#dvgrab –autosplit –frames 0 –size 0 –format raw –timestamp <dest>/<foo>

In this command, <dest> is the place you want to store the clips (e.g. /home/video), and
<foo> is whatever prefix you want the resulting filenames to have (e.g. tape1-). The clips will automatically be split into files and the timestamp will follow the prefix in each name.

Once you run the dvgrab command, it will wait for you to press play on the camera and begin capturing the clips. You’ll have to press <ctrl>-c once the clips are finished being captured.

Because of the broken firewire connection on my camera, I investigated the possibility of using USB to capture video, but that doesn’t appear to be a viable choice (and much slower, even if one could get it to work).

More info on firewire in Ubuntu here: Firewire – Community Ubuntu Documentation