Copying Video Files From Action Cameras to a NAS Drive

For unknown reasons, a recent VLC update caused it to ignore uppercase file extensions: MP4 and AVI files no longer appear in its directory listings, while mp4 and avi files do. The least-awful solution involved renaming the files after copying them:

find /mnt/video -name \*AVI -print0 | xargs -0 rename -v -f 's/AVI/avi/'
find /mnt/video -name \*MP4 -print0 | xargs -0 rename -v -f 's/MP4/mp4/'
find /mnt/video -name \*THM -print0 | xargs -0 rename -v -f 's/THM/thm/'

Yup, that scans the whole drive every time, which takes care of stray files, manual tweaks, and suchlike. The THM files are useless thumbnails; I should just delete them.

While I had the hood up, I listed the remaining space on the NAS drive and cleaned up a few misfeatures. I manually delete old video files / directories as needed, usually immediately after the script crashes for lack of room.

The Sony HDR-AS30V can act as a USB memory device, but it dependably segfaults the ExFAT driver; I now transfer its MicroSD card to an adapter and jam it into the media slot on the monitor, where it works fine.

Protip: always turn the AS30V on to verify the MicroSD card has seated correctly in its socket. Unfortunately, the socket can also hold Sony’s proprietary Memory Stick Micro cards (32 GB maximum capacity = roadkill), but the dual-use / dual-direction socket isn’t a snug fit around MicroSD cards. You (well, I) can insert a card so it looks fine, while sitting slightly canted and not making proper contact. The camera will kvetch about that and it’s easier to fix with the camera in hand.

I’ve disabled USB device automounting, as I vastly prefer to handle them manually, so the script asks for permission in order to mount the drives. The transfer requires about an hour, so I’ve extended the time the sudo password remains active.

The script lets both cards transfer data simultaneously; the Fly6 generally finishes first because it produces less data. That produces a jumbled progress display and the script waits for both drives to finish before continuing.

The Bash source code as a GitHub Gist:

thisdate=$(date --rfc-3339=date)
echo Date is $thisdate
# MicroSD cards not automounted
sudo mount -o uid=ed /dev/sdb1 /mnt/AS30V/
sudo mount -o uid=ed /dev/sdc1 /mnt/Fly6/
# IOmega NAS defined as /mnt/video in fstab
sudo mount /mnt/video
mkdir /mnt/video/$thisdate
rsync -ahu --progress $as30v/MP_ROOT/100ANV01/ /mnt/video/$thisdate &
rsync -ahu --progress $fly6 /mnt/video
echo Fly6 RC is $rc2
echo Waiting for $as30v
wait $pid1
rc=$(( $rc2 + $? ))
echo Overall RC: $rc
if [ $rc -eq 0 ] ; then
echo Fix capitalized extensions
find /mnt/video -name \*AVI -print0 | xargs -0 rename -v -f 's/AVI/avi/'
find /mnt/video -name \*MP4 -print0 | xargs -0 rename -v -f 's/MP4/mp4/'
find /mnt/video -name \*THM -print0 | xargs -0 rename -v -f 's/THM/thm/'
echo Space remaining on NAS drive:
df -h /mnt/video
echo Remove files on AS30V
rm $as30v/MP_ROOT/100ANV01/*
echo Unmount cards and NAS
sudo umount $as30v
sudo umount $fly6
sudo umount /mnt/video
echo Whoopsie: $rc
view raw hosted with ❤ by GitHub