== morph.sh ==
Einfach mal was mit Holz machen.

My workflow for digitizing MiniDV tapes on Linux

en linux media preservation

I was given a pile of old MiniDV tapes full of a relative’s home videos, along with a Sony MiniDV camcorder. I promised to convert the tapes into video files, which wasn’t quite as straightforward as I had hoped, but I got it working. A huge help in this was a blog post from Jonathan at jonsdocs.org.uk which explains the process in detail - I’ll keep it brief and just document the steps I took to get it working.


The camera (a Sony DCR-PC108E) came with a dock of sorts that had a Sony i.LINK connector, which, as Jon explains, uses FireWire under the hood, so I bought a cheap FireWire PCIe card off Amazon. The cable that came with it was hot garbage, so I bought a new 4-pin to 6-pin cable too. My workstation running Fedora Linux recognized everything immediately and was ready to go after connecting the camcorder to the dock and the dock to the computer and to the power line.


The script needs dvgrab and ffmpeg to run; dvgrab is available in Fedora’s default repositories, a proper version of ffmpeg needs to be installed from a third-party repo such as RPMFusion. According to Repology it seems that all major distros ship dvgrab; I don’t know if there are any differences in driver support for FireWire cards across distros, but I’d imagine you shouldn’t run into many problems if you stick to generic, non-exotic hardware.

Script magic

Since I’m lazy I like automation, I wrote a shell script that takes care of all the steps for me, except for the last part of transcoding the large .avi file into a more workable .mp4 file - I use HandBrake for that. Since the transcoding step takes a while, I simply run this script for each of the tapes that I have and, after that, do a batch job in HandBrake that transcodes all of the videos at once. This way I can stay at my desk for the things that might require interaction (changing tapes and restarting the script) and the conversion can then run unsupervised later.

Here is the script I came up with. Use it with caution - it’s by no means perfect but it works well enough for me.

# This script is licensed under the MIT License (https://morph.sh/mit-license)

set -e
set -o pipefail

if ! [ "$1" ]; then
    echo "No arguments given! Exiting."
    exit 1

set -u


# make sure the general working directory is there
[ -d "${BASE_DIR}" ] || mkdir "${BASE_DIR}"
mkdir "${BASE_DIR}/to-convert"
mkdir "${BASE_DIR}/converted"

# create directory for this tape
if [[ -d "${BASE_DIR}/${TAPE_NAME}" ]]; then
    echo "Directory ${BASE_DIR}/${TAPE_NAME} exists!"
    echo "Aborting due to risk of losing data."
    echo "Please delete the directory before continuing."
    exit 1
    mkdir "${BASE_DIR}/${TAPE_NAME}"
    cd "${BASE_DIR}/${TAPE_NAME}"

# Start dvgrab
sudo dvgrab --rewind --autosplit --format dv2 "${TAPE_NAME}"-

# Write list of files for ffmpeg to concatenate
rm -f list.txt && find . -name "${TAPE_NAME}*.avi" -exec echo "file '{}'" >> list.txt \;

# Concatenate all video files into one
ffmpeg -f concat -safe 0 -i list.txt -c copy "${TAPE_NAME}_concatenated.avi"

# move file to directory for HandBrake to convert
mv "${TAPE_NAME}_concatenated.avi" "${BASE_DIR}/to-convert"

To use it, simply save the script wherever you like, make it executable, and if necessary edit the BASE_DIR variable to another path. Then, you call it with the name of your tape as the only argument: ./minidv.sh tape23. The rest should happen by itself. After that, use HandBrake on the videos in ${BASE_DIR}/converted with whichever settings suit your needs.

Have fun!

Epilogue: a word on doing this on Windows

Admittedly, my beefy workstation usually runs Windows because I only use it for gaming. To save me the hassle of installing Linux on it, I tried to make it work on Windows - here’s what I’ve learned: all Sony software that used to be able to do this (their docs still point you to “PlayMemories Home”) no longer supports the feature, the driver for the USB connection (which would’ve been WAY easier than FireWire) only worked up to Windows 7. There is a very positively old-school looking utility named WinDV that was last updated in 2003 but apparently still works theoretically. I couldn’t get it to work, but it may have been my fault; I’ve seen people report success for this method with recent OSes.