Batch Operations for GoPro images

Recently I purchased a used GoPro Hero 3 Black. I’ve used it mainly to take time lapse pictures. The GoPro records images in 4x3 aspect ratio, and makes quite large images (2MB+ per frame). With the help of Google, I was able to piece together some scripts to help me convert these to mp4 videos on my MacBook.

Assuming the images have been offloaded from the GoPro’s SD card, group each series of time lapse images into a separate directly. I did not write a script for this, but it should be fairly trivial to do so.

I am by no means an expert in Bash, so there is plenty of room for improvement in these scripts, such as auto-grouping time lapse sequences, and changing the cropping settings.

# $1 - where to move images from (SD card)
# $2 - Where to move images to
# Stills are prefixed with 'GOPR'
mkdir $2/stills
mv $1/GOPR*.JPG $2/stills/
# Videos are also prefixed wih 'GOPR'
mkdir $2/video
mv $1/GOPR* $2/video/
# Remaining images should be timelapse
mkdir $2/lapse
mv $1/*.JPG $2/lapse
# TODO: Group each sequence of time lapse images into their own directory
cd time lapse sequence>
# Rename this sequence
ls *.JPG| awk 'BEGIN{ a=0 }{ printf "mv %s gopro_%04d.jpg\n",$0,a++}' | bash
# Make a MP4 video 
#       30fps   image sequence    1080p     mp4 video    colorspace      use x264     mp4 rate factor  crop filter                output file
ffmpeg -r 30 -i gopro_%04d.JPG -s hd1080 -f mp4 -pix_fmt yuv420p -vcodec libx264 -crf 25               -vf crop=in_w:in_h-480:0:0 out.mp4

I will leave adjusting the crop filter further as an exercise to the reader. I believe this one crops from the top (most of my sequences had a lot of sky in them), and I was shooing in 5MP mode. If you need to crop from the bottom, or if you shoot in a different frame size, the settings will be different.

Leave a Reply