#!/bin/sh # create a side-by-side image or video from files made with the gopro hero3+ dual hero system sync cable. # assumes that the two cameras were positioned unrotated side by side, which is unlike the default dual hero system configuration. this requires rotation of the left image. # accepts left and right files in any order and assumes that the file names have the automatically assigned 3D_L and 3D_R prefixes. # usage: path1 path2 # select left and right image if echo "$1" | grep -i "3d_l" then left="$2" right="$1" elif echo "$2" | grep -i "3d_l" then left="$1" right="$2" else echo error: file names must begin with 3d prefix. $@ exit 1 fi output=$(basename "$left") output="$(dirname "$left")/sbs.$output" extension=$(printf "$left" | tail -c 3) if test mp4 = $extension then # use only "-filter_complex hstack" for merge without any rotation. ffmpeg -y -i "$left" -i "$right" -filter_complex "[1]transpose=1,transpose=1[a];[0][a]hstack" -c:v libx264 -crf 17 -preset slow -c:a copy "$output" elif test jpg = $extension then convert "$left" -rotate 180 "$right" -rotate 180 +append "$output" else echo error: invalid filename extension exit 1 fi