-
Copying Video Files From Action Cameras to a NAS Drive
For unknown reasons, a recent VLC update caused it to ignore uppercase file extensions:
MP4andAVIfiles no longer appear in its directory listings, whilemp4andavifiles 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
THMfiles 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
sudopassword 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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters#!/bin/sh thisdate=$(date –rfc-3339=date) echo Date is $thisdate date # MicroSD cards not automounted as30v=/mnt/AS30V fly6=/mnt/Fly6 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 & pid1=$! rsync -ahu –progress $fly6 /mnt/video date rc2=$? echo Fly6 RC is $rc2 echo Waiting for $as30v wait $pid1 rc=$(( $rc2 + $? )) date 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 else echo Whoopsie: $rc fi